diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-07-15 16:56:35 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-07-15 16:56:35 +0200 |
commit | 46a61a1b237b5b676cf0821bf65932d86cfe67b5 (patch) | |
tree | 19e96c2d7d9f1a1e4c43e59a7ab6bc9bdf459d18 /modules/private/monitoring/default.nix | |
parent | 68c45ad53b34301c1a0c59352a839db13e1f2420 (diff) | |
download | Nix-46a61a1b237b5b676cf0821bf65932d86cfe67b5.tar.gz Nix-46a61a1b237b5b676cf0821bf65932d86cfe67b5.tar.zst Nix-46a61a1b237b5b676cf0821bf65932d86cfe67b5.zip |
Add monitoring for tiboqorl
Diffstat (limited to 'modules/private/monitoring/default.nix')
-rw-r--r-- | modules/private/monitoring/default.nix | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix index 8f8b6c0..d5bf7fb 100644 --- a/modules/private/monitoring/default.nix +++ b/modules/private/monitoring/default.nix | |||
@@ -92,19 +92,24 @@ let | |||
92 | interface = "ens3"; | 92 | interface = "ens3"; |
93 | }; | 93 | }; |
94 | }; | 94 | }; |
95 | externalObjects = lib.genAttrs [ "tiboqorl-fr" ] | ||
96 | (n: pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; }); | ||
95 | masterPassiveObjects = let | 97 | masterPassiveObjects = let |
96 | passiveNodes = lib.attrsets.filterAttrs (n: _: builtins.elem n ["backup-2" "eldiron"]) nodes; | 98 | passiveNodes = lib.attrsets.filterAttrs (n: _: builtins.elem n ["backup-2" "eldiron"]) nodes; |
97 | toPassiveServices = map (s: s.passiveInfo.filter s // s.passiveInfo); | 99 | toPassiveServices = map (s: s.passiveInfo.filter s // s.passiveInfo); |
98 | passiveServices = lib.flatten (lib.attrsets.mapAttrsToList | 100 | passiveServices = lib.flatten (lib.attrsets.mapAttrsToList |
99 | (_: n: toPassiveServices n.config.myServices.monitoring.services) | 101 | (_: n: toPassiveServices n.config.myServices.monitoring.services) |
100 | passiveNodes | 102 | passiveNodes |
101 | ); | 103 | ) ++ lib.flatten (lib.attrsets.mapAttrsToList |
104 | (_: n: toPassiveServices n.service) | ||
105 | externalObjects); | ||
102 | in { | 106 | in { |
103 | service = passiveServices; | 107 | service = passiveServices; |
104 | host = lib.lists.foldr | 108 | host = lib.lists.foldr |
105 | (a: b: a//b) | 109 | (a: b: a//b) |
106 | {} | 110 | {} |
107 | (lib.attrsets.mapAttrsToList (_: h: h.config.myServices.monitoring.hosts) passiveNodes); | 111 | (lib.attrsets.mapAttrsToList (_: h: h.config.myServices.monitoring.hosts) passiveNodes |
112 | ++ lib.attrsets.mapAttrsToList (_: n: n.host) externalObjects); | ||
108 | }; | 113 | }; |
109 | emailCheck = host: hostFQDN: let | 114 | emailCheck = host: hostFQDN: let |
110 | allCfg = config.myEnv.monitoring.email_check; | 115 | allCfg = config.myEnv.monitoring.email_check; |
@@ -130,7 +135,7 @@ let | |||
130 | }; | 135 | }; |
131 | otherObjects = map | 136 | otherObjects = map |
132 | (n: (pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; })) | 137 | (n: (pkgs.callPackage (./. + "/objects_" + n + ".nix") { inherit emailCheck; })) |
133 | [ "caldance-1" "ulminfo-fr" "phare" "tiboqorl-fr" ]; | 138 | [ "caldance-1" "ulminfo-fr" "phare" ]; |
134 | masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; }; | 139 | masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; }; |
135 | commonObjects = pkgs.callPackage ./objects_common.nix ({ | 140 | commonObjects = pkgs.callPackage ./objects_common.nix ({ |
136 | master = cfg.master; | 141 | master = cfg.master; |
@@ -149,6 +154,9 @@ let | |||
149 | hostFQDN = config.hostEnv.fqdn; | 154 | hostFQDN = config.hostEnv.fqdn; |
150 | hostName = name; | 155 | hostName = name; |
151 | }); | 156 | }); |
157 | objectsFiles = lib.mapAttrs' (name: value: lib.nameValuePair | ||
158 | "=/${name}/objects.conf" { alias = pkgs.writeText "objects.conf" (toObjects value); } | ||
159 | ) externalObjects; | ||
152 | in | 160 | in |
153 | { | 161 | { |
154 | options = { | 162 | options = { |
@@ -181,6 +189,10 @@ in | |||
181 | }; | 189 | }; |
182 | 190 | ||
183 | config = lib.mkIf cfg.enable { | 191 | config = lib.mkIf cfg.enable { |
192 | services.nginx = lib.mkIf config.myServices.status.enable { | ||
193 | virtualHosts."status.immae.eu".locations = objectsFiles; | ||
194 | }; | ||
195 | |||
184 | services.duplyBackup.profiles.monitoring = { | 196 | services.duplyBackup.profiles.monitoring = { |
185 | rootDir = config.services.naemon.varDir; | 197 | rootDir = config.services.naemon.varDir; |
186 | }; | 198 | }; |