From Segfault
Jump to navigation Jump to search

When a full-blown Naemon installation is to exhaustive, we could employ Monit to do the job. Example configuration:

$ cat /etc/monitrc 
set daemon  30              # check services at 30 seconds intervals
   with start delay 60      # optional: delay the first check by one minute

set log syslog
set mailserver port 25
set alert

include /etc/monit.d/*

Let's test for a specific network connection and act on it if it's not available:

$ cat /etc/monit.d/autossh 
check process autossh with pidfile /tmp/
  start program = "/usr/local/sbin/ start foobar"
  stop program  = "/usr/local/sbin/ stop foobar"
  if changed pid then alert
  if failed host localhost port 25 protocol smtp with timeout 30 seconds then alert
  if 3 restarts within 5 cycles then timeout

More examples can be found in the Monit wiki.