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 30 # check services at 30 seconds intervals
|
---|
20 | # with start delay 240 # optional: delay the first check by 4-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 |
|
---|
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/apache/bin/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 | #
|
---|
195 | ## Check that a process is running, in this case Apache, and that it respond
|
---|
196 | ## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
|
---|
197 | ## and number of children. If the process is not running, Monit will restart
|
---|
198 | ## it by default. In case the service is restarted very often and the
|
---|
199 | ## problem remains, it is possible to disable monitoring using the TIMEOUT
|
---|
200 | ## statement. This service depends on another service (apache_bin) which
|
---|
201 | ## is defined above.
|
---|
202 | #
|
---|
203 | # check process apache with pidfile /usr/local/apache/logs/httpd.pid
|
---|
204 | # start program = "/etc/init.d/httpd start" with timeout 60 seconds
|
---|
205 | # stop program = "/etc/init.d/httpd stop"
|
---|
206 | # if cpu > 60% for 2 cycles then alert
|
---|
207 | # if cpu > 80% for 5 cycles then restart
|
---|
208 | # if totalmem > 200.0 MB for 5 cycles then restart
|
---|
209 | # if children > 250 then restart
|
---|
210 | # if loadavg(5min) greater than 10 for 8 cycles then stop
|
---|
211 | # if failed host www.tildeslash.com port 80 protocol http
|
---|
212 | # and request "/somefile.html"
|
---|
213 | # then restart
|
---|
214 | # if failed port 443 protocol https with timeout 15 seconds then restart
|
---|
215 | # if 3 restarts within 5 cycles then unmonitor
|
---|
216 | # depends on apache_bin
|
---|
217 | # group server
|
---|
218 | #
|
---|
219 | #
|
---|
220 | ## Check filesystem permissions, uid, gid, space and inode usage. Other services,
|
---|
221 | ## such as databases, may depend on this resource and an automatically graceful
|
---|
222 | ## stop may be cascaded to them before the filesystem will become full and data
|
---|
223 | ## lost.
|
---|
224 | #
|
---|
225 | # check filesystem datafs with path /dev/sdb1
|
---|
226 | # start program = "/bin/mount /data"
|
---|
227 | # stop program = "/bin/umount /data"
|
---|
228 | # if failed permission 660 then unmonitor
|
---|
229 | # if failed uid root then unmonitor
|
---|
230 | # if failed gid disk then unmonitor
|
---|
231 | # if space usage > 80% for 5 times within 15 cycles then alert
|
---|
232 | # if space usage > 99% then stop
|
---|
233 | # if inode usage > 30000 then alert
|
---|
234 | # if inode usage > 99% then stop
|
---|
235 | # group server
|
---|
236 | #
|
---|
237 | #
|
---|
238 | ## Check a file's timestamp. In this example, we test if a file is older
|
---|
239 | ## than 15 minutes and assume something is wrong if its not updated. Also,
|
---|
240 | ## if the file size exceed a given limit, execute a script
|
---|
241 | #
|
---|
242 | # check file database with path /data/mydatabase.db
|
---|
243 | # if failed permission 700 then alert
|
---|
244 | # if failed uid data then alert
|
---|
245 | # if failed gid data then alert
|
---|
246 | # if timestamp > 15 minutes then alert
|
---|
247 | # if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
|
---|
248 | #
|
---|
249 | #
|
---|
250 | ## Check directory permission, uid and gid. An event is triggered if the
|
---|
251 | ## directory does not belong to the user with uid 0 and gid 0. In addition,
|
---|
252 | ## the permissions have to match the octal description of 755 (see chmod(1)).
|
---|
253 | #
|
---|
254 | # check directory bin with path /bin
|
---|
255 | # if failed permission 755 then unmonitor
|
---|
256 | # if failed uid 0 then unmonitor
|
---|
257 | # if failed gid 0 then unmonitor
|
---|
258 | #
|
---|
259 | #
|
---|
260 | ## Check a remote host availability by issuing a ping test and check the
|
---|
261 | ## content of a response from a web server. Up to three pings are sent and
|
---|
262 | ## connection to a port and an application level network check is performed.
|
---|
263 | #
|
---|
264 | # check host myserver with address 192.168.1.1
|
---|
265 | # if failed ping then alert
|
---|
266 | # if failed port 3306 protocol mysql with timeout 15 seconds then alert
|
---|
267 | # if failed port 80 protocol http
|
---|
268 | # and request /some/path with content = "a string"
|
---|
269 | # then alert
|
---|
270 | #
|
---|
271 | #
|
---|
272 | ## Check a network link status (up/down), link capacity changes, saturation
|
---|
273 | ## and bandwidth usage.
|
---|
274 | #
|
---|
275 | # check network public with interface eth0
|
---|
276 | # if failed link then alert
|
---|
277 | # if changed link then alert
|
---|
278 | # if saturation > 90% then alert
|
---|
279 | # if download > 10 MB/s then alert
|
---|
280 | # if total uploaded > 1 GB in last hour then alert
|
---|
281 | #
|
---|
282 | #
|
---|
283 | ## Check custom program status output.
|
---|
284 | #
|
---|
285 | # check program myscript with path /usr/local/bin/myscript.sh
|
---|
286 | # if status != 0 then alert
|
---|
287 | #
|
---|
288 | #
|
---|
289 | ###############################################################################
|
---|
290 | ## Includes
|
---|
291 | ###############################################################################
|
---|
292 | ##
|
---|
293 | ## It is possible to include additional configuration parts from other files or
|
---|
294 | ## directories.
|
---|
295 | #
|
---|
296 | # include /etc/monit.d/*
|
---|
297 | #
|
---|