Nethence NEWDOC OLDDOC Lab Webmail Your IP BBDock  

setting up Monit agent-server

assuming your M/Monit instance is in place.


on Unices

Either use the system’s package manager,

apt -y install monit

yum -y install monit

Or use the third-parity binaries directly,


on Windows


agent-server configuration

Check how many CPUs you have,

grep ^proc /proc/cpuinfo | wc -l

Check what network interface you are using,

ifconfig eth0
ifconfig bond0
#ifname=`ifconfig | grep ^[az] | egrep -v '^lo|virbr' | cut -f1 -d:`

Check your hostname,

hostname --long

Check that the monit host resolves and responds,

ping -c1

Check that the mmonit service is reachable, preferably on 443,

nmap -Pn -p 80,443

Check that your smtp relay responds and that email setup is in place.

telnet <smarthost> 25

Now setup the agent,

   cd /etc/monit/
   cp monitrc monitrc.dist
   vi monitrc

   cd /etc/
   cp monit.conf monit.conf.dist
   vi monit.conf

   cd /etc/
   cp monitrc monitrc.dist
   vi monitrc

note that cpu wait shows up by default, I like that so I comment out the custom check system,

set mmonit

check network public with interface eth0
        if failed link then alert
        if changed link then alert
        if saturation > 90% then alert
        if total upload > 10 GB in last hour then alert

#check system HOSTNAME
#       if loadavg (15min) > 4 then alert
#       if memory usage > 90% then alert
#       if swap usage > 5% then alert
#       if cpu usage (wait) > 10% then alert
#       group system_resources

set mailserver SMARTHOST, localhost
set alert

set mail-format {
  subject: monit alert --  $EVENT $SERVICE
  message: $EVENT Service $SERVICE

                Date:        $DATE
                Action:      $ACTION
                Host:        $HOST
                Description: $DESCRIPTION


check process mongod with pidfile /var/run/mongodb/
    if cpu > 60% for 2 cycles then alert
    #if totalmem > 1 GB for 5 cycles then restart
    if children > 250 then restart
    if loadavg(5min) greater than 10 for 8 cycles then alert
    group server

Ready to go

Start the daemon and enable it at boot time,

service monit restart
chkconfig monit on

#binaries on Debian
/usr/local/monit/bin/monit stop all
/usr/local/monit/bin/monit start all
vi /etc/rc.local
/usr/local/monit/bin/monit start all

#already started & enabled while pkg installation
#TODO service monit restart
#TODO update-rc.d monit defaults

You should now see the added host within the M/Monit interface.


Tildeslash Monit