--- /dev/null
+# apache monit-cn template
+
+check process apache with pidfile "/var/run/apache.pid"
+ start program = "/etc/init.d/apache start"
+ stop program = "/etc/init.d/apache stop"
+ if failed host 127.0.0.1 port 80 protocol http
+ with timeout 15 seconds
+ then restart
+ if children > 250 then restart
--- /dev/null
+# bind8 monit-cn template
+
+check process bind with pidfile "/var/run/named.pid"
+ start program = "/etc/init.d/bind start"
+ stop program = "/etc/init.d/bind stop"
+ if failed host 127.0.0.1 port 53 type tcp
+ then restart
+ if failed host 127.0.0.1 port 53 type udp
+ then restart
--- /dev/null
+# crond monit-cn template
+
+check process cron with pidfile "/var/run/cron.pid"
+ group system
+ start program = "/etc/init.d/cron start"
+ stop program = "/etc/init.d/cron stop"
--- /dev/null
+# exim monit-cn template
+
+check process exim4 with pidfile "/var/run/exim4/exim.pid"
+ group mail
+ start program = "/etc/init.d/exim4 start"
+ stop program = "/etc/init.d/exim4 stop"
+ if failed host 127.0.0.1 port 25 protocol smtp
+ then restart
--- /dev/null
+# ntp monit-cn template
+
+check process ntpd with pidfile "/var/run/ntpd.pid"
+ start program = "/etc/init.d/ntpd start"
+ stop program = "/etc/init.d/ntpd stop"
--- /dev/null
+# proftpd monit-cn template
+
+check process proftpd with pidfile "/var/run/proftpd.pid"
+ start program = "/etc/init.d/proftpd start"
+ stop program = "/etc/init.d/proftpd stop"
--- /dev/null
+# qpopper monit-cn template
+
+check process qpopper with pidfile "/var/run/popper.pid"
+ group mail
+ start program = "/etc/init.d/qpopper start"
+ stop program = "/etc/init.d/qpopper stop"
+ if failed host 127.0.0.1 port 110 type tcp
+ then restart
--- /dev/null
+# samba monit-cn template
+
+check process smbd with pidfile "/var/run/samba/smbd.pid"
+ group system
+ start program = "/etc/init.d/samba start"
+ stop program = "/etc/init.d/samba stop"
+
+check process nmbd with pidfile "/var/run/samba/nmbd.pid"
+ group system
+ start program = "/etc/init.d/samba start"
+ stop program = "/etc/init.d/samba stop"
--- /dev/null
+# sendmail monit-cn template
+
+check process sendmail with pidfile "/var/run/sendmail.pid"
+ group mail
+ start program = "/etc/init.d/sendmail start"
+ stop program = "/etc/init.d/sendmail stop"
+ if failed host 127.0.0.1 port 25 protocol smtp
+ then restart
--- /dev/null
+# sshd monit-cn template
+
+check process sshd with pidfile "/var/run/sshd.pid"
+ start program "/etc/init.d/ssh start"
+ stop program "/etc/init.d/ssh stop"
+ if failed host 127.0.0.1 port 22 protocol ssh
+ with timeout 15 seconds
+ then restart
--- /dev/null
+# syslogd monit-cn template
+
+check process syslogd with pidfile "/var/run/syslogd.pid"
+ start program = "/etc/init.d/sysklogd start"
+ stop program = "/etc/init.d/sysklogd stop"
return 0
}
+#####################################################################
+changed=0
if [ ! -d "$MONIT_DIR" ]; then
mkdir -p "$MONIT_DIR"
else
serviceconf=$(basename $i)
echo "CN: Disabled $serviceconf"
mv -f $i $i.disabled
+ changed=1
fi
done
fi
if [ ! -r "$MONIT_DIR"/$serviceconf ]; then
echo "CN: Enabled $serviceconf"
cp -a $i "$MONIT_DIR"
+ changed=1
fi
fi
done
-echo "CN: Stopping/restarting monit service"
-pkill -9 -f /usr/sbin/monit || true
+if [ $changed -eq 1 ]; then
+ echo "CN: Stopping/restarting monit service"
+ pkill -9 -f /usr/sbin/monit || true
+fi
exit 0