Monitor Salt with Monit

December 16, 2014   

Sometimes salt has the tendency to crash. So we can use monit to fix that problem

This assumes you already have the EPEL repo installed

yum install monit

Now with monit installed we can edit the following config


With the following contents

set daemon 5
  with start delay 5
set logfile /var/log/monit.log
set idfile /var/lib/
set statefile /var/run/monit.state
set mailserver
  localhost port 25
  with timeout 30 seconds
set mail-format {
   subject: $SERVICE $EVENT at $DATE
   message:     Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
    Yours sincerely,

set alert
  only on { nonexist, timeout, resource, icmp, connection}
set eventqueue
  basedir /var/tmp
  slots 100
set httpd port 2812 and
  use address
  allow localhost
include /etc/monit.d/*.conf

Make sure to change the use address so it won’t mind to all ips or just se the allow subnet/mask to a valid one.

Then edit the following file


It will look like this

check process salt
  with pidfile /var/run/
  group system
  start "/etc/init.d/salt-minion start"
  stop "/etc/init.d/salt-minion stop"
  if 3 restarts within 5 cycles
    then unmonitor

That should check if salt is up and running.

You can use this process for almost any process that sets a local pid to check.

comments powered by Disqus