]> 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 316c2ddff5dd56688979e7b3bc0d55a06e90ab2c..d5bf7fb275fe1c026f5b7b1f146b985dad096d14 100644 (file)
@@ -70,35 +70,46 @@ let
     wrapProgram $out/check_ovh_sms --prefix PATH : ${lib.makeBinPath [
       (pkgs.python3.withPackages (ps: [ps.ovh]))
     ]}
+    wrapProgram $out/check_bandwidth --prefix PATH : ${lib.makeBinPath [
+      pkgs.iproute pkgs.bc
+    ]}
     '';
   toObjects = pkgs.callPackage ./to_objects.nix {};
   commonConfig = {
     eldiron = {
       processWarn = "250"; processAlert = "400";
       loadWarn = "8.0"; loadAlert = "10.0";
+      interface = "eth0";
     };
     backup-2 = {
       processWarn = "60"; processAlert = "70";
       loadWarn = "1.0"; loadAlert = "2.0";
+      interface = "ens3";
     };
     monitoring-1 = {
       processWarn = "50"; processAlert = "60";
       loadWarn = "1.0"; loadAlert = "2.0";
+      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;
@@ -124,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;
@@ -143,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 = {
@@ -175,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;
     };