diff options
Diffstat (limited to 'modules/private')
-rw-r--r-- | modules/private/environment.nix | 12 | ||||
-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 |
5 files changed, 59 insertions, 0 deletions
diff --git a/modules/private/environment.nix b/modules/private/environment.nix index 2cecc6d..b7589eb 100644 --- a/modules/private/environment.nix +++ b/modules/private/environment.nix | |||
@@ -497,6 +497,18 @@ in | |||
497 | imap_login = mkOption { type = str; description = "IMAP login"; }; | 497 | imap_login = mkOption { type = str; description = "IMAP login"; }; |
498 | imap_password = mkOption { type = str; description = "IMAP password"; }; | 498 | imap_password = mkOption { type = str; description = "IMAP password"; }; |
499 | eriomem_keys = mkOption { type = listOf (listOf str); description = "Eriomem keys"; default = []; }; | 499 | eriomem_keys = mkOption { type = listOf (listOf str); description = "Eriomem keys"; default = []; }; |
500 | ovh_sms = mkOption { | ||
501 | description = "OVH credentials for sms script"; | ||
502 | type = submodule { | ||
503 | options = { | ||
504 | endpoint = mkOption { type = str; default = "ovh-eu"; description = "OVH endpoint"; }; | ||
505 | application_key = mkOption { type = str; description = "Application key"; }; | ||
506 | application_secret = mkOption { type = str; description = "Application secret"; }; | ||
507 | consumer_key = mkOption { type = str; description = "Consumer key"; }; | ||
508 | account = mkOption { type = str; description = "Account"; }; | ||
509 | }; | ||
510 | }; | ||
511 | }; | ||
500 | nrdp_tokens = mkOption { type = listOf str; description = "Tokens allowed to push status update"; }; | 512 | nrdp_tokens = mkOption { type = listOf str; description = "Tokens allowed to push status update"; }; |
501 | slack_url = mkOption { type = str; description = "Slack webhook url to push status update"; }; | 513 | slack_url = mkOption { type = str; description = "Slack webhook url to push status update"; }; |
502 | slack_channel = mkOption { type = str; description = "Slack channel to push status update"; }; | 514 | slack_channel = mkOption { type = str; description = "Slack channel to push status update"; }; |
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) | ||