X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=flakes%2Fprivate%2Fmonitoring%2Fmyplugins.nix;fp=modules%2Fprivate%2Fmonitoring%2Fmyplugins.nix;h=35730bb5c88d610e64197436b1afa6e955de17aa;hb=1a64deeb894dc95e2645a75771732c6cc53a79ad;hp=e59ddc402f1793365feb14e504f3b8c804f4d6f0;hpb=fa25ffd4583cc362075cd5e1b4130f33306103f0;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/monitoring/myplugins.nix b/flakes/private/monitoring/myplugins.nix similarity index 88% rename from modules/private/monitoring/myplugins.nix rename to flakes/private/monitoring/myplugins.nix index e59ddc4..35730bb 100644 --- a/modules/private/monitoring/myplugins.nix +++ b/flakes/private/monitoring/myplugins.nix @@ -21,31 +21,24 @@ in }; notify-primary = { resources = { - USER206 = config.myEnv.monitoring.slack_channel; - USER207 = config.myEnv.monitoring.slack_url; - USER210 = config.myEnv.monitoring.eban.user; - USER211 = config.myEnv.monitoring.eban.password; + USER210 = config.myEnv.monitoring.apprise_urls; }; commands = { # $OVE is to force naemon to run via shell instead of execve which fails here notify-host-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" HOSTSTATE=\"$HOSTSTATE$\" HOSTOUTPUT=\"$HOSTOUTPUT$\" $USER2$/notify_by_email host \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE"; # $OVE is to force naemon to run via shell instead of execve which fails here notify-service-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_email service \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE"; - notify-by-slack = "HOST=\"$HOSTALIAS$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_slack \"$ARG1$\" \"$ARG2$\""; - notify-host-eban-url = "STATUS_NAME=\"Server\" USER=\"$USER210$\" PASSWORD=\"$USER211$\" HOSTSTATE=\"$HOSTSTATE$\" $USER2$/notify_eban_url"; - notify-service-eban-url = "STATUS_NAME=\"$_SERVICEWEBSTATUS_NAME$\" USER=\"$USER210$\" PASSWORD=\"$USER211$\" SERVICESTATE=\"$SERVICESTATE$\" $USER2$/notify_eban_url"; + notify-host-by-apprise = "HOST=\"$HOSTALIAS$\" NOTIFICATIONTYPE=\"$NOTIFICATIONTYPE$\" HOSTSTATE=\"$HOSTSTATE$\" HOSTOUTPUT=\"$HOSTOUTPUT$\" $USER2$/notify_by_apprise host \"$ARG1$\""; + notify-service-by-apprise = "HOST=\"$HOSTALIAS$\" NOTIFICATIONTYPE=\"$NOTIFICATIONTYPE$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_apprise service \"$ARG1$\""; }; chunk = '' - cp ${./plugins}/{notify_by_email,notify_by_slack,notify_eban_url} $out - patchShebangs $out/{notify_by_email,notify_by_slack,notify_eban_url} + cp ${./plugins}/{notify_by_email,notify_by_apprise} $out + patchShebangs $out/{notify_by_email,notify_by_apprise} wrapProgram $out/notify_by_email --prefix PATH : ${lib.makeBinPath [ pkgs.mailutils ]} - wrapProgram $out/notify_by_slack --prefix PATH : ${lib.makeBinPath [ - pkgs.curl pkgs.jq - ]} - wrapProgram $out/notify_eban_url --prefix PATH : ${lib.makeBinPath [ - pkgs.curl + wrapProgram $out/notify_by_apprise --prefix PATH : ${lib.makeBinPath [ + pkgs.apprise ]} ''; }; @@ -79,6 +72,28 @@ in check_external_dns = "$USER1$/check_dns -H $ARG2$ -s $ARG1$ $ARG3$"; }; }; + mdadm = { + commands = { + check_mdadm = "$USER2$/check_command -c \"${pkgs.mdadm}/bin/mdadm --monitor --scan -1\" -s 0 -o \"^$\" -r root"; + }; + sudo = _: { + commands = [ + { command = "${pkgs.mdadm}/bin/mdadm --monitor --scan -1"; options = [ "NOPASSWD" ]; } + ]; + runAs = "root"; + }; + }; + postfix = { + commands = { + check_mailq = "$USER1$/check_mailq -s -w 1 -c 2"; + }; + sudo = _: { + commands = [ + { command = "${pkgs.postfix}/bin/mailq"; options = [ "NOPASSWD" ]; } + ]; + runAs = "root"; + }; + }; emails = { resources = { USER203 = config.secrets.fullPaths."naemon/id_rsa"; @@ -120,7 +135,7 @@ in cp ${./plugins}/check_eriomem $out/ patchShebangs $out/check_eriomem wrapProgram $out/check_eriomem --prefix PATH : ${lib.makeBinPath [ - pkgs.s3cmd pkgs.python3 + pkgs.s3cmd pkgs.python38 ]} cp ${./plugins}/check_backup_age $out/check_backup_eriomem_age patchShebangs $out/check_backup_eriomem_age @@ -178,6 +193,8 @@ in commands = { check_http = "$USER1$/check_http --sni -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\""; check_https = "$USER1$/check_http --sni --ssl -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\""; + check_https_4 = "$USER1$/check_http -4 --sni --ssl -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\""; + check_https_6 = "$USER1$/check_http -6 --sni --ssl -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\""; check_https_auth = "$USER1$/check_http --sni --ssl -a \"$USER202$\" -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\""; check_https_certificate = "$USER1$/check_http --sni --ssl -H \"$ARG1$\" -C 21,15"; check_https_code = "$USER1$/check_http --sni --ssl -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -e \"$ARG3$\" -r \"$ARG4$\""; @@ -240,7 +257,7 @@ in cp ${./plugins}/check_mem.sh $out/ patchShebangs $out/check_mem.sh wrapProgram $out/check_mem.sh --prefix PATH : ${lib.makeBinPath [ - pkgs.gnugrep pkgs.gawk pkgs.procps-ng + pkgs.gnugrep pkgs.gawk pkgs.procps ]} ''; }; @@ -303,31 +320,25 @@ in cp ${./plugins}/check_ovh_sms $out/ patchShebangs $out/check_ovh_sms wrapProgram $out/check_ovh_sms --prefix PATH : ${lib.makeBinPath [ - (pkgs.python3.withPackages (ps: [ps.ovh])) + (pkgs.python38.withPackages (ps: [ps.ovh])) ]} ''; }; - postgresql = { + postgresql = { package }: { commands = { check_postgresql_replication = "${sudo} -u postgres $USER2$/check_postgres_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\""; check_postgresql_database_count = "$USER2$/check_postgres_database_count \"$ARG1$\" \"$ARG2$\" \"$ARG3$\""; }; - chunk = let - postgresqlBinary = if config.myServices.databasesReplication.postgresql.enable - then config.myServices.databasesReplication.postgresql.mainPackage - else if config.myServices.databases.enable - then config.myServices.databases.postgresql.package - else pkgs.postgresql; - in '' + chunk = '' cp ${./plugins}/check_postgres_replication $out/ patchShebangs $out/check_postgres_replication wrapProgram $out/check_postgres_replication --prefix PATH : ${lib.makeBinPath [ - postgresqlBinary + package ]} cp ${./plugins}/check_postgres_database_count $out/ patchShebangs $out/check_postgres_database_count wrapProgram $out/check_postgres_database_count --prefix PATH : ${lib.makeBinPath [ - postgresqlBinary + package ]} '';