###############################################################################
## 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, 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 240  # optional: delay the first check by 4-minutes
#                           # (by default 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 stand alone log file instead, specify the path to a log file
#
set logfile syslog facility log_daemon                       
#
#
### Set the location of monit id file which saves the unique id specific for
### given monit. 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 the location of monit state file which saves the monitoring state
### on each cycle. By default the file is placed in $HOME/.monit.state. If
### state file is stored on persistent filesystem, monit will recover the
### monitoring state across reboots. If it is on temporary filesystem, the
### state will be lost on reboot.
#
set statefile /var/.monit.state
#
## Set the list of mail servers for alert delivery. Multiple servers may be 
## specified using comma separator. By default monit uses port 25 - this
## is possible to override with the PORT option.
#
# set mailserver mail.bar.baz,               # primary mailserver
 set mailserver mail.domain.com
 set mailserver mail2.domain.com

#                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 a 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 maximal queue
## size using the SLOTS option (if omitted, the queue is limited by space 
## available in the back end filesystem).
#
# set eventqueue
#     basedir /var/monit  # set the base directory where events will be stored
#     slots 100           # optionaly limit the queue size
#
#
## Send status and events to M/Monit (Monit central management: for more
## informations about M/Monit see http://www.tildeslash.com/mmonit).
#
# set mmonit http://monit:monit@192.168.1.10:8080/collector
#
#
set mail-format {
                  from: monitoring@domain.com
                  subject: $HOST -- $SERVICE $EVENT at $DATE
                  message: Monit $ACTION for $SERVICE at $DATE

                Host: $HOST
                Description: $DESCRIPTION

                Simplehost monitoring
                monitoring@domain.com
                }
#
## Send alert to system admin on any event
set alert monitoring@domain.com

#
#
###############################################################################
## Services
###############################################################################
##
#
check process apache2 with pidfile /var/run/apache2.pid
group www
start program = "/etc/init.d/apache2 start"
stop program  = "/etc/init.d/apache2 stop"
# Admin will notify by mail if below of the condition satisfied.
if failed host www.domain.com port 80 protocol http and request "/monit/token" then restart
if cpu is greater than 60% for 6 cycles then alert
if cpu > 80% for 5 cycles then restart
#if totalmem > 200.0 for 5 cycles then restart
if children > 240 then alert
if loadavg(5min) greater than 15 for 8 cycles then restart
if 2 restarts within 5 cycles then timeout
group server

# monit will only monit/give alert in this mode.

check device home with path /dev/md1
        if space usage > 85% then alert
        alert monitoring@domain.com with mail-format {
                from: monitoring@domain.com
                subject: [SEVERITY 1 ALERT] $HOST -- $SERVICE $EVENT at $DATE
                message: Monit $ACTION for $SERVICE at $DATE

                /home is has exceeded 85% usage!
                check /home with du -sh and remove necessary files!

                Host: $HOST
                Description: $DESCRIPTION

                Simplehost monitoring
                monitoring@domain.com
                }
alert monitoring@domain.com with reminder on 20 cycles

check device var with path /dev/md4
        if space usage > 85% then alert
        alert monitoring@domain.com with mail-format {
                from: monitoring@domain.com
                subject: [SEVERITY 1 ALERT] $HOST -- $SERVICE $EVENT at $DATE
                message: Monit $ACTION for $SERVICE at $DATE

                /var is has exceeded 85% usage!
                check /var with du -sh and remove necessary files!

                Host: $HOST
                Description: $DESCRIPTION

                Simplehost monitoring
                monitoring@domain.com
                }
alert monitoring@domain.com with reminder on 20 cycles

check device root with path /dev/md0
        if space usage > 85% then alert
        alert monitoring@domain.com with mail-format {
              from: monitoring@domain.com
              subject: [SEVERITY 1 ALERT] $HOST -- $SERVICE $EVENT at $DATE
              message: Monit $ACTION for $SERVICE at $DATE

              / is has exceeded 85% usage!
              check / with du -sh and remove necessary files!

              Host: $HOST
              Description: $DESCRIPTION

              Simplehost monitoring
              monitoring@domain.com
             }
alert monitoring@domain.com with reminder on 20 cycles

check device usr with path /dev/md3
        if space usage > 90% then alert
        alert monitoring@domain.com with mail-format {
              from: monitoring@domain.com
              subject: [SEVERITY 1 ALERT] $HOST -- $SERVICE $EVENT at $DATE
              message: Monit $ACTION for $SERVICE at $DATE

              /usr is has exceeded 90% usage!
              check /usr with du -sh and remove necessary files!

              Host: $HOST
              Description: $DESCRIPTION

              Simplehost monitoring
              monitoring@domain.com
             }
alert monitoring@domain.com with reminder on 20 cycles

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 4 seconds then alert
if failed port 80 protocol http then alert

## for monitoring of net connection

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 3 seconds then alert

check host [ip-removed] with address [ip-removed]
if failed icmp type echo with timeout 3 seconds then alert

check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mail
start program = "/etc/init.d/postfix start"
stop  program = "/etc/init.d/postfix stop"
if failed host [ip-removed] port 25 protocol smtp for 2 cycles then restart
if failed host [ip-removed] port 25 protocol smtp for 2 cycles then alert
if failed host [ip-removed] port 25 protocol smtp for 2 cycles then alert
if 2 restarts within 5 cycles then timeout

check process bind with pidfile /var/lib/named/var/run/bind/run/named.pid
#check process bind with pidfile /var/run/bind/run/named.pid
   start program = "/etc/init.d/bind9 start"
   stop program = "/etc/init.d/bind9 stop"
   if failed host [ip-removed] port 53 type tcp for 2 cycles then restart
   if failed host [ip-removed] port 53 type tcp for 2 cycles then alert
   if failed host [ip-removed] port 53 type tcp for 2 cycles then alert
   if 2 restarts within 5 cycles then timeout

check process vsftpd with pidfile /var/run/vsftpd/vsftpd.pid
   start program = "/etc/init.d/vsftpd start"
   stop program  = "/etc/init.d/vsftpd stop"
   if failed host [ip-removed] port 21 protocol ftp then restart
   if 2 restarts within 5 cycles then timeout

check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/ssh start"
   stop program  "/etc/init.d/ssh stop"
   if failed host [ip-removed] port 22 protocol ssh for 2 cycles then restart
   if 2 restarts within 5 cycles then timeout

 check process mysqld with pidfile /var/run/mysqld/mysqld.pid
 start program  "/etc/init.d/mysql start"
 stop program  "/etc/init.d/mysql stop"
 if failed host 127.0.0.1 port 3306 then restart
 if 2 restarts within 5 cycles then timeout

#
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
#  include /etc/monit.d/*
#
#