lib/clerie-monitoring-ids.nix: Add functions to analyse assigned monitoring ids
This commit is contained in:
parent
2cdf09c5ae
commit
5ebe26caf8
@ -134,6 +134,8 @@
|
|||||||
uptimestatus;
|
uptimestatus;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
inherit lib self;
|
||||||
|
|
||||||
hydraJobs = {
|
hydraJobs = {
|
||||||
inherit (self)
|
inherit (self)
|
||||||
packages;
|
packages;
|
||||||
|
13
lib/clerie-monitoring-ids.nix
Normal file
13
lib/clerie-monitoring-ids.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
inputs:
|
||||||
|
|
||||||
|
with inputs.nixpkgs.lib;
|
||||||
|
|
||||||
|
rec {
|
||||||
|
monitoringIdForHost = host: let
|
||||||
|
evalResult = builtins.tryEval (attrByPath [ "clerie" "monitoring" "id" ] null host.config);
|
||||||
|
in
|
||||||
|
if evalResult.success then evalResult.value else null;
|
||||||
|
monitoringIdsByHost = hosts: filterAttrs (name: id: id != null) (mapAttrs (name: host: monitoringIdForHost host) hosts);
|
||||||
|
hostsByMonitoringIds = hosts: mapAttrs' (name: id: nameValuePair id name) (monitoringIdsByHost hosts);
|
||||||
|
monitoringIds = hosts: attrNames (hostsByMonitoringIds hosts);
|
||||||
|
}
|
@ -14,6 +14,7 @@ let
|
|||||||
generateColmenaHost
|
generateColmenaHost
|
||||||
mapToColmenaHosts
|
mapToColmenaHosts
|
||||||
buildHosts;
|
buildHosts;
|
||||||
|
clerie-monitoring-ids = callLibs ./clerie-monitoring-ids.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user