+ 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" "quatresaisons" "dilion"]) 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 (_: n: n.host) externalObjects);
+ };
+ emailCheck = host: hostFQDN: let
+ allCfg = config.myEnv.monitoring.email_check;
+ cfg = allCfg."${host}";
+ reverseTargets = builtins.attrNames (lib.attrsets.filterAttrs (k: v: builtins.elem host v.targets) allCfg);
+ to_email = cfg': host':
+ let sep = if lib.strings.hasInfix "+" cfg'.mail_address then "_" else "+";
+ in "${cfg'.mail_address}${sep}${host'}@${cfg'.mail_domain}";
+ mails_to_send = builtins.concatStringsSep "," (map (n: to_email allCfg."${n}" host) cfg.targets);
+ mails_to_receive = builtins.concatStringsSep "," (map (n: "${to_email cfg n}:${n}") reverseTargets);
+ command = if cfg.local
+ then
+ [ "check_emails_local" "/var/lib/naemon/checks/email" mails_to_send mails_to_receive ]
+ else
+ [ "check_emails" cfg.login cfg.port mails_to_send mails_to_receive ];
+ in
+ {
+ service_description = "${hostFQDN} email service is active";
+ use = "mail-service";
+ host_name = hostFQDN;
+ servicegroups = "webstatus-email";
+ check_command = command;
+ };
+ otherObjects = map
+ (n: (pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; }))
+ [ "ulminfo-fr" "phare" "eban" ];
+ masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; };