Nethence NEWDOC OLDDOC Lab Webmail Your IP BBDock  

setting up Monit agent-server

assuming your M/Monit instance is in place.

installation

on Unices

Either use the system’s package manager,

#debian/ubuntu
apt -y install monit

#EPEL
yum -y install monit

Or use the third-parity binaries directly,

TODO

on Windows

ChimeraEntertainment/monit-windows-agent https://github.com/ChimeraEntertainment/monit-windows-agent

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
hostname --long
#domainname

Check that the monit host resolves and responds,

host mmonitsrv.example.com
ping -c1 mmonitsrv.example.com

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

nmap -Pn -p 80,443 mmonitsrv.example.com

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

telnet <smarthost> 25
quit

Now setup the agent,

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

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

   #EPEL7
   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 http://monit:PASSWORD@mmonit.example.com/collector

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 hostmaster@example.com

set mail-format {
     from: hostmaster@example.com
  subject: monit alert --  $EVENT $SERVICE
  message: $EVENT Service $SERVICE

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

M/Monit https://mmonit.internal.example.com/
}

check process mongod with pidfile /var/run/mongodb/mongod.pid
    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,

#RHEL6,7
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

#Ubuntu
#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.

References

Tildeslash Monit https://bitbucket.org/tildeslash/monit/