imap_login = mkOption { type = str; description = "IMAP login"; };
imap_password = mkOption { type = str; description = "IMAP password"; };
eriomem_keys = mkOption { type = listOf (listOf str); description = "Eriomem keys"; default = []; };
+ ovh_sms = mkOption {
+ description = "OVH credentials for sms script";
+ type = submodule {
+ options = {
+ endpoint = mkOption { type = str; default = "ovh-eu"; description = "OVH endpoint"; };
+ application_key = mkOption { type = str; description = "Application key"; };
+ application_secret = mkOption { type = str; description = "Application secret"; };
+ consumer_key = mkOption { type = str; description = "Consumer key"; };
+ account = mkOption { type = str; description = "Account"; };
+ };
+ };
+ };
nrdp_tokens = mkOption { type = listOf str; description = "Tokens allowed to push status update"; };
slack_url = mkOption { type = str; description = "Slack webhook url to push status update"; };
slack_channel = mkOption { type = str; description = "Slack channel to push status update"; };
wrapProgram $out/notify_by_slack --prefix PATH : ${lib.makeBinPath [
pkgs.curl pkgs.jq
]}
+ wrapProgram $out/check_ovh_sms --prefix PATH : ${lib.makeBinPath [
+ (pkgs.python3.withPackages (ps: [ps.ovh]))
+ ]}
'';
toObjects = pkgs.callPackage ./to_objects.nix {};
commonConfig = {
$USER206$=${config.myEnv.monitoring.slack_channel}
$USER207$=${config.myEnv.monitoring.slack_url}
$USER208$=${builtins.concatStringsSep "," (map (builtins.concatStringsSep ":") config.myEnv.monitoring.eriomem_keys)}
+ $USER209$=${builtins.concatStringsSep "," [
+ config.myEnv.monitoring.ovh_sms.endpoint
+ config.myEnv.monitoring.ovh_sms.application_key
+ config.myEnv.monitoring.ovh_sms.application_secret
+ config.myEnv.monitoring.ovh_sms.consumer_key
+ config.myEnv.monitoring.ovh_sms.account
+ ]}
'';
objectDefs = toObjects commonObjects
+ toObjects hostObjects
check_mysql_replication = "${sudo} -u mysql $USER2$/check_mysql_replication \"$ARG1$\" \"$ARG2$\"";
check_postgresql_replication = "${sudo} -u postgres $USER2$/check_postgres_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\"";
check_openldap_replication = "${sudo} -u openldap $USER2$/check_openldap_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\" \"$ARG4$\" \"$ARG5$\"";
+ check_ovh_sms = "$USER2$/check_ovh_sms \"$USER209$\"";
check_redis_replication = "${sudo} -u redis $USER2$/check_redis_replication \"$ARG1$\"";
check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15";
check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit";
_webstatus_url = "imap.immae.eu";
}
+ # Third party services
+ {
+ service_description = "OVH account has enough sms";
+ host_name = "eldiron.immae.eu";
+ use = "external-service";
+ check_command = "check_ovh_sms";
+
+ check_interval = "120";
+ notification_interval = "120";
+ }
+
# Backup services
{
service_description = "Eriomem backup is up and not full";
--- /dev/null
+#!/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)