From 0ecee20a438cb6e283c728dfa7d7a9b54a8c4ade Mon Sep 17 00:00:00 2001 From: Dinko Korunic Date: Wed, 3 Oct 2007 18:08:25 +0000 Subject: [PATCH] r3: - new conffiles - don't restart if there was no change in conffiles/status --- monit-cn/apache1.conf | 9 +++++++++ monit-cn/bind8.conf | 9 +++++++++ monit-cn/cron.conf | 6 ++++++ monit-cn/exim.conf | 8 ++++++++ monit-cn/ntpd.conf | 5 +++++ monit-cn/proftpd.conf | 5 +++++ monit-cn/qpopper.conf | 8 ++++++++ monit-cn/samba.conf | 11 +++++++++++ monit-cn/sendmail.conf | 8 ++++++++ monit-cn/sshd.conf | 8 ++++++++ monit-cn/syslogd.conf | 5 +++++ update-monit.d | 10 ++++++++-- 12 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 monit-cn/apache1.conf create mode 100644 monit-cn/bind8.conf create mode 100644 monit-cn/cron.conf create mode 100644 monit-cn/exim.conf create mode 100644 monit-cn/ntpd.conf create mode 100644 monit-cn/proftpd.conf create mode 100644 monit-cn/qpopper.conf create mode 100644 monit-cn/samba.conf create mode 100644 monit-cn/sendmail.conf create mode 100644 monit-cn/sshd.conf create mode 100644 monit-cn/syslogd.conf diff --git a/monit-cn/apache1.conf b/monit-cn/apache1.conf new file mode 100644 index 0000000..f2902d6 --- /dev/null +++ b/monit-cn/apache1.conf @@ -0,0 +1,9 @@ +# 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 diff --git a/monit-cn/bind8.conf b/monit-cn/bind8.conf new file mode 100644 index 0000000..f324f53 --- /dev/null +++ b/monit-cn/bind8.conf @@ -0,0 +1,9 @@ +# 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 diff --git a/monit-cn/cron.conf b/monit-cn/cron.conf new file mode 100644 index 0000000..56753f2 --- /dev/null +++ b/monit-cn/cron.conf @@ -0,0 +1,6 @@ +# 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" diff --git a/monit-cn/exim.conf b/monit-cn/exim.conf new file mode 100644 index 0000000..35f256a --- /dev/null +++ b/monit-cn/exim.conf @@ -0,0 +1,8 @@ +# 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 diff --git a/monit-cn/ntpd.conf b/monit-cn/ntpd.conf new file mode 100644 index 0000000..48f4c25 --- /dev/null +++ b/monit-cn/ntpd.conf @@ -0,0 +1,5 @@ +# 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" diff --git a/monit-cn/proftpd.conf b/monit-cn/proftpd.conf new file mode 100644 index 0000000..d71f454 --- /dev/null +++ b/monit-cn/proftpd.conf @@ -0,0 +1,5 @@ +# 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" diff --git a/monit-cn/qpopper.conf b/monit-cn/qpopper.conf new file mode 100644 index 0000000..297df59 --- /dev/null +++ b/monit-cn/qpopper.conf @@ -0,0 +1,8 @@ +# 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 diff --git a/monit-cn/samba.conf b/monit-cn/samba.conf new file mode 100644 index 0000000..9582278 --- /dev/null +++ b/monit-cn/samba.conf @@ -0,0 +1,11 @@ +# 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" diff --git a/monit-cn/sendmail.conf b/monit-cn/sendmail.conf new file mode 100644 index 0000000..5e8a186 --- /dev/null +++ b/monit-cn/sendmail.conf @@ -0,0 +1,8 @@ +# 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 diff --git a/monit-cn/sshd.conf b/monit-cn/sshd.conf new file mode 100644 index 0000000..8ce1fe4 --- /dev/null +++ b/monit-cn/sshd.conf @@ -0,0 +1,8 @@ +# 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 diff --git a/monit-cn/syslogd.conf b/monit-cn/syslogd.conf new file mode 100644 index 0000000..5e368f4 --- /dev/null +++ b/monit-cn/syslogd.conf @@ -0,0 +1,5 @@ +# 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" diff --git a/update-monit.d b/update-monit.d index 0a1443f..0e06932 100755 --- a/update-monit.d +++ b/update-monit.d @@ -55,7 +55,9 @@ check_pid() { return 0 } +##################################################################### +changed=0 if [ ! -d "$MONIT_DIR" ]; then mkdir -p "$MONIT_DIR" else @@ -65,6 +67,7 @@ else serviceconf=$(basename $i) echo "CN: Disabled $serviceconf" mv -f $i $i.disabled + changed=1 fi done fi @@ -76,11 +79,14 @@ for i in $(find "$TEMPLATES_DIR" -name '*.conf'); do 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 -- 1.7.10.4