]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/monitoring/objects_common.nix
Remove mail from syrwenne
[perso/Immae/Config/Nix.git] / modules / private / monitoring / objects_common.nix
CommitLineData
eb071dd4 1{ hostFQDN
e820134d 2, hostName
2d7caffb 3, interface ? "eth0"
eb071dd4
IB
4, processWarn ? "250"
5, processAlert ? "400"
6, loadWarn ? "8.0"
7, loadAlert ? "10.0"
8, mdadm
9, sudo
e820134d
IB
10, master
11, lib
eb071dd4
IB
12, ...
13}:
e820134d
IB
14let
15 defaultPassiveInfo = {
16 filter = lib.attrsets.filterAttrs
17 (k: v: builtins.elem k ["service_description"] || builtins.substring 0 1 k == "_");
18 use = "external-passive-service";
19 freshness_threshold = "450";
20 retry_interval = "1";
21 servicegroups = "webstatus-resources";
22 host_name = hostFQDN;
23 };
24in
eb071dd4
IB
25{
26 host = {
27 "${hostFQDN}" = {
28 alias = hostFQDN;
29 address = hostFQDN;
30 use = "linux-server";
e820134d
IB
31 hostgroups = "webstatus-hosts";
32 _webstatus_name = hostName;
eb071dd4
IB
33 };
34 };
35 service = [
36 {
e820134d 37 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
38 service_description = "Size on root partition";
39 use = "local-service";
40 check_command = ["check_local_disk" "20%" "10%" "/"];
41 }
42 {
e820134d 43 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
44 service_description = "Total number of process";
45 use = "local-service";
46 check_command = [
47 "check_local_procs"
48 processWarn
49 processAlert
50 "RSZDT"
51 ];
52 }
2d7caffb
IB
53 {
54 passiveInfo = defaultPassiveInfo;
55 service_description = "Network bandwidth";
56 use = "local-service";
57 check_interval = "2";
58 max_check_attempts = "20";
59 retry_interval = "2";
60 check_command = [
61 "check_local_bandwidth"
62 interface
63 "20480" # kb/s
64 "51200" # kb/s
65 ];
66 }
eb071dd4 67 {
e820134d 68 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
69 service_description = "Average load";
70 use = "local-service";
71 check_command = [
72 "check_local_load"
73 "${loadWarn},${loadWarn},${loadWarn}"
74 "${loadAlert},${loadAlert},${loadAlert}"
75 ];
76 }
77 {
e820134d 78 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
79 service_description = "Swap usage";
80 use = "local-service";
81 check_command = ["check_local_swap" "20" "10"];
82 }
83 {
e820134d 84 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
85 service_description = "Memory usage";
86 use = "local-service";
87 check_command = ["check_memory" "80" "90"];
88 }
89 {
e820134d 90 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
91 service_description = "NTP is activated and working";
92 use = "local-service";
93 check_command = ["check_ntp"];
94 }
95 {
e820134d 96 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
97 service_description = "No mdadm array is degraded";
98 use = "local-service";
99 check_command = [
100 "check_command_output"
101 "${mdadm}/bin/mdadm --monitor --scan -1"
102 "^$"
103 "-s 0 -r root"
104 ];
105 }
106 ];
107 command = {
e820134d 108 check_dns = "$USER1$/check_dns -H $ARG1$ -s $HOSTADDRESS$ $ARG2$";
71a2425e
IB
109 check_emails = "$USER2$/check_emails -H $HOSTADDRESS$ -i $USER203$ -l $ARG1$ -p $ARG2$ -s $ARG3$ -f $ARG4$";
110 check_emails_local = "$USER2$/check_emails -H $HOSTADDRESS$ -n $ARG1$ -r $ADMINEMAIL$ -s $ARG2$ -f $ARG3$";
25844101 111 check_eriomem = "$USER2$/check_eriomem $USER208$";
171d8e1a 112 check_eriomem_age = "$USER2$/check_eriomem_age $ARG1$";
e820134d
IB
113 check_external_dns = "$USER1$/check_dns -H $ARG2$ -s $ARG1$ $ARG3$";
114 check_ftp_database = "$USER2$/check_ftp_database";
115 check_git = "$USER2$/check_git $USER203$";
116 check_http = "$USER1$/check_http --sni -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\"";
117 check_https = "$USER1$/check_http --sni --ssl -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\"";
118 check_https_auth = "$USER1$/check_http --sni --ssl -a \"$USER202$\" -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -r \"$ARG3$\"";
119 check_https_certificate = "$USER1$/check_http --sni --ssl -H \"$ARG1$\" -C 21,15";
120 check_https_code = "$USER1$/check_http --sni --ssl -f stickyport -H \"$ARG1$\" -u \"$ARG2$\" -e \"$ARG3$\" -r \"$ARG4$\"";
121 check_imap_connection = "$USER2$/check_imap_connection -u \"$USER204$\" -p \"$USER205$\" -H \"imap.immae.eu:143\"";
eb071dd4
IB
122 check_local_disk = "$USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$";
123 check_local_procs = "$USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$";
124 check_local_load = "$USER1$/check_load -w $ARG1$ -c $ARG2$";
125 check_local_swap = "$USER1$/check_swap -n ok -w $ARG1$ -c $ARG2$";
2d7caffb 126 check_local_bandwidth = "$USER2$/check_bandwidth -i=$ARG1$ -w $ARG2$ -c $ARG3$";
eb071dd4 127 check_memory = "$USER2$/check_mem.sh -w $ARG1$ -c $ARG2$";
e820134d 128 check_command_match = "$USER2$/check_command -c \"$ARG1$\" -C \"$ARG2$\" $ARG3$";
eb071dd4 129 check_command_output = "$USER2$/check_command -c \"$ARG1$\" -s 0 -o \"$ARG2$\" $ARG3$";
e820134d 130 check_command_status = "$USER2$/check_command -c \"$ARG1$\" -s \"$ARG2$\" $ARG3$";
eb071dd4 131 check_ntp = "$USER1$/check_ntp_time -t 30 -q -H 0.arch.pool.ntp.org";
e820134d 132 check_mailq = "$USER1$/check_mailq -s -w 1 -c 2";
6015a3b5 133 check_mysql_replication = "${sudo} -u mysql $USER2$/check_mysql_replication \"$ARG1$\" \"$ARG2$\"";
eb071dd4 134 check_postgresql_replication = "${sudo} -u postgres $USER2$/check_postgres_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\"";
16b80abd 135 check_openldap_replication = "${sudo} -u openldap $USER2$/check_openldap_replication \"$ARG1$\" \"$ARG2$\" \"$ARG3$\" \"$ARG4$\" \"$ARG5$\"";
6191bdeb 136 check_ovh_sms = "$USER2$/check_ovh_sms \"$USER209$\"";
6015a3b5 137 check_redis_replication = "${sudo} -u redis $USER2$/check_redis_replication \"$ARG1$\"";
e820134d
IB
138 check_smtp = "$USER1$/check_smtp -H $HOSTADDRESS$ -p 25 -S -D 21,15";
139 check_tcp = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -e \"$ARG2$\" -Mcrit";
140 check_tcp_ssl = "$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -S -D 21,15";
eb071dd4
IB
141
142 check_host_alive = "$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5";
143 check_last_file_date = "${sudo} -u \"$ARG3$\" $USER2$/check_last_file_date \"$ARG1$\" \"$ARG2$\"";
e820134d
IB
144 check_ok = "$USER1$/check_dummy 0 \"Dummy OK\"";
145 check_critical = "$USER1$/check_dummy 2 \"Dummy CRITICAL\"";
eb071dd4 146
e820134d
IB
147 # $OVE is to force naemon to run via shell instead of execve which fails here
148 notify-host-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" HOSTSTATE=\"$HOSTSTATE$\" HOSTOUTPUT=\"$HOSTOUTPUT$\" $USER2$/notify_by_email host \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE";
149 # $OVE is to force naemon to run via shell instead of execve which fails here
150 notify-service-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_email service \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE";
e820134d 151 notify-by-slack = "HOST=\"$HOSTALIAS$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_slack \"$ARG1$\" \"$ARG2$\"";
eb071dd4 152
a97118c4 153 notify-master = "$USER2$/send_nrdp.sh -u \"$USER200$\" -t \"$USER201$\" -H \"$HOSTADDRESS$\" -s \"$SERVICEDESC$\" -S \"$SERVICESTATEID$\" -o \"$SERVICEOUTPUT$ | $SERVICEPERFDATA$\"";
eb071dd4
IB
154 };
155 timeperiod = {
156 "24x7" = {
157 alias = "24 Hours A Day, 7 Days A Week";
158 monday = "00:00-24:00";
159 tuesday = "00:00-24:00";
160 wednesday = "00:00-24:00";
161 thursday = "00:00-24:00";
162 friday = "00:00-24:00";
163 saturday = "00:00-24:00";
164 sunday = "00:00-24:00";
165 };
166 };
e820134d
IB
167 servicegroup = {
168 webstatus-webapps = { alias = "Web applications"; };
169 webstatus-websites = { alias = "Personal websites"; };
170 webstatus-ssl = { alias = "SSL certificates"; };
171 webstatus-dns = { alias = "DNS resolution"; };
172 webstatus-remote-services = { alias = "Other remote services"; };
173 webstatus-local-services = { alias = "Other local services"; };
174 webstatus-email = { alias = "E-mail services"; };
175 webstatus-resources = { alias = "Local resources"; };
176 webstatus-databases = { alias = "Databases resources"; };
177 webstatus-backup = { alias = "Backup resources"; };
178 };
179 hostgroup = {
180 webstatus-hosts = { alias = "Hosts"; };
181 };
eb071dd4
IB
182 contactgroup = {
183 admins = { alias = "Naemon Administrators"; };
184 };
eb071dd4
IB
185 templates = {
186 service = {
187 generic-service = {
188 active_checks_enabled = "1";
189 check_freshness = "0";
190 check_interval = "10";
191 check_period = "24x7";
192 contact_groups = "admins";
193 event_handler_enabled = "1";
194 flap_detection_enabled = "1";
195 is_volatile = "0";
196 max_check_attempts = "3";
197 notification_interval = "60";
198 notification_options = "w,u,c,r,f,s";
199 notification_period = "24x7";
e820134d 200 notifications_enabled = if master then "1" else "0";
eb071dd4
IB
201 obsess_over_service = "1";
202 passive_checks_enabled = "1";
203 process_perf_data = "1";
204 retain_nonstatus_information = "1";
205 retain_status_information = "1";
206 retry_interval = "2";
207 };
208 local-service = {
209 use = "generic-service";
210 host_name = hostFQDN;
211 check_interval = "5";
212 max_check_attempts = "4";
213 retry_interval = "1";
e820134d
IB
214 servicegroups = "webstatus-resources";
215 };
216 external-service = {
217 use = "generic-service";
218 check_interval = "5";
219 max_check_attempts = "4";
220 retry_interval = "1";
221 };
222 web-service = {
223 use = "generic-service";
224 check_interval = "20";
225 max_check_attempts = "2";
226 retry_interval = "1";
227 };
228 external-web-service = {
229 use = "generic-service";
230 check_interval = "20";
231 max_check_attempts = "2";
232 retry_interval = "1";
233 };
234 mail-service = {
235 use = "generic-service";
236 check_interval = "15";
237 max_check_attempts = "1";
238 retry_interval = "1";
239 };
240 dns-service = {
241 use = "generic-service";
242 check_interval = "120";
243 notification_interval = "120";
244 max_check_attempts = "5";
245 retry_interval = "5";
eb071dd4
IB
246 };
247 };
248 # No contact, we go through master
e820134d
IB
249 contact = {
250 generic-contact = {
251 host_notification_commands = "notify-host-by-email";
252 host_notification_options = "d,u,r,f,s";
253 host_notification_period = "24x7";
254 service_notification_commands = "notify-service-by-email";
255 service_notification_options = "w,u,c,r,f,s";
256 service_notification_period = "24x7";
257 };
258 };
eb071dd4
IB
259 host = {
260 generic-host = {
261 event_handler_enabled = "1";
262 flap_detection_enabled = "1";
263 notification_period = "24x7";
264 notifications_enabled = "1";
265 process_perf_data = "1";
266 retain_nonstatus_information = "1";
267 retain_status_information = "1";
268 };
269 linux-server = {
270 check_command = "check_host_alive";
271 check_interval = "5";
272 check_period = "24x7";
273 contact_groups = "admins";
274 max_check_attempts = "10";
275 notification_interval = "120";
276 notification_options = "d,u,r,f";
277 retry_interval = "1";
278 };
279 };
280 };
281}