]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add monitoring for tiboqorl
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 15 Jul 2020 14:56:35 +0000 (16:56 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 15 Jul 2020 14:56:35 +0000 (16:56 +0200)
modules/private/monitoring/default.nix
modules/private/monitoring/objects_monitoring-1.nix
modules/private/monitoring/objects_tiboqorl-fr.nix
modules/private/pub/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;
     };
index 320f6e33fa7c4be2445ac9d2ac7653b560b38dc3..2cba58e03179748048be801cc49865c3873f1943 100644 (file)
@@ -679,9 +679,14 @@ in
       use = "generic-contact";
       contactgroups = "telio-tortay";
     };
+    thibault = config.myEnv.monitoring.contacts.thibault // {
+      use = "generic-contact";
+      contactgroups = "tiboqorl";
+    };
   };
   contactgroup = {
     telio-tortay = { alias = "Telio Tortay"; members = "immae"; };
+    tiboqorl = { alias = "Tiboqorl"; members = "immae"; };
   };
   servicedependency = map to_eriomem_age_dependency (builtins.attrNames nodes.eldiron.config.services.duplyBackup.profiles);
 }
index 1cc6ea00d7ec79e1bd8c561b211c47525bde26c7..97b7f7b8ba8598d0a5ae9508819a76c52fc48313 100644 (file)
-{ ... }:
+{ lib, ... }:
+let
+  hostFQDN = "tiboqorl.fr";
+  defaultPassiveInfo = {
+    filter = lib.attrsets.filterAttrs
+      (k: v: builtins.elem k ["service_description"] || builtins.substring 0 1 k == "_");
+    use = "external-passive-service";
+    contact_groups = "tiboqorl";
+    freshness_threshold = "450";
+    retry_interval = "1";
+    servicegroups = "webstatus-resources";
+    host_name = hostFQDN;
+  };
+in
 {
   host = {
     "tiboqorl.fr" = {
       alias = "tiboqorl.fr";
       address = "tiboqorl.fr";
       use = "linux-server";
+      contact_groups = "tiboqorl";
+      hostgroups = "webstatus-hosts";
+      _webstatus_name = "tiboqorl";
+    };
+  };
+  service = [
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "Size on root partition";
+      use = "local-service";
+      check_command = ["check_local_disk" "20%" "10%" "/"];
+    }
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "Total number of process";
+      use = "local-service";
+      check_command = [ "check_local_procs" "250" "400" "RSZDT" ];
+    }
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "Network bandwidth";
+      use = "local-service";
+      check_interval = "2";
+      max_check_attempts = "20";
+      retry_interval = "2";
+      check_command = [
+        "check_local_bandwidth"
+        "eth0"
+        "20480" # kb/s
+        "51200" # kb/s
+      ];
+    }
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "Average load";
+      use = "local-service";
+      check_command = [
+        "check_local_load"
+        "3.0,3.0,3.0" # warn
+        "4.0,4.0,4.0" # alert
+      ];
+    }
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "Swap usage";
+      use = "local-service";
+      check_command = ["check_local_swap" "20" "10"];
+    }
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "Memory usage";
+      use = "local-service";
+      check_command = ["check_memory" "80" "90"];
+    }
+    {
+      passiveInfo = defaultPassiveInfo;
+      service_description = "NTP is activated and working";
+      use = "local-service";
+      check_command = ["check_ntp"];
+    }
+  ];
+  command = {
+    check_local_disk = "$USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$";
+    check_local_procs = "/usr/bin/sudo $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$";
+    check_local_load = "$USER1$/check_load -w $ARG1$ -c $ARG2$";
+    check_local_swap = "$USER1$/check_swap -n ok -w $ARG1$ -c $ARG2$";
+    check_local_bandwidth = "/usr/bin/sudo $USER2$/check_bandwidth -i=$ARG1$ -w $ARG2$ -c $ARG3$";
+    check_memory = "$USER2$/check_mem.sh -w $ARG1$ -c $ARG2$";
+    check_ntp = "$USER1$/check_ntp_time -t 30 -q -H 0.arch.pool.ntp.org";
+
+    check_host_alive = "$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5";
+
+    notify-master = "$USER2$/send_nrdp.sh -u \"$USER200$\" -t \"$USER201$\" -H \"$HOSTADDRESS$\" -s \"$SERVICEDESC$\" -S \"$SERVICESTATEID$\" -o \"$SERVICEOUTPUT$ | $SERVICEPERFDATA$\"";
+  };
+  timeperiod = {
+    "24x7" = {
+      alias = "24 Hours A Day, 7 Days A Week";
+      monday = "00:00-24:00";
+      tuesday = "00:00-24:00";
+      wednesday = "00:00-24:00";
+      thursday = "00:00-24:00";
+      friday = "00:00-24:00";
+      saturday = "00:00-24:00";
+      sunday = "00:00-24:00";
+    };
+  };
+  servicegroup = {
+    webstatus-resources = { alias = "Local resources"; };
+  };
+  hostgroup = {
+    webstatus-hosts = { alias = "Hosts"; };
+  };
+  contactgroup = {
+    tiboqorl = { alias = "Naemon Administrators"; };
+  };
+  templates = {
+    service = {
+      generic-service = {
+        active_checks_enabled = "1";
+        check_freshness = "0";
+        check_interval = "10";
+        check_period = "24x7";
+        contact_groups = "tiboqorl";
+        event_handler_enabled = "1";
+        flap_detection_enabled = "1";
+        is_volatile = "0";
+        max_check_attempts = "3";
+        notification_interval = "60";
+        notification_options = "w,u,c,r,f,s";
+        notification_period = "24x7";
+        notifications_enabled = "0";
+        obsess_over_service = "1";
+        passive_checks_enabled = "1";
+        process_perf_data = "1";
+        retain_nonstatus_information = "1";
+        retain_status_information = "1";
+        retry_interval = "2";
+      };
+      local-service = {
+        use = "generic-service";
+        host_name = hostFQDN;
+        check_interval = "5";
+        max_check_attempts = "4";
+        retry_interval = "1";
+        servicegroups = "webstatus-resources";
+      };
+    };
+    host = {
+      generic-host = {
+        event_handler_enabled = "1";
+        flap_detection_enabled = "1";
+        notification_period = "24x7";
+        notifications_enabled = "1";
+        process_perf_data = "1";
+        retain_nonstatus_information = "1";
+        retain_status_information = "1";
+      };
+      linux-server = {
+        check_command = "check_host_alive";
+        check_interval = "5";
+        check_period = "24x7";
+        contact_groups = "tiboqorl";
+        max_check_attempts = "10";
+        notification_interval = "120";
+        notification_options = "d,u,r,f";
+        retry_interval = "1";
+      };
     };
   };
 }
index 790395c68f9b3b7b9dc5be9217c99fe729426a34..49f3ab8a1907fcd4e7a27a615c05ce94351d17ce 100644 (file)
@@ -19,7 +19,7 @@
       rootDir = "/var/lib/pub";
     };
     users.users.pub = let
-      restrict = pkgs.runCommand "restrict" { 
+      restrict = pkgs.runCommand "restrict" {
         file = ./restrict;
         buildInputs = [ pkgs.makeWrapper ];
       } ''