Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- ## Monit control file
- ###############################################################################
- ##
- ## Comments begin with a '#' and extend through the end of the line. Keywords
- ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
- ##
- ## Below you will find examples of some frequently used statements. For
- ## information about the control file and a complete list of statements and
- ## options, please have a look in the Monit manual.
- ##
- ##
- ###############################################################################
- ## Global section
- ###############################################################################
- ##
- ## Start Monit in the background (run as a daemon):
- #
- set daemon 120 # check services at 2-minute intervals
- with start delay 60 # optional: delay the first check by 4-minutes (by
- # # default Monit check immediately after Monit start)
- #
- #
- ## Set syslog logging with the 'daemon' facility. If the FACILITY option is
- ## omitted, Monit will use 'user' facility by default. If you want to log to
- ## a standalone log file instead, specify the full path to the log file
- #
- # set logfile syslog facility log_daemon
- set logfile /var/log/monit.log
- #
- #
- ## Set the location of the Monit lock file which stores the process id of the
- ## running Monit instance. By default this file is stored in $HOME/.monit.pid
- #
- set pidfile /var/run/monit.pid
- #
- ## Set the location of the Monit id file which stores the unique id for the
- ## Monit instance. The id is generated and stored on first Monit start. By
- ## default the file is placed in $HOME/.monit.id.
- #
- # set idfile /var/.monit.id
- set idfile /var/lib/monit/id
- #
- ## Set the location of the Monit state file which saves monitoring states
- ## on each cycle. By default the file is placed in $HOME/.monit.state. If
- ## the state file is stored on a persistent filesystem, Monit will recover
- ## the monitoring state across reboots. If it is on temporary filesystem, the
- ## state will be lost on reboot which may be convenient in some situations.
- #
- # set statefile /var/.monit.state
- set statefile /var/lib/monit/state
- #
- ## Set the list of mail servers for alert delivery. Multiple servers may be
- ## specified using a comma separator. If the first mail server fails, Monit
- # will use the second mail server in the list and so on. By default Monit uses
- # port 25 - it is possible to override this with the PORT option.
- #
- # set mailserver mail.bar.baz, # primary mailserver
- # backup.bar.baz port 10025, # backup mailserver on port 10025
- # localhost # fallback relay
- #
- #
- ## By default Monit will drop alert events if no mail servers are available.
- ## If you want to keep the alerts for later delivery retry, you can use the
- ## EVENTQUEUE statement. The base directory where undelivered alerts will be
- ## stored is specified by the BASEDIR option. You can limit the queue size
- ## by using the SLOTS option (if omitted, the queue is limited by space
- ## available in the back end filesystem).
- #
- set eventqueue
- basedir /var/lib/monit/events # set the base directory where events will be stored
- # slots 100 # optionally limit the queue size
- #
- #
- ## Send status and events to M/Monit (for more informations about M/Monit
- ## see http://mmonit.com/). By default Monit registers credentials with
- ## M/Monit so M/Monit can smoothly communicate back to Monit and you don't
- ## have to register Monit credentials manually in M/Monit. It is possible to
- ## disable credential registration using the commented out option below.
- ## Though, if safety is a concern we recommend instead using https when
- ## communicating with M/Monit and send credentials encrypted.
- #
- # set mmonit http://monit:monit@192.168.1.10:8080/collector
- # # and register without credentials # Don't register credentials
- #
- #
- ## Monit by default uses the following format for alerts if the the mail-format
- ## statement is missing::
- ## --8<--
- set mail-format {
- from: me@example.com
- subject: $HOST monit alert -- $EVENT $SERVICE
- message: $EVENT Service $SERVICE
- Date: $DATE
- Action: $ACTION
- Host: $HOST
- Description: $DESCRIPTION
- }
- ## --8<--
- ##
- ## You can override this message format or parts of it, such as subject
- ## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
- ## are expanded at runtime. For example, to override the sender, use:
- #
- # set mail-format { from: monit@foo.bar }
- #
- #
- ## You can set alert recipients whom will receive alerts if/when a
- ## service defined in this file has errors. Alerts may be restricted on
- ## events by using a filter as in the second example below.
- #
- # set alert sysadm@foo.bar # receive all alerts
- #
- ## Do not alert when Monit starts, stops or performs a user initiated action.
- ## This filter is recommended to avoid getting alerts for trivial cases.
- #
- set alert me@example.com not on { instance, action }
- #
- #
- ## Monit has an embedded HTTP interface which can be used to view status of
- ## services monitored and manage services from a web interface. The HTTP
- ## interface is also required if you want to issue Monit commands from the
- ## command line, such as 'monit status' or 'monit restart service' The reason
- ## for this is that the Monit client uses the HTTP interface to send these
- ## commands to a running Monit daemon. See the Monit Wiki if you want to
- ## enable SSL for the HTTP interface.
- #
- set httpd port 2812 and
- # use address localhost # only accept connection from localhost
- # allow localhost # allow localhost to connect to the server and
- # allow admin:monit # require user 'admin' with password 'monit'
- allow 0.0.0.0/0.0.0.0
- ###############################################################################
- ## Services
- ###############################################################################
- ##
- check process ssh_to_home matching "ssh -N -R"
- start program "/root/create_ssh_tunnel.sh"
- stop program /usr/bin/pkill -f "ssh -N -R"
- if failed host 192.168.88.25 port 2230 protocol ssh for 2 cycles then restart
- # if 5 restarts within 5 cycles then timeout
- check process sshd with pidfile /var/run/sshd.pid
- start program "/etc/init.d/ssh start" with timeout 60 seconds
- stop program "/etc/init.d/ssh stop"
- if failed port 22 protocol ssh then restart
- # if 5 restarts within 5 cycles then timeout
- check process openvpn with pidfile /var/run/openvpn.home1195.pid
- start program "/etc/init.d/openvpn start" with timeout 60 seconds
- stop program "/etc/init.d/openvpn stop"
- if failed host 192.168.6.1 port 80 for 2 cycles then restart
- check host 1_myself with address 192.168.0.1
- start program "/sbin/ifup eth1" with timeout 60 seconds
- stop program "/sbin/ifdown eth1" with timeout 60 seconds
- if 5 restarts within 10 cycles then timeout
- if failed ping with timeout 4 seconds then restart
- noalert me@example.com
- check host 2_home_server with address 192.168.88.25
- if failed ping timeout 4 seconds then alert
- noalert me@example.com
- depends on openvpn
- check host 3_laptop with address 192.168.0.100
- if failed ping timeout 4 seconds then alert
- noalert me@example.com
- check host 4_linux with address 192.168.0.99
- if failed ping timeout 4 seconds then alert
- noalert me@example.com
- check device RootFS with path /
- if space usage is greater than 95% for 5 cycles then alert
- check network tun0 with interface tun0
- if failed link then alert
- noalert me@example.com
- check process piControl matching "piControl"
- start program "/bin/bash -c '/usr/bin/python /usr/local/bin/piControl.py &'"
- stop program /usr/bin/pkill -f "piControl.py"
- # if 5 restarts within 5 cycles then timeout
- check process timeDate matching "timeDate"
- start program "/bin/bash -c '/usr/bin/python /usr/local/bin/timeDate.py &'"
- stop program /usr/bin/pkill -f "timeDate.py"
- # if 5 restarts within 5 cycles then timeout
- set mailserver smtp.example.com port 587
- username "me@example.com" password "example"
- using tlsv1 with timeout 120 seconds
- ###############################################################################
- ## Includes
- ###############################################################################
- ##
- ## It is possible to include additional configuration parts from other files or
- ## directories.
- #
- # include /etc/monit.d/*
- #
Add Comment
Please, Sign In to add comment