]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/monitoring/default.nix
Add monitoring for duply backup
[perso/Immae/Config/Nix.git] / modules / private / monitoring / default.nix
index d23e9c5e572969611dc6f5e1041dd02622498681..316c2ddff5dd56688979e7b3bc0d55a06e90ab2c 100644 (file)
@@ -11,6 +11,11 @@ let
       pkgs.mailutils
     ]}
     '';
+  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;
   myplugins = pkgs.runCommand "buildplugins" {
     buildInputs = [ pkgs.makeWrapper pkgs.perl ];
   } ''
@@ -21,14 +26,11 @@ let
     wrapProgram $out/send_nrdp.sh --prefix PATH : ${lib.makeBinPath [
       pkgs.curl pkgs.jq
     ]}
-    wrapProgram $out/check_maison_bbc --prefix PATH : ${lib.makeBinPath [
-      pkgs.curl pkgs.jq
-    ]}
     wrapProgram $out/check_mem.sh --prefix PATH : ${lib.makeBinPath [
       pkgs.gnugrep pkgs.gawk pkgs.procps-ng
     ]}
     wrapProgram $out/check_postgres_replication --prefix PATH : ${lib.makeBinPath [
-      pkgs.postgresql
+      postgresqlBinary
     ]}
     wrapProgram $out/check_redis_replication --prefix PATH : ${lib.makeBinPath [
       pkgs.gnugrep pkgs.coreutils pkgs.redis
@@ -56,9 +58,9 @@ let
     wrapProgram $out/check_eriomem --prefix PATH : ${lib.makeBinPath [
       pkgs.s3cmd pkgs.python3
     ]}
-    wrapProgram $out/notify_maison_bbc_by_email --prefix PATH : ${lib.makeBinPath [
-      pkgs.mailutils pkgs.gawk
-    ]}
+    wrapProgram $out/check_eriomem_age --prefix PATH : ${lib.makeBinPath [
+      pkgs.duplicity
+    ]} --set SECRETS_PATH ${lib.optionalString cfg.master config.secrets.fullPaths."eriomem_access_key"}
     wrapProgram $out/notify_by_email --prefix PATH : ${lib.makeBinPath [
       pkgs.mailutils
     ]}
@@ -122,7 +124,7 @@ let
     };
   otherObjects = map
     (n: (pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; }))
-    [ "caldance-1" "ulminfo-fr" "immae-eu" "phare" "tiboqorl-fr" ];
+    [ "caldance-1" "ulminfo-fr" "phare" "tiboqorl-fr" ];
   masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; };
   commonObjects = pkgs.callPackage ./objects_common.nix ({
     master = cfg.master;
@@ -137,7 +139,7 @@ let
       lib.attrsets.optionalAttrs
         (builtins.pathExists specific_file)
         (pkgs.callPackage specific_file {
-          inherit config emailCheck;
+          inherit config nodes emailCheck;
           hostFQDN = config.hostEnv.fqdn;
           hostName = name;
         });
@@ -233,16 +235,27 @@ in
         dest = "naemon/id_rsa";
         user = "naemon";
         group = "naemon";
-        premissions = "0400";
+        permissions = "0400";
         text = config.myEnv.monitoring.ssh_secret_key;
       }
-    ];
+    ] ++ lib.optional cfg.master (
+      {
+        dest = "eriomem_access_key";
+        user = "naemon";
+        group = "naemon";
+        permissions = "0400";
+        text = ''
+          export AWS_ACCESS_KEY_ID="${config.myEnv.backup.accessKeyId}"
+          export AWS_SECRET_ACCESS_KEY="${config.myEnv.backup.secretAccessKey}"
+          export BASE_URL="${config.myEnv.backup.remote}"
+        '';
+      }
+    );
     # needed since extraResource is not in the closure
     systemd.services.naemon.path = [ myplugins ];
     services.naemon = {
       enable = true;
       extraConfig = ''
-        broker_module=${pkgs.naemon-livestatus}/lib/naemon-livestatus/livestatus.so ${config.services.naemon.runDir}/live
         use_syslog=1
         log_initial_states=1
         date_format=iso8601
@@ -250,6 +263,9 @@ in
       '' + lib.optionalString (!cfg.master) ''
         obsess_over_services=1
         ocsp_command=notify-master
+      '' + lib.optionalString (cfg.master) ''
+        broker_module=${pkgs.naemon-livestatus}/lib/naemon-livestatus/livestatus.so ${config.services.naemon.runDir}/live
+        broker_module=${pkgs.status_engine.module}/lib/status-engine/naemon/statusengine-${pkgs.naemon.status_engine_version}.o use_service_perfdata=1 use_process_data=0 use_system_command_data=0 use_external_command_data=0 use_flapping_data=0 use_program_status_data=0 use_notification_data=0 use_contact_status_data=0 use_contact_notification_data=0 use_event_handler_data=0 use_object_data=0
       '';
       extraResource = ''
         $USER2$=${myplugins}