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