aboutsummaryrefslogtreecommitdiff
path: root/modules/private/monitoring/default.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-02 01:33:08 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-02 01:33:08 +0100
commiteb071dd42518cb40d629e5bde29c6aed72e4d4df (patch)
treef9a109801d540ef8fc4c1b0656436f560ad1f6b7 /modules/private/monitoring/default.nix
parent9f2025235d888eb4a7822024a5fad2e288388814 (diff)
downloadNix-eb071dd42518cb40d629e5bde29c6aed72e4d4df.tar.gz
Nix-eb071dd42518cb40d629e5bde29c6aed72e4d4df.tar.zst
Nix-eb071dd42518cb40d629e5bde29c6aed72e4d4df.zip
Use nix expressions to build monitoring list
Diffstat (limited to 'modules/private/monitoring/default.nix')
-rw-r--r--modules/private/monitoring/default.nix56
1 files changed, 20 insertions, 36 deletions
diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix
index 6062aba..0259cbf 100644
--- a/modules/private/monitoring/default.nix
+++ b/modules/private/monitoring/default.nix
@@ -17,42 +17,26 @@ let
17 pkgs.postgresql 17 pkgs.postgresql
18 ]} 18 ]}
19 ''; 19 '';
20 defaultObjects = 20 toObjects = pkgs.callPackage ./to_objects.nix {};
21 let specific_file = ./conf + "/specific_" + name + ".cfg"; 21 commonConfig = {
22 eldiron = {
23 processWarn = "250"; processAlert = "400";
24 loadWarn = "8.0"; loadAlert = "10.0";
25 };
26 backup-2 = {
27 processWarn = "50"; processAlert = "60";
28 loadWarn = "1.0"; loadAlert = "2.0";
29 };
30 };
31 commonObjects = pkgs.callPackage ./objects_common.nix ({
32 inherit hostFQDN;
33 sudo = "/run/wrappers/bin/sudo";
34 } // builtins.getAttr name commonConfig);
35 hostObjects =
36 let
37 specific_file = ./. + "/objects_" + name + ".nix";
22 in 38 in
23 builtins.readFile ./conf/local_services.cfg 39 lib.attrsets.optionalAttrs (builtins.pathExists specific_file) (pkgs.callPackage specific_file {});
24 + builtins.readFile ./conf/timeperiods.cfg
25 + builtins.readFile ./conf/services.cfg
26 + builtins.readFile ./conf/contacts.cfg
27 + builtins.readFile ./conf/hosts.cfg
28 + ''
29 define command {
30 command_line ${myplugins}/send_nrdp.sh -u "$USER200$" -t "$USER201$" -H "$HOSTADDRESS$" -s "$SERVICEDESC$" -S "$SERVICESTATEID$" -o "$SERVICEOUTPUT$"
31 command_name notify-master
32 }
33 define service {
34 service_description No mdadm array is degraded
35 use local-service
36 check_command check_command_output!${pkgs.mdadm}/bin/mdadm --monitor --scan -1!^$!-s 0 -r root
37 }
38
39 define service {
40 name local-service
41 use generic-service
42 host_name ${hostFQDN}
43 check_interval 5
44 max_check_attempts 4
45 register 0
46 retry_interval 1
47 }
48 define host {
49 host_name ${hostFQDN}
50 alias ${hostFQDN}
51 address ${hostFQDN}
52 use linux-server
53 }
54 ''
55 + lib.strings.optionalString (builtins.pathExists specific_file) (builtins.readFile specific_file);
56in 40in
57{ 41{
58 options = { 42 options = {
@@ -122,7 +106,7 @@ in
122 $USER200$=${myconfig.env.monitoring.status_url} 106 $USER200$=${myconfig.env.monitoring.status_url}
123 $USER201$=${myconfig.env.monitoring.status_token} 107 $USER201$=${myconfig.env.monitoring.status_token}
124 ''; 108 '';
125 objectDefs = defaultObjects; 109 objectDefs = toObjects commonObjects + toObjects hostObjects;
126 }; 110 };
127 }; 111 };
128} 112}