]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/monitoring/objects_monitoring-1.nix
Refactor monitoring to avoid useless resources in each machine
[perso/Immae/Config/Nix.git] / modules / private / monitoring / objects_monitoring-1.nix
index 3200d5c3f9fa61153100be4591b5b9d07cacbdfa..32dbe4b9cd758b340f3bd13903cd587a4fd606ab 100644 (file)
@@ -1,5 +1,28 @@
-{ config, pkgs, hostFQDN, emailCheck, ... }:
+{ config, pkgs, nodes, hostFQDN, emailCheck, lib, ... }:
+let
+  to_resource = func: cfg: lib.flatten (lib.optionals cfg.enable (lib.mapAttrsToList func cfg.profiles));
+  to_backup_age_dependency = name: profile: map (remote:
+    {
+      dependent_host_name = "eldiron.immae.eu";
+      host_name           = "eldiron.immae.eu";
+      dependent_service_description = "${remote} backup for ${name} is not too old";
+      service_description = "${remote} backup is up and not full";
+      execution_failure_criteria = "u";
+      notification_failure_criteria = "u";
+    }) profile.remotes;
+  to_backup_age = name: profile: map (remote:
+    {
+      service_description = "${remote} backup for ${name} is not too old";
+      host_name = "eldiron.immae.eu";
+      use = "external-service";
+      check_command = ["check_backup_${remote}_age" name];
+
+      check_interval = "120";
+      notification_interval = "1440";
+    }) profile.remotes;
+in
 {
+  activatedPlugins = [ "dns" "ftp" "git" "http" "imap" "ovh" "tcp" ];
   host = {
     # Dummy host for testing
     # "dummy-host" = {
       _webstatus_url = "imap.immae.eu";
     }
 
+    # Third party services
+    {
+      service_description = "OVH account has enough sms";
+      host_name = "eldiron.immae.eu";
+      use = "external-service";
+      check_command = "check_ovh_sms";
+
+      check_interval = "120";
+      notification_interval = "1440";
+    }
+
     # Backup services
+    # {
+    #   service_description = "eriomem backup is up and not full";
+    #   host_name = "eldiron.immae.eu";
+    #   use = "external-service";
+    #   check_command = "check_backup_eriomem";
+
+    #   check_interval = "120";
+    #   notification_interval = "1440";
+
+    #   servicegroups = "webstatus-backup";
+    # }
     {
-      service_description = "Eriomem backup is up and not full";
+      service_description = "ovh backup is up and not full";
       host_name = "eldiron.immae.eu";
       use = "external-service";
-      check_command = "check_eriomem";
+      check_command = "check_ok";
 
       check_interval = "120";
-      notification_interval = "120";
+      notification_interval = "1440";
 
       servicegroups = "webstatus-backup";
     }
       service_description = "roundcube website is running on mail.immae.eu";
       host_name = "eldiron.immae.eu";
       use = "external-web-service";
-      check_command = ["check_https_code" "mail.immae.eu" "/roundcube/" "401" "<title>Roundcube"];
+      check_command = ["check_https" "mail.immae.eu" "/roundcube/" "<title>Roundcube"];
 
       servicegroups = "webstatus-webapps,webstatus-email";
       _webstatus_name = "Roundcube";
       service_description = "gitweb website is running on git.immae.eu";
       host_name = "eldiron.immae.eu";
       use = "external-web-service";
-      check_command = ["check_https" "git.immae.eu" "/" "git web interface"];
+      check_command = ["check_https" "git.immae.eu" "/cgit" "<title>Immae’s git"];
 
       servicegroups = "webstatus-webapps";
       _webstatus_name = "Git";
       service_description = "Telio website is running on realistesmedia.fr";
       host_name = "eldiron.immae.eu";
       use = "external-web-service";
-      check_command = ["check_https" "realistesmedia.fr" "/" "<title>Réal'istes"];
+      check_command = ["check_https" "realistesmedia.fr" "/" "doctype html"];
       contact_groups = "telio-tortay";
     }
 
       _webstatus_url = "https://www.sandetludo.com/";
     }
 
-    {
-      service_description = "Maison bbc accepts add requests on http";
-      host_name = "eldiron.immae.eu";
-      use = "external-web-service";
-      check_command = [ "check_http" "maison.bbc.bouya.org" "/add.php" "^$"];
-    }
-
-    {
-      service_description = "Maison bbc has up to date data";
-      host_name = "eldiron.immae.eu";
-      use = "generic-service";
-      contact_groups = "maison-bbc";
-      notification_interval = "1440";
-      check_command = "check_maison_bbc";
-      flap_detection_enabled = "0";
-      max_check_attempts = "1";
-    }
-
     # SSL
     {
       service_description = "ldap SSL is up to date";
       _webstatus_name = "LDAP";
       _webstatus_url = "ldap.immae.eu";
     }
-  ];
+
+    # Tiboqorl
+    {
+      service_description = "Cyllene support page is running";
+      host_name = "tiboqorl.fr";
+      use = "external-web-service";
+      contact_groups = "tiboqorl";
+      check_command = [ "check_https" "sc.groupe-cyllene.com" "/" "<title>Support Client Cyllene" ];
+      _webstatus_namespace = "tiboqorl";
+    }
+
+    {
+      service_description = "Origny page is running";
+      host_name = "tiboqorl.fr";
+      use = "external-web-service";
+      contact_groups = "tiboqorl";
+      check_command = [ "check_https" "origny.tiboqorl.fr" "/" "<title>Home Assistant" ];
+      _webstatus_namespace = "tiboqorl";
+    }
+  ] ++ to_resource to_backup_age nodes.eldiron.config.services.duplyBackup;
   contact = {
     telio-tortay = config.myEnv.monitoring.contacts.telio-tortay // {
       use = "generic-contact";
       contactgroups = "telio-tortay";
     };
-    papa = config.myEnv.monitoring.contacts.papa // {
+    thibault = config.myEnv.monitoring.contacts.thibault // {
       use = "generic-contact";
-      contactgroups = "maison-bbc";
-      service_notification_commands = "notify-maison-bbc-by-email";
+      contactgroups = "tiboqorl";
     };
   };
   contactgroup = {
-    maison-bbc = { alias = "Maison BBC"; };
     telio-tortay = { alias = "Telio Tortay"; members = "immae"; };
+    tiboqorl = { alias = "Tiboqorl"; members = "immae"; };
   };
+  servicedependency = to_resource to_backup_age_dependency nodes.eldiron.config.services.duplyBackup;
 }