]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - flakes/private/monitoring/plugins/check_ovh_sms
Squash changes containing private information
[perso/Immae/Config/Nix.git] / flakes / private / monitoring / plugins / check_ovh_sms
diff --git a/flakes/private/monitoring/plugins/check_ovh_sms b/flakes/private/monitoring/plugins/check_ovh_sms
new file mode 100755 (executable)
index 0000000..caf279c
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import sys
+try:
+    import ovh
+
+    [endpoint, application_key, application_secret, consumer_key, account] = sys.argv[1].split(",")
+    client = ovh.Client(
+        endpoint=endpoint,
+        application_key=application_key,
+        application_secret=application_secret,
+        consumer_key=consumer_key,
+    )
+
+    result = client.get('/sms/{}'.format(account))["creditsLeft"]
+
+    if result < 20:
+        print("SMS OVH Critical - Not enough sms left ({})|SMS={};;;;".format(result, result))
+        sys.exit(2)
+    else:
+        print("SMS OVH Ok - Enough sms left ({})|SMS={};;;;".format(result, result))
+        sys.exit(0)
+except Exception:
+    print("SMS OVH UNKNOWN - Error during script")
+    sys.exit(3)