1 | ###############################################################################
|
---|
2 | ## Monit control file
|
---|
3 | ###############################################################################
|
---|
4 | ##
|
---|
5 | ## Comments begin with a '#' and extend through the end of the line. Keywords
|
---|
6 | ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
|
---|
7 | ##
|
---|
8 | ## Below you will find examples of some frequently used statements. For
|
---|
9 | ## information about the control file and a complete list of statements and
|
---|
10 | ## options, please have a look in the Monit manual.
|
---|
11 | ##
|
---|
12 | ##
|
---|
13 | ###############################################################################
|
---|
14 | ## Global section
|
---|
15 | ###############################################################################
|
---|
16 | ##
|
---|
17 | ## Start Monit in the background (run as a daemon):
|
---|
18 | #
|
---|
19 | set daemon 60 # check services at 60 seconds intervals
|
---|
20 | with start delay 120 # optional: delay the first check by 2-minutes (by
|
---|
21 | # # default Monit check immediately after Monit start)
|
---|
22 | #
|
---|
23 | #
|
---|
24 | ## Set syslog logging. If you want to log to a standalone log file instead,
|
---|
25 | ## specify the full path to the log file
|
---|
26 | #
|
---|
27 | set logfile syslog
|
---|
28 |
|
---|
29 | #
|
---|
30 | #
|
---|
31 | ## Set the location of the Monit lock file which stores the process id of the
|
---|
32 | ## running Monit instance. By default this file is stored in $HOME/.monit.pid
|
---|
33 | #
|
---|
34 | set pidfile /var/run/monit.pid
|
---|
35 | #
|
---|
36 | ## Set the location of the Monit id file which stores the unique id for the
|
---|
37 | ## Monit instance. The id is generated and stored on first Monit start. By
|
---|
38 | ## default the file is placed in $HOME/.monit.id.
|
---|
39 | #
|
---|
40 | set idfile /var/.monit.id
|
---|
41 | #
|
---|
42 | ## Set the location of the Monit state file which saves monitoring states
|
---|
43 | ## on each cycle. By default the file is placed in $HOME/.monit.state. If
|
---|
44 | ## the state file is stored on a persistent filesystem, Monit will recover
|
---|
45 | ## the monitoring state across reboots. If it is on temporary filesystem, the
|
---|
46 | ## state will be lost on reboot which may be convenient in some situations.
|
---|
47 | #
|
---|
48 | set statefile /var/.monit.state
|
---|
49 | #
|
---|
50 | #
|
---|
51 |
|
---|
52 | ## Set limits for various tests. The following example shows the default values:
|
---|
53 | ##
|
---|
54 | # set limits {
|
---|
55 | # programOutput: 512 B, # check program's output truncate limit
|
---|
56 | # sendExpectBuffer: 256 B, # limit for send/expect protocol test
|
---|
57 | # fileContentBuffer: 512 B, # limit for file content test
|
---|
58 | # httpContentBuffer: 1 MB, # limit for HTTP content test
|
---|
59 | # networkTimeout: 5 seconds # timeout for network I/O
|
---|
60 | # programTimeout: 300 seconds # timeout for check program
|
---|
61 | # stopTimeout: 30 seconds # timeout for service stop
|
---|
62 | # startTimeout: 30 seconds # timeout for service start
|
---|
63 | # restartTimeout: 30 seconds # timeout for service restart
|
---|
64 | # }
|
---|
65 |
|
---|
66 | ## Set global SSL options (just most common options showed, see manual for
|
---|
67 | ## full list).
|
---|
68 | #
|
---|
69 | # set ssl {
|
---|
70 | # verify : enable, # verify SSL certificates (disabled by default but STRONGLY RECOMMENDED)
|
---|
71 | # selfsigned : allow # allow self signed SSL certificates (reject by default)
|
---|
72 | # }
|
---|
73 | #
|
---|
74 | #
|
---|
75 | ## Set the list of mail servers for alert delivery. Multiple servers may be
|
---|
76 | ## specified using a comma separator. If the first mail server fails, Monit
|
---|
77 | # will use the second mail server in the list and so on. By default Monit uses
|
---|
78 | # port 25 - it is possible to override this with the PORT option.
|
---|
79 | #
|
---|
80 | # set mailserver mail.bar.baz, # primary mailserver
|
---|
81 | # backup.bar.baz port 10025, # backup mailserver on port 10025
|
---|
82 | # localhost # fallback relay
|
---|
83 | #
|
---|
84 | #
|
---|
85 | ## By default Monit will drop alert events if no mail servers are available.
|
---|
86 | ## If you want to keep the alerts for later delivery retry, you can use the
|
---|
87 | ## EVENTQUEUE statement. The base directory where undelivered alerts will be
|
---|
88 | ## stored is specified by the BASEDIR option. You can limit the queue size
|
---|
89 | ## by using the SLOTS option (if omitted, the queue is limited by space
|
---|
90 | ## available in the back end filesystem).
|
---|
91 | #
|
---|
92 | set eventqueue
|
---|
93 | basedir /var/monit # set the base directory where events will be stored
|
---|
94 | slots 100 # optionally limit the queue size
|
---|
95 | #
|
---|
96 | #
|
---|
97 | ## Send status and events to M/Monit (for more informations about M/Monit
|
---|
98 | ## see https://mmonit.com/). By default Monit registers credentials with
|
---|
99 | ## M/Monit so M/Monit can smoothly communicate back to Monit and you don't
|
---|
100 | ## have to register Monit credentials manually in M/Monit. It is possible to
|
---|
101 | ## disable credential registration using the commented out option below.
|
---|
102 | ## Though, if safety is a concern we recommend instead using https when
|
---|
103 | ## communicating with M/Monit and send credentials encrypted. The password
|
---|
104 | ## should be URL encoded if it contains URL-significant characters like
|
---|
105 | ## ":", "?", "@".
|
---|
106 | #
|
---|
107 | # set mmonit http://monit:monit@192.168.1.10:8080/collector
|
---|
108 | # # and register without credentials # Don't register credentials
|
---|
109 | #
|
---|
110 | #
|
---|
111 | ## Monit by default uses the following format for alerts if the the mail-format
|
---|
112 | ## statement is missing::
|
---|
113 | ## --8<--
|
---|
114 | ## set mail-format {
|
---|
115 | ## from: Monit <monit@$HOST>
|
---|
116 | ## subject: monit alert -- $EVENT $SERVICE
|
---|
117 | ## message: $EVENT Service $SERVICE
|
---|
118 | ## Date: $DATE
|
---|
119 | ## Action: $ACTION
|
---|
120 | ## Host: $HOST
|
---|
121 | ## Description: $DESCRIPTION
|
---|
122 | ##
|
---|
123 | ## Your faithful employee,
|
---|
124 | ## Monit
|
---|
125 | ## }
|
---|
126 | ## --8<--
|
---|
127 | ##
|
---|
128 | ## You can override this message format or parts of it, such as subject
|
---|
129 | ## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
|
---|
130 | ## are expanded at runtime. For example, to override the sender, use:
|
---|
131 | #
|
---|
132 | # set mail-format { from: monit@foo.bar }
|
---|
133 | #
|
---|
134 | #
|
---|
135 | ## You can set alert recipients whom will receive alerts if/when a
|
---|
136 | ## service defined in this file has errors. Alerts may be restricted on
|
---|
137 | ## events by using a filter as in the second example below.
|
---|
138 | #
|
---|
139 | # set alert sysadm@foo.bar # receive all alerts
|
---|
140 | #
|
---|
141 | ## Do not alert when Monit starts, stops or performs a user initiated action.
|
---|
142 | ## This filter is recommended to avoid getting alerts for trivial cases.
|
---|
143 | #
|
---|
144 | # set alert your-name@your.domain not on { instance, action }
|
---|
145 | #
|
---|
146 | #
|
---|
147 | ## Monit has an embedded HTTP interface which can be used to view status of
|
---|
148 | ## services monitored and manage services from a web interface. The HTTP
|
---|
149 | ## interface is also required if you want to issue Monit commands from the
|
---|
150 | ## command line, such as 'monit status' or 'monit restart service' The reason
|
---|
151 | ## for this is that the Monit client uses the HTTP interface to send these
|
---|
152 | ## commands to a running Monit daemon. See the Monit Wiki if you want to
|
---|
153 | ## enable SSL for the HTTP interface.
|
---|
154 | #
|
---|
155 | set httpd port 2812 and
|
---|
156 | # use address localhost # only accept connection from localhost
|
---|
157 | allow 172.16.0.0/12
|
---|
158 | allow localhost
|
---|
159 | # allow localhost # allow localhost to connect to the server and
|
---|
160 | # allow guest:guest read-only
|
---|
161 | ###############################################################################
|
---|
162 | ## Services
|
---|
163 | ###############################################################################
|
---|
164 | ##
|
---|
165 | ## Check general system resources such as load average, cpu and memory
|
---|
166 | ## usage. Each test specifies a resource, conditions and the action to be
|
---|
167 | ## performed should a test fail.
|
---|
168 | #
|
---|
169 | # check system $HOST
|
---|
170 | # if loadavg (1min) > 4 then alert
|
---|
171 | # if loadavg (5min) > 2 then alert
|
---|
172 | # if cpu usage > 95% for 10 cycles then alert
|
---|
173 | # if memory usage > 75% then alert
|
---|
174 | # if swap usage > 25% then alert
|
---|
175 | #
|
---|
176 | #
|
---|
177 | ## Check if a file exists, checksum, permissions, uid and gid. In addition
|
---|
178 | ## to alert recipients in the global section, customized alert can be sent to
|
---|
179 | ## additional recipients by specifying a local alert handler. The service may
|
---|
180 | ## be grouped using the GROUP option. More than one group can be specified by
|
---|
181 | ## repeating the 'group name' statement.
|
---|
182 | #
|
---|
183 | check file apache_bin with path /usr/local/sbin/httpd
|
---|
184 | # if failed checksum and
|
---|
185 | # expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
|
---|
186 | if failed permission 755 then unmonitor
|
---|
187 | if failed uid root then unmonitor
|
---|
188 | # if failed gid root then unmonitor
|
---|
189 | # alert security@foo.bar on {
|
---|
190 | # checksum, permission, uid, gid, unmonitor
|
---|
191 | # } with the mail-format { subject: Alarm! }
|
---|
192 | # group server
|
---|
193 | #
|
---|
194 | check file nsd_bin with path /usr/local/sbin/nsd
|
---|
195 | if failed permission 755 then unmonitor
|
---|
196 | if failed uid root then unmonitor
|
---|
197 |
|
---|
198 | #
|
---|
199 | ## Check that a process is running, in this case Apache, and that it respond
|
---|
200 | ## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
|
---|
201 | ## and number of children. If the process is not running, Monit will restart
|
---|
202 | ## it by default. In case the service is restarted very often and the
|
---|
203 | ## problem remains, it is possible to disable monitoring using the TIMEOUT
|
---|
204 | ## statement. This service depends on another service (apache_bin) which
|
---|
205 | ## is defined above.
|
---|
206 | #
|
---|
207 | check process apache with pidfile /var/run/httpd.pid
|
---|
208 | start program = "/usr/local/etc/rc.d/apache24 start" with timeout 60 seconds
|
---|
209 | stop program = "/usr/local/etc/rc.d/apache24 stop"
|
---|
210 | # if cpu > 60% for 2 cycles then alert
|
---|
211 | if cpu > 80% for 5 cycles then restart
|
---|
212 | if totalmem > 200.0 MB for 5 cycles then restart
|
---|
213 | if children > 250 then restart
|
---|
214 | # if loadavg(5min) greater than 10 for 8 cycles then stop
|
---|
215 | if failed host localhost port 80 protocol http
|
---|
216 | and request "/index.html"
|
---|
217 | then restart
|
---|
218 | # if failed port 443 protocol https with timeout 15 seconds then restart
|
---|
219 | # if 3 restarts within 5 cycles then unmonitor
|
---|
220 | depends on apache_bin
|
---|
221 | # group server
|
---|
222 | #
|
---|
223 |
|
---|
224 | check process cron with pidfile /var/run/cron.pid
|
---|
225 | start program = "/etc/rc.d/cron start"
|
---|
226 | stop program = "/etc/rc.d/cron stop"
|
---|
227 |
|
---|
228 | check process dhcpd with pidfile /var/run/dhcpd/dhcpd.pid
|
---|
229 | start program = "/usr/local/etc/rc.d/isc-dhcpd start" with timeout 60 seconds
|
---|
230 | stop program = "/usr/local/etc/rc.d/isc-dhcpd stop"
|
---|
231 |
|
---|
232 | check process lvrouted with pidfile /var/run/lvrouted.pid
|
---|
233 | start program = "/usr/local/etc/rc.d/lvrouted start"
|
---|
234 | stop program = "/usr/local/etc/rc.d/lvrouted stop"
|
---|
235 |
|
---|
236 | check process nsd with pidfile /var/run/nsd/nsd.pid
|
---|
237 | start program = "/usr/local/etc/rc.d/nsd start" with timeout 60 seconds
|
---|
238 | stop program = "/usr/local/etc/rc.d/nsd stop"
|
---|
239 | depends on nsd_bin
|
---|
240 |
|
---|
241 | check process ntpd with pidfile /var/run/ntpd.pid
|
---|
242 | start program = "/etc/rc.d/ntpd start"
|
---|
243 | stop program = "/etc/rc.d/ntpd stop"
|
---|
244 |
|
---|
245 | check process snmpd with pidfile /var/run/net_snmpd.pid
|
---|
246 | start program = "/usr/local/etc/rc.d/snmpd start"
|
---|
247 | stop program = "/usr/local/etc/rc.d/snmpd stop"
|
---|
248 |
|
---|
249 | check process sshd with pidfile /var/run/sshd.pid
|
---|
250 | start program = "/etc/rc.d/sshd start"
|
---|
251 | stop program = "/etc/rc.d/sshd stop"
|
---|
252 |
|
---|
253 | check process syslogd with pidfile /var/run/syslog.pid
|
---|
254 | start program = "/etc/rc.d/syslogd start"
|
---|
255 | stop program = "/etc/rc.d/syslogd stop"
|
---|
256 |
|
---|
257 | check process tcpserver with pidfile /var/run/tcpserver.pid
|
---|
258 | start program = "/usr/local/etc/rc.d/http302 start"
|
---|
259 | stop program = "/usr/local/etc/rc.d/http302 stop"
|
---|
260 |
|
---|
261 |
|
---|
262 | check process unbound with pidfile /etc/local//unbound/unbound.pid
|
---|
263 | start program = "/usr/local/etc/rc.d/unbound start"
|
---|
264 | stop program = "/usr/local/etc/rc.d/unbound stop"
|
---|
265 |
|
---|
266 | #
|
---|
267 | ## Check filesystem permissions, uid, gid, space and inode usage. Other services,
|
---|
268 | ## such as databases, may depend on this resource and an automatically graceful
|
---|
269 | ## stop may be cascaded to them before the filesystem will become full and data
|
---|
270 | ## lost.
|
---|
271 | #
|
---|
272 |
|
---|
273 | check filesystem etc with path /dev/md0
|
---|
274 | if space usage > 90% then exec /sbin/reboot
|
---|
275 |
|
---|
276 | check filesystem var with path /dev/md1
|
---|
277 | if space usage > 90% then exec /sbin/reboot
|
---|
278 |
|
---|
279 | check filesystem tmp with path /dev/md2
|
---|
280 | if space usage > 90% then exec /sbin/reboot
|
---|
281 |
|
---|
282 | # check filesystem cfg with path /dev/ufs/WLIMGs3
|
---|
283 | # check filesystem rootfs-1a with path /dev/ufs/WLIMGs1a
|
---|
284 | # check filesystem rootfs-1b with path /dev/ufs/WLIMGs1b
|
---|
285 |
|
---|
286 | # check filesystem datafs with path /dev/sdb1
|
---|
287 | # start program = "/bin/mount /data"
|
---|
288 | # stop program = "/bin/umount /data"
|
---|
289 | # if failed permission 660 then unmonitor
|
---|
290 | # if failed uid root then unmonitor
|
---|
291 | # if failed gid disk then unmonitor
|
---|
292 | # if space usage > 80% for 5 times within 15 cycles then alert
|
---|
293 | # if space usage > 99% then stop
|
---|
294 | # if inode usage > 30000 then alert
|
---|
295 | # if inode usage > 99% then stop
|
---|
296 | # group server
|
---|
297 | #
|
---|
298 | #
|
---|
299 | ## Check a file's timestamp. In this example, we test if a file is older
|
---|
300 | ## than 15 minutes and assume something is wrong if its not updated. Also,
|
---|
301 | ## if the file size exceed a given limit, execute a script
|
---|
302 | #
|
---|
303 | # check file database with path /data/mydatabase.db
|
---|
304 | # if failed permission 700 then alert
|
---|
305 | # if failed uid data then alert
|
---|
306 | # if failed gid data then alert
|
---|
307 | # if timestamp > 15 minutes then alert
|
---|
308 | # if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
|
---|
309 | #
|
---|
310 | #
|
---|
311 | ## Check directory permission, uid and gid. An event is triggered if the
|
---|
312 | ## directory does not belong to the user with uid 0 and gid 0. In addition,
|
---|
313 | ## the permissions have to match the octal description of 755 (see chmod(1)).
|
---|
314 | #
|
---|
315 | # check directory bin with path /bin
|
---|
316 | # if failed permission 755 then unmonitor
|
---|
317 | # if failed uid 0 then unmonitor
|
---|
318 | # if failed gid 0 then unmonitor
|
---|
319 | #
|
---|
320 | #
|
---|
321 | ## Check a remote host availability by issuing a ping test and check the
|
---|
322 | ## content of a response from a web server. Up to three pings are sent and
|
---|
323 | ## connection to a port and an application level network check is performed.
|
---|
324 | #
|
---|
325 | # check host myserver with address 192.168.1.1
|
---|
326 | # if failed ping then alert
|
---|
327 | # if failed port 3306 protocol mysql with timeout 15 seconds then alert
|
---|
328 | # if failed port 80 protocol http
|
---|
329 | # and request /some/path with content = "a string"
|
---|
330 | # then alert
|
---|
331 | #
|
---|
332 | #
|
---|
333 | ## Check a network link status (up/down), link capacity changes, saturation
|
---|
334 | ## and bandwidth usage.
|
---|
335 | #
|
---|
336 | # check network public with interface eth0
|
---|
337 | # if failed link then alert
|
---|
338 | # if changed link then alert
|
---|
339 | # if saturation > 90% then alert
|
---|
340 | # if download > 10 MB/s then alert
|
---|
341 | # if total uploaded > 1 GB in last hour then alert
|
---|
342 | #
|
---|
343 | #
|
---|
344 | ## Check custom program status output.
|
---|
345 | #
|
---|
346 | # check program myscript with path /usr/local/bin/myscript.sh
|
---|
347 | # if status != 0 then alert
|
---|
348 | #
|
---|
349 | #
|
---|
350 | ###############################################################################
|
---|
351 | ## Includes
|
---|
352 | ###############################################################################
|
---|
353 | ##
|
---|
354 | ## It is possible to include additional configuration parts from other files or
|
---|
355 | ## directories.
|
---|
356 | #
|
---|
357 | # include /etc/monit.d/*
|
---|
358 | #
|
---|