]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - systems/eldiron/monitoring.nix
Squash changes containing private information
[perso/Immae/Config/Nix.git] / systems / eldiron / monitoring.nix
diff --git a/systems/eldiron/monitoring.nix b/systems/eldiron/monitoring.nix
new file mode 100644 (file)
index 0000000..2aa7f8f
--- /dev/null
@@ -0,0 +1,51 @@
+{ config, pkgs, lib, name, monitoring, ... }:
+let
+  hostFQDN = config.hostEnv.fqdn;
+  emailCheck = monitoring.lib.emailCheck config.myEnv.monitoring.email_check;
+in
+{
+  config.myServices.monitoring.activatedPlugins = [ "memory" "command" "bandwidth" "emails" "mdadm" "postfix" "postgresql" "zfs" "notify-secondary"];
+  config.myServices.monitoring.pluginsArgs.postgresql.package = config.myServices.databases.postgresql.package;
+  config.myServices.monitoring.objects = lib.mkMerge [
+    (monitoring.lib.objectsCommon {
+      inherit hostFQDN;
+      hostName = name;
+      master = false;
+      processWarn = "550"; processAlert = "650";
+      loadWarn = "1.0"; loadAlert = "1.2";
+      interface = builtins.head (builtins.attrNames config.networking.interfaces);
+    })
+
+    {
+      service = [
+        {
+          service_description = "No mdadm array is degraded";
+          use = "local-service";
+          check_command = ["check_mdadm"];
+          __passive_servicegroups = "webstatus-resources";
+        }
+        {
+          service_description = "Postgresql replication for backup-2 is up to date";
+          use = "local-service";
+          check_command = ["check_postgresql_replication" "backup-2" "/run/postgresql" "5432"];
+          __passive_servicegroups = "webstatus-databases";
+        }
+        {
+          service_description = "No ZFS pool is degraded";
+          use = "local-service";
+          check_command = ["check_zfs"];
+          __passive_servicegroups = "webstatus-resources";
+        }
+        {
+          service_description = "mailq is empty";
+          use = "local-service";
+          check_command = ["check_mailq"];
+          __passive_servicegroups = "webstatus-email";
+        }
+        (emailCheck "eldiron" hostFQDN // {
+          __passive_servicegroups = "webstatus-email";
+        })
+      ];
+    }
+  ];
+}