aboutsummaryrefslogtreecommitdiff
path: root/modules/private/monitoring/default.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-01 18:25:16 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-01 18:25:16 +0100
commit9f2025235d888eb4a7822024a5fad2e288388814 (patch)
treecd9ed388375e5843b373a5975b1e902b61ecaded /modules/private/monitoring/default.nix
parent0012da0ff3d45df9f68412b90be4f7c24d46a777 (diff)
downloadNix-9f2025235d888eb4a7822024a5fad2e288388814.tar.gz
Nix-9f2025235d888eb4a7822024a5fad2e288388814.tar.zst
Nix-9f2025235d888eb4a7822024a5fad2e288388814.zip
Add monitoring for backup-2
Diffstat (limited to 'modules/private/monitoring/default.nix')
-rw-r--r--modules/private/monitoring/default.nix114
1 files changed, 64 insertions, 50 deletions
diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix
index c5acd40..6062aba 100644
--- a/modules/private/monitoring/default.nix
+++ b/modules/private/monitoring/default.nix
@@ -1,4 +1,4 @@
1{ config, myconfig, pkgs, lib, ... }: 1{ config, myconfig, pkgs, lib, name, hostFQDN, ... }:
2let 2let
3 myplugins = pkgs.runCommand "buildplugins" { 3 myplugins = pkgs.runCommand "buildplugins" {
4 buildInputs = [ pkgs.makeWrapper pkgs.perl ]; 4 buildInputs = [ pkgs.makeWrapper pkgs.perl ];
@@ -13,16 +13,57 @@ let
13 wrapProgram $out/check_mem.sh --prefix PATH : ${lib.makeBinPath [ 13 wrapProgram $out/check_mem.sh --prefix PATH : ${lib.makeBinPath [
14 pkgs.gnugrep pkgs.gawk pkgs.procps-ng 14 pkgs.gnugrep pkgs.gawk pkgs.procps-ng
15 ]} 15 ]}
16 wrapProgram $out/check_postgres_replication --prefix PATH : ${lib.makeBinPath [
17 pkgs.postgresql
18 ]}
16 ''; 19 '';
20 defaultObjects =
21 let specific_file = ./conf + "/specific_" + name + ".cfg";
22 in
23 builtins.readFile ./conf/local_services.cfg
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);
17in 56in
18{ 57{
19 options = { 58 options = {
20 myServices.monitoring.enable = lib.mkOption { 59 myServices.monitoring = {
21 type = lib.types.bool; 60 enable = lib.mkOption {
22 default = false; 61 type = lib.types.bool;
23 description = '' 62 default = false;
24 Whether to enable monitoring. 63 description = ''
25 ''; 64 Whether to enable monitoring.
65 '';
66 };
26 }; 67 };
27 }; 68 };
28 69
@@ -39,6 +80,21 @@ in
39 users = [ "naemon" ]; 80 users = [ "naemon" ];
40 runAs = "root"; 81 runAs = "root";
41 } 82 }
83 {
84 commands = [
85 { command = "${myplugins}/check_postgres_replication *"; options = [ "NOPASSWD" ]; }
86 { command = "${myplugins}/check_last_file_date /backup2/*"; options = [ "NOPASSWD" ]; }
87 ];
88 users = [ "naemon" ];
89 runAs = "postgres";
90 }
91 {
92 commands = [
93 { command = "${myplugins}/check_last_file_date /backup2/*"; options = [ "NOPASSWD" ]; }
94 ];
95 users = [ "naemon" ];
96 runAs = "backup";
97 }
42 ]; 98 ];
43 environment.etc."mdadm.conf" = { 99 environment.etc."mdadm.conf" = {
44 enable = true; 100 enable = true;
@@ -66,49 +122,7 @@ in
66 $USER200$=${myconfig.env.monitoring.status_url} 122 $USER200$=${myconfig.env.monitoring.status_url}
67 $USER201$=${myconfig.env.monitoring.status_token} 123 $USER201$=${myconfig.env.monitoring.status_token}
68 ''; 124 '';
69 objectDefs = builtins.readFile ./conf/local_services.cfg 125 objectDefs = defaultObjects;
70 + builtins.readFile ./conf/timeperiods.cfg
71 + builtins.readFile ./conf/services.cfg
72 + builtins.readFile ./conf/contacts.cfg
73 + builtins.readFile ./conf/hosts.cfg
74 + ''
75 define command {
76 command_line ${myplugins}/send_nrdp.sh -u "$USER200$" -t "$USER201$" -H "$HOSTADDRESS$" -s "$SERVICEDESC$" -S "$SERVICESTATEID$" -o "$SERVICEOUTPUT$"
77 command_name notify-master
78 }
79 define service {
80 service_description No mdadm array is degraded
81 use local-service
82 check_command check_command_output!${pkgs.mdadm}/bin/mdadm --monitor --scan -1!^$!-s 0 -r root
83 }
84
85 define service {
86 service_description mailq is empty
87 use local-service
88 check_command check_mailq
89 }
90
91 define command {
92 command_name check_mailq
93 command_line $USER1$/check_mailq -s -w 1 -c 2
94 }
95
96 define service {
97 name local-service
98 use generic-service
99 host_name eldiron.immae.eu
100 check_interval 5
101 max_check_attempts 4
102 register 0
103 retry_interval 1
104 }
105 define host {
106 host_name eldiron.immae.eu
107 alias eldiron.immae.eu
108 address eldiron.immae.eu
109 use linux-server
110 }
111 '';
112 }; 126 };
113 }; 127 };
114} 128}