Monit - System Monitoring

Written by Simone

I'm going to paste my working Monit configuration file for anyone attempting to make it work under Debian

  set daemon  120
  set log /var/log/monit.log
  set idfile /var/lib/monit/id
  set statefile /var/lib/monit/state

set ssl {
     verify     : enable
 }

  SET MAILSERVER
        pandora.woodpeckersnest.space
        PORT 465
        USERNAME <username> PASSWORD <password>
        using SSL

  set eventqueue
     basedir /var/lib/monit/events
     slots 100

  set alert <username>@woodpeckersnest.space not on { instance }

  set httpd port 2812 and
   use address 0.0.0.0
   allow 0.0.0.0/0.0.0.0
   allow admin:<password>
   with ssl {
         pemchain: /etc/monit/fullchain.pem
         pemkey: /etc/monit/privkey.pem
        }

  check system PANDORA
    if cpu usage > 95% for 10 cycles then alert
    if memory usage > 85% then alert
    if swap usage > 50% then alert

  check network ens3 with interface ens3
    if link down then alert
    if changed link then alert
    if saturation > 90% then alert

  check filesystem rootfs with path /
    if space usage > 80% then alert
    if space usage > 85% then alert
    if space usage > 90% then alert
    if space usage > 95% then alert

  check host pandora.spacenest.it with address 94.143.138.27
    if failed ping then alert
    if failed port 22 protocol ssh
    then alert

Then there are files under /etc/monit/conf.d/* and/or /etc/monit/conf-enabled/*. I only have 3:

nginx:

 check process nginx with pidfile /var/run/nginx.pid
   group www-data
   start program = "/etc/init.d/nginx start"
   stop program = "/etc/init.d/nginx stop"

postfix:

 check process postfix with pidfile /var/spool/postfix/pid/master.pid
     start program = "/etc/init.d/postfix start"
     stop  program = "/etc/init.d/postfix stop"
     if failed
        port 25
        protocol smtps
        username "<your_username>"
        password "<your_password>"
     then alert

sshd:

 check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/sshd start"
   stop program  "/etc/init.d/sshd stop"
   if failed port 22 protocol ssh then restart

Monit manual is very helpful, you should check it out.

Comments

  1. blog.woodpeckersnest.space:

    Mentioned this post.

  2. Markdown is allowed. HTML is not allowed.