1 ###############################################################################
3 ###############################################################################
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 '/'.
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.
13 ###############################################################################
15 ###############################################################################
17 ## Start Monit in the background (run as a daemon):
19 # set daemon 120 # check services at 2-minute intervals
20 # with start delay 240 # optional: delay the first check by 4-minutes (by
21 # # default Monit check immediately after Monit start)
24 ## Set syslog logging with the 'daemon' facility. If the FACILITY option is
25 ## omitted, Monit will use 'user' facility by default. If you want to log to
26 ## a standalone log file instead, specify the full path to the log file
28 # set logfile syslog facility log_daemon
31 ### Set the location of the Monit id file which stores the unique id for the
32 ### Monit instance. The id is generated and stored on first Monit start. By
33 ### default the file is placed in $HOME/.monit.id.
35 # set idfile /var/.monit.id
37 ### Set the location of the Monit state file which saves monitoring states
38 ### on each cycle. By default the file is placed in $HOME/.monit.state. If
39 ### the state file is stored on a persistent filesystem, Monit will recover
40 ### the monitoring state across reboots. If it is on temporary filesystem, the
41 ### state will be lost on reboot which may be convenient in some situations.
43 # set statefile /var/.monit.state
45 ## Set the list of mail servers for alert delivery. Multiple servers may be
46 ## specified using a comma separator. By default Monit uses port 25 - it is
47 ## possible to override this with the PORT option.
49 # set mailserver mail.bar.baz, # primary mailserver
50 # backup.bar.baz port 10025, # backup mailserver on port 10025
51 # localhost # fallback relay
54 ## By default Monit will drop alert events if no mail servers are available.
55 ## If you want to keep the alerts for later delivery retry, you can use the
56 ## EVENTQUEUE statement. The base directory where undelivered alerts will be
57 ## stored is specified by the BASEDIR option. You can limit the maximal queue
58 ## size using the SLOTS option (if omitted, the queue is limited by space
59 ## available in the back end filesystem).
62 # basedir /var/monit # set the base directory where events will be stored
63 # slots 100 # optionally limit the queue size
66 ## Send status and events to M/Monit (for more informations about M/Monit
67 ## see http://mmonit.com/).
69 # set mmonit http://monit:monit@192.168.1.10:8080/collector
72 ## Monit by default uses the following alert mail format:
75 ## From: monit@$HOST # sender
76 ## Subject: monit alert -- $EVENT $SERVICE # subject
78 ## $EVENT Service $SERVICE #
83 ## Description: $DESCRIPTION #
85 ## Your faithful employee, #
89 ## You can override this message format or parts of it, such as subject
90 ## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
91 ## are expanded at runtime. For example, to override the sender, use:
93 # set mail-format { from: monit@foo.bar }
96 ## You can set alert recipients whom will receive alerts if/when a
97 ## service defined in this file has errors. Alerts may be restricted on
98 ## events by using a filter as in the second example below.
100 # set alert sysadm@foo.bar # receive all alerts
101 # set alert manager@foo.bar only on { timeout } # receive just service-
105 ## Monit has an embedded web server which can be used to view status of
106 ## services monitored and manage services from a web interface. See the
107 ## Monit Wiki if you want to enable SSL for the web server.
109 # set httpd port 2812 and
110 # use address localhost # only accept connection from localhost
111 # allow localhost # allow localhost to connect to the server and
112 # allow admin:monit # require user 'admin' with password 'monit'
113 # allow @monit # allow users of group 'monit' to connect (rw)
114 # allow @users readonly # allow users of group 'users' to connect readonly
117 ###############################################################################
119 ###############################################################################
121 ## Check general system resources such as load average, cpu and memory
122 ## usage. Each test specifies a resource, conditions and the action to be
123 ## performed should a test fail.
125 # check system myhost.mydomain.tld
126 # if loadavg (1min) > 4 then alert
127 # if loadavg (5min) > 2 then alert
128 # if memory usage > 75% then alert
129 # if cpu usage (user) > 70% then alert
130 # if cpu usage (system) > 30% then alert
131 # if cpu usage (wait) > 20% then alert
134 ## Check a file for existence, checksum, permissions, uid and gid. In addition
135 ## to alert recipients in the global section, customized alert can be sent to
136 ## additional recipients by specifying a local alert handler. The service may
137 ## be grouped using the GROUP option. More than one group can be specified by
138 ## repeating the 'group name' statement.
140 # check file apache_bin with path /usr/local/apache/bin/httpd
141 # if failed checksum and
142 # expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
143 # if failed permission 755 then unmonitor
144 # if failed uid root then unmonitor
145 # if failed gid root then unmonitor
146 # alert security@foo.bar on {
147 # checksum, permission, uid, gid, unmonitor
148 # } with the mail-format { subject: Alarm! }
152 ## Check that a process is running, in this case Apache, and that it respond
153 ## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
154 ## and number of children. If the process is not running, Monit will restart
155 ## it by default. In case the service is restarted very often and the
156 ## problem remains, it is possible to disable monitoring using the TIMEOUT
157 ## statement. This service depends on another service (apache_bin) which
160 # check process apache with pidfile /usr/local/apache/logs/httpd.pid
161 # start program = "/etc/init.d/httpd start" with timeout 60 seconds
162 # stop program = "/etc/init.d/httpd stop"
163 # if cpu > 60% for 2 cycles then alert
164 # if cpu > 80% for 5 cycles then restart
165 # if totalmem > 200.0 MB for 5 cycles then restart
166 # if children > 250 then restart
167 # if loadavg(5min) greater than 10 for 8 cycles then stop
168 # if failed host www.tildeslash.com port 80 protocol http
169 # and request "/somefile.html"
171 # if failed port 443 type tcpssl protocol http
172 # with timeout 15 seconds
174 # if 3 restarts within 5 cycles then timeout
175 # depends on apache_bin
179 ## Check filesystem permissions, uid, gid, space and inode usage. Other services,
180 ## such as databases, may depend on this resource and an automatically graceful
181 ## stop may be cascaded to them before the filesystem will become full and data
184 # check filesystem datafs with path /dev/sdb1
185 # start program = "/bin/mount /data"
186 # stop program = "/bin/umount /data"
187 # if failed permission 660 then unmonitor
188 # if failed uid root then unmonitor
189 # if failed gid disk then unmonitor
190 # if space usage > 80% for 5 times within 15 cycles then alert
191 # if space usage > 99% then stop
192 # if inode usage > 30000 then alert
193 # if inode usage > 99% then stop
197 ## Check a file's timestamp. In this example, we test if a file is older
198 ## than 15 minutes and assume something is wrong if its not updated. Also,
199 ## if the file size exceed a given limit, execute a script
201 # check file database with path /data/mydatabase.db
202 # if failed permission 700 then alert
203 # if failed uid data then alert
204 # if failed gid data then alert
205 # if timestamp > 15 minutes then alert
206 # if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
209 ## Check directory permission, uid and gid. An event is triggered if the
210 ## directory does not belong to the user with uid 0 and gid 0. In addition,
211 ## the permissions have to match the octal description of 755 (see chmod(1)).
213 # check directory bin with path /bin
214 # if failed permission 755 then unmonitor
215 # if failed uid 0 then unmonitor
216 # if failed gid 0 then unmonitor
219 ## Check a remote host availability by issuing a ping test and check the
220 ## content of a response from a web server. Up to three pings are sent and
221 ## connection to a port and an application level network check is performed.
223 # check host myserver with address 192.168.1.1
224 # if failed icmp type echo count 3 with timeout 3 seconds then alert
225 # if failed port 3306 protocol mysql with timeout 15 seconds then alert
226 # if failed url http://user:password@192.168.1.1:8080/?querystring
227 # and content == 'action="j_security_check"'
231 ###############################################################################
233 ###############################################################################
235 ## It is possible to include additional configuration parts from other files or
239 include /etc/monit/conf.d/*