| 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 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/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 dhcpd with pidfile /var/run/dhcpd/dhcpd.pid
|
|---|
| 225 | start program = "/usr/local/etc/rc.d/isc-dhcpd start" with timeout 60 seconds
|
|---|
| 226 | stop program = "/usr/local/etc/rc.d/isc-dhcpd stop"
|
|---|
| 227 |
|
|---|
| 228 | check process lvrouted with pidfile /var/run/lvrouted.pid
|
|---|
| 229 | start program = "/usr/local/etc/rc.d/lvrouted start"
|
|---|
| 230 | stop program = "/usr/local/etc/rc.d/lvrouted stop"
|
|---|
| 231 |
|
|---|
| 232 | check process nsd with pidfile /var/run/nsd/nsd.pid
|
|---|
| 233 | start program = "/usr/local/etc/rc.d/nsd start" with timeout 60 seconds
|
|---|
| 234 | stop program = "/usr/local/etc/rc.d/nsd stop"
|
|---|
| 235 | depends on nsd_bin
|
|---|
| 236 |
|
|---|
| 237 | check process ntpd with pidfile /var/run/ntpd.pid
|
|---|
| 238 | start program = "/etc/rc.d/ntpd start"
|
|---|
| 239 | stop program = "/etc/rc.d/ntpd stop"
|
|---|
| 240 |
|
|---|
| 241 | check process unbound with pidfile /etc/local//unbound/unbound.pid
|
|---|
| 242 | start program = "/usr/local/etc/rc.d/unbound start"
|
|---|
| 243 | stop program = "/usr/local/etc/rc.d/unbound stop"
|
|---|
| 244 |
|
|---|
| 245 | #
|
|---|
| 246 | ## Check filesystem permissions, uid, gid, space and inode usage. Other services,
|
|---|
| 247 | ## such as databases, may depend on this resource and an automatically graceful
|
|---|
| 248 | ## stop may be cascaded to them before the filesystem will become full and data
|
|---|
| 249 | ## lost.
|
|---|
| 250 | #
|
|---|
| 251 | # check filesystem datafs with path /dev/sdb1
|
|---|
| 252 | # start program = "/bin/mount /data"
|
|---|
| 253 | # stop program = "/bin/umount /data"
|
|---|
| 254 | # if failed permission 660 then unmonitor
|
|---|
| 255 | # if failed uid root then unmonitor
|
|---|
| 256 | # if failed gid disk then unmonitor
|
|---|
| 257 | # if space usage > 80% for 5 times within 15 cycles then alert
|
|---|
| 258 | # if space usage > 99% then stop
|
|---|
| 259 | # if inode usage > 30000 then alert
|
|---|
| 260 | # if inode usage > 99% then stop
|
|---|
| 261 | # group server
|
|---|
| 262 | #
|
|---|
| 263 | #
|
|---|
| 264 | ## Check a file's timestamp. In this example, we test if a file is older
|
|---|
| 265 | ## than 15 minutes and assume something is wrong if its not updated. Also,
|
|---|
| 266 | ## if the file size exceed a given limit, execute a script
|
|---|
| 267 | #
|
|---|
| 268 | # check file database with path /data/mydatabase.db
|
|---|
| 269 | # if failed permission 700 then alert
|
|---|
| 270 | # if failed uid data then alert
|
|---|
| 271 | # if failed gid data then alert
|
|---|
| 272 | # if timestamp > 15 minutes then alert
|
|---|
| 273 | # if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
|
|---|
| 274 | #
|
|---|
| 275 | #
|
|---|
| 276 | ## Check directory permission, uid and gid. An event is triggered if the
|
|---|
| 277 | ## directory does not belong to the user with uid 0 and gid 0. In addition,
|
|---|
| 278 | ## the permissions have to match the octal description of 755 (see chmod(1)).
|
|---|
| 279 | #
|
|---|
| 280 | # check directory bin with path /bin
|
|---|
| 281 | # if failed permission 755 then unmonitor
|
|---|
| 282 | # if failed uid 0 then unmonitor
|
|---|
| 283 | # if failed gid 0 then unmonitor
|
|---|
| 284 | #
|
|---|
| 285 | #
|
|---|
| 286 | ## Check a remote host availability by issuing a ping test and check the
|
|---|
| 287 | ## content of a response from a web server. Up to three pings are sent and
|
|---|
| 288 | ## connection to a port and an application level network check is performed.
|
|---|
| 289 | #
|
|---|
| 290 | # check host myserver with address 192.168.1.1
|
|---|
| 291 | # if failed ping then alert
|
|---|
| 292 | # if failed port 3306 protocol mysql with timeout 15 seconds then alert
|
|---|
| 293 | # if failed port 80 protocol http
|
|---|
| 294 | # and request /some/path with content = "a string"
|
|---|
| 295 | # then alert
|
|---|
| 296 | #
|
|---|
| 297 | #
|
|---|
| 298 | ## Check a network link status (up/down), link capacity changes, saturation
|
|---|
| 299 | ## and bandwidth usage.
|
|---|
| 300 | #
|
|---|
| 301 | # check network public with interface eth0
|
|---|
| 302 | # if failed link then alert
|
|---|
| 303 | # if changed link then alert
|
|---|
| 304 | # if saturation > 90% then alert
|
|---|
| 305 | # if download > 10 MB/s then alert
|
|---|
| 306 | # if total uploaded > 1 GB in last hour then alert
|
|---|
| 307 | #
|
|---|
| 308 | #
|
|---|
| 309 | ## Check custom program status output.
|
|---|
| 310 | #
|
|---|
| 311 | # check program myscript with path /usr/local/bin/myscript.sh
|
|---|
| 312 | # if status != 0 then alert
|
|---|
| 313 | #
|
|---|
| 314 | #
|
|---|
| 315 | ###############################################################################
|
|---|
| 316 | ## Includes
|
|---|
| 317 | ###############################################################################
|
|---|
| 318 | ##
|
|---|
| 319 | ## It is possible to include additional configuration parts from other files or
|
|---|
| 320 | ## directories.
|
|---|
| 321 | #
|
|---|
| 322 | # include /etc/monit.d/*
|
|---|
| 323 | #
|
|---|