Solved Monit and spamass-milter

I have installed and configured sysutils/monit on my server and it is working great will all daemons except one. When configuring the config file to monitor a daemon you use the following:

Code:
check process ntpd with pidfile /var/run/ntpd.pid
  start program = "/etc/rc.d/ntpd start"
  stop program = "/etc/rc.d/ntpd stop"
if failed host 127.0.0.1 port 123 type udp then alert

As you can see it uses a pid file as part of the check process.

I want to monitor mail/spamass-milter but this uses a .sock file rather. I have tried the following unsuccessfully:

Code:
check file spamass-milter with path /var/run/spamass-milter/spamass-milter.sock
  start program = "/usr/local/etc/rc.d/spamass-milter start"
  stop program = "/usr/local/etc/rc.d/spamass-milter stop"
  if failed unixsocket /var/run/spamass-milter/spamass-milter.sock then restart
  if 3 restarts within 5 cycles then timeout

But this didn't work. Does anyone know how I can monitor a daemon that uses a .sock file with monit?

Thanks.
 
Just remove the whole "with .... " from the line. And use "check process". This will look for the process in the process list. By adding "with pidfile ..." you tell it to specifically look for a process with a PID that's in the file.
 
Just remove the whole "with .... " from the line. And use "check process". This will look for the process in the process list. By adding "with pidfile ..." you tell it to specifically look for a process with a PID that's in the file.

Thanks!

I have tried:

Code:
check process spamass-milter
  start program = "/usr/local/etc/rc.d/spamass-milter start"
  stop program = "/usr/local/etc/rc.d/spamass-milter stop"
  if failed unixsocket /var/run/spamass-milter/spamass-milter.sock then restart
  if 3 restarts within 5 cycles then timeout

but it keeps giving me a sytax error:

Code:
/usr/local/etc/monitrc:376: syntax error 'start program = "'

And I'm not sure why!
 
This seems to work:

Code:
check process spamass-milter
  matching "spamass-milter"
  start program = "/usr/local/etc/rc.d/spamass-milter start"
  stop program = "/usr/local/etc/rc.d/spamass-milter stop"
  if failed unixsocket /var/run/spamass-milter/spamass-milter.sock then restart
  if 3 restarts within 5 cycles then timeout

Thanks for the help!
 
Nice job tracking it down. Reading monit(1), it seems the case is either the pidfile argument or matching argument is required.
1. CHECK PROCESS <unique name> <PIDFILE <path> | MATCHING <regex>>
<path> is the absolute path to the program's pidfile. If the pidfile does not exist or does not contain the pid number of a running process, Monit will call the entry's start method if defined. <regex> is alternative process specification using pattern matching to process name (command line) from process table instead of pidfile. The first match is used so this form of check is useful for unique pattern matching - the pidfile should be used where possible as it defines expected pid exactly (pattern matching won't be useful for Apache in most cases or for processes which start child processes using fork/clone as the child will match the same pattern temporarily).
 
Back
Top