]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/monitoring/default.nix
Add monitoring for tiboqorl
[perso/Immae/Config/Nix.git] / modules / private / monitoring / default.nix
index 8f8b6c0d1494adb803a79604565972c4f22ba18a..d5bf7fb275fe1c026f5b7b1f146b985dad096d14 100644 (file)
@@ -92,19 +92,24 @@ let
       interface = "ens3";
     };
   };
+  externalObjects = lib.genAttrs [ "tiboqorl-fr" ]
+    (n: pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; });
   masterPassiveObjects = let
     passiveNodes = lib.attrsets.filterAttrs (n: _: builtins.elem n ["backup-2" "eldiron"]) nodes;
     toPassiveServices = map (s: s.passiveInfo.filter s // s.passiveInfo);
     passiveServices = lib.flatten (lib.attrsets.mapAttrsToList
       (_: n: toPassiveServices n.config.myServices.monitoring.services)
       passiveNodes
-      );
+      ) ++ lib.flatten (lib.attrsets.mapAttrsToList
+      (_: n: toPassiveServices n.service)
+      externalObjects);
   in {
     service = passiveServices;
     host = lib.lists.foldr
       (a: b: a//b)
       {}
-      (lib.attrsets.mapAttrsToList (_: h: h.config.myServices.monitoring.hosts) passiveNodes);
+      (lib.attrsets.mapAttrsToList (_: h: h.config.myServices.monitoring.hosts) passiveNodes
+      ++ lib.attrsets.mapAttrsToList (_: n: n.host) externalObjects);
   };
   emailCheck = host: hostFQDN: let
     allCfg = config.myEnv.monitoring.email_check;
@@ -130,7 +135,7 @@ let
     };
   otherObjects = map
     (n: (pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; }))
-    [ "caldance-1" "ulminfo-fr" "phare" "tiboqorl-fr" ];
+    [ "caldance-1" "ulminfo-fr" "phare" ];
   masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; };
   commonObjects = pkgs.callPackage ./objects_common.nix ({
     master = cfg.master;
@@ -149,6 +154,9 @@ let
           hostFQDN = config.hostEnv.fqdn;
           hostName = name;
         });
+  objectsFiles = lib.mapAttrs' (name: value: lib.nameValuePair
+    "=/${name}/objects.conf" { alias = pkgs.writeText "objects.conf" (toObjects value); }
+  ) externalObjects;
 in
 {
   options = {
@@ -181,6 +189,10 @@ in
   };
 
   config = lib.mkIf cfg.enable {
+    services.nginx = lib.mkIf config.myServices.status.enable {
+      virtualHosts."status.immae.eu".locations = objectsFiles;
+    };
+
     services.duplyBackup.profiles.monitoring = {
       rootDir = config.services.naemon.varDir;
     };