diff options
Diffstat (limited to 'modules/private/monitoring')
-rw-r--r-- | modules/private/monitoring/default.nix | 10 | ||||
-rw-r--r-- | modules/private/monitoring/objects_common.nix | 1 | ||||
-rw-r--r-- | modules/private/monitoring/objects_monitoring-1.nix | 11 | ||||
-rwxr-xr-x | modules/private/monitoring/plugins/check_ovh_sms | 25 |
4 files changed, 47 insertions, 0 deletions
diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix index a7013af..d23e9c5 100644 --- a/modules/private/monitoring/default.nix +++ b/modules/private/monitoring/default.nix | |||
@@ -65,6 +65,9 @@ let | |||
65 | wrapProgram $out/notify_by_slack --prefix PATH : ${lib.makeBinPath [ | 65 | wrapProgram $out/notify_by_slack --prefix PATH : ${lib.makeBinPath [ |
66 | pkgs.curl pkgs.jq | 66 | pkgs.curl pkgs.jq |
67 | ]} | 67 | ]} |
68 | wrapProgram $out/check_ovh_sms --prefix PATH : ${lib.makeBinPath [ | ||
69 | (pkgs.python3.withPackages (ps: [ps.ovh])) | ||
70 | ]} | ||
68 | ''; | 71 | ''; |
69 | toObjects = pkgs.callPackage ./to_objects.nix {}; | 72 | toObjects = pkgs.callPackage ./to_objects.nix {}; |
70 | commonConfig = { | 73 | commonConfig = { |
@@ -259,6 +262,13 @@ in | |||
259 | $USER206$=${config.myEnv.monitoring.slack_channel} | 262 | $USER206$=${config.myEnv.monitoring.slack_channel} |
260 | $USER207$=${config.myEnv.monitoring.slack_url} | 263 | $USER207$=${config.myEnv.monitoring.slack_url} |
261 | $USER208$=${builtins.concatStringsSep "," (map (builtins.concatStringsSep ":") config.myEnv.monitoring.eriomem_keys)} | 264 | $USER208$=${builtins.concatStringsSep "," (map (builtins.concatStringsSep ":") config.myEnv.monitoring.eriomem_keys)} |
265 | $USER209$=${builtins.concatStringsSep "," [ | ||
266 | config.myEnv.monitoring.ovh_sms.endpoint | ||
267 | config.myEnv.monitoring.ovh_sms.application_key | ||
268 | config.myEnv.monitoring.ovh_sms.application_secret | ||
269 | config.myEnv.monitoring.ovh_sms.consumer_key | ||
270 | config.myEnv.monitoring.ovh_sms.account | ||
271 | ]} | ||
262 | ''; | 272 | ''; |
263 | objectDefs = toObjects commonObjects | 273 | objectDefs = toObjects commonObjects |
264 | + toObjects hostObjects | 274 | + toObjects hostObjects |
diff --git a/modules/private/monitoring/objects_common.nix b/modules/private/monitoring/objects_common.nix index a9d6da4..e21f9d0 100644 --- a/modules/private/monitoring/objects_common.nix +++ b/modules/private/monitoring/objects_common.nix | |||
@@ -117,6 +117,7 @@ in | |||
117 | check_mysql_replication = "${sudo} -u mysql $USER2$/check_mysql_replication \"$ARG1$\" \"$ARG2$\""; | 117 | check_mysql_replication = "${sudo} -u mysql $USER2$/check_mysql_replication \"$ARG1$\" \"$ARG2$\""; |
118 | check_postgresql_replication = "${sudo} -u postgres $USER2$/check_postgres_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\""; | 118 | check_postgresql_replication = "${sudo} -u postgres $USER2$/check_postgres_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\""; |
119 | check_openldap_replication = "${sudo} -u openldap $USER2$/check_openldap_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\" \"$ARG4$\" \"$ARG5$\""; | 119 | check_openldap_replication = "${sudo} -u openldap $USER2$/check_openldap_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\" \"$ARG4$\" \"$ARG5$\""; |
120 | check_ovh_sms = "$USER2$/check_ovh_sms \"$USER209$\""; | ||
120 | check_redis_replication = "${sudo} -u redis $USER2$/check_redis_replication \"$ARG1$\""; | 121 | check_redis_replication = "${sudo} -u redis $USER2$/check_redis_replication \"$ARG1$\""; |
121 | check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15"; | 122 | check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15"; |
122 | check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit"; | 123 | check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit"; |
diff --git a/modules/private/monitoring/objects_monitoring-1.nix b/modules/private/monitoring/objects_monitoring-1.nix index 3200d5c..10327b8 100644 --- a/modules/private/monitoring/objects_monitoring-1.nix +++ b/modules/private/monitoring/objects_monitoring-1.nix | |||
@@ -79,6 +79,17 @@ | |||
79 | _webstatus_url = "imap.immae.eu"; | 79 | _webstatus_url = "imap.immae.eu"; |
80 | } | 80 | } |
81 | 81 | ||
82 | # Third party services | ||
83 | { | ||
84 | service_description = "OVH account has enough sms"; | ||
85 | host_name = "eldiron.immae.eu"; | ||
86 | use = "external-service"; | ||
87 | check_command = "check_ovh_sms"; | ||
88 | |||
89 | check_interval = "120"; | ||
90 | notification_interval = "120"; | ||
91 | } | ||
92 | |||
82 | # Backup services | 93 | # Backup services |
83 | { | 94 | { |
84 | service_description = "Eriomem backup is up and not full"; | 95 | service_description = "Eriomem backup is up and not full"; |
diff --git a/modules/private/monitoring/plugins/check_ovh_sms b/modules/private/monitoring/plugins/check_ovh_sms new file mode 100755 index 0000000..141f82d --- /dev/null +++ b/modules/private/monitoring/plugins/check_ovh_sms | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | import sys | ||
4 | try: | ||
5 | import ovh | ||
6 | |||
7 | [endpoint, application_key, application_secret, consumer_key, account] = sys.argv[1].split(",") | ||
8 | client = ovh.Client( | ||
9 | endpoint=endpoint, | ||
10 | application_key=application_key, | ||
11 | application_secret=application_secret, | ||
12 | consumer_key=consumer_key, | ||
13 | ) | ||
14 | |||
15 | result = client.get('/sms/{}'.format(account))["creditsLeft"] | ||
16 | |||
17 | if result < 20: | ||
18 | print("SMS OVH Critical - Not enough sms left ({})|SMS {}".format(result, result)) | ||
19 | sys.exit(2) | ||
20 | else: | ||
21 | print("SMS OVH Ok - Enough sms left ({})|SMS {}".format(result, result)) | ||
22 | sys.exit(0) | ||
23 | except Exception: | ||
24 | print("SMS OVH UNKNOWN - Error during script") | ||
25 | sys.exit(3) | ||