r1: [svn-inject] Installing original source of monit-cn
authorDinko Korunic <Dinko.Korunic@CARNet.hr>
Wed, 3 Oct 2007 17:11:43 +0000 (17:11 +0000)
committerDinko Korunic <Dinko.Korunic@CARNet.hr>
Wed, 3 Oct 2007 17:11:43 +0000 (17:11 +0000)
25 files changed:
README.CARNet [new file with mode: 0644]
changelog.CARNet [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/install [new file with mode: 0644]
debian/postinst [new file with mode: 0755]
debian/postrm [new file with mode: 0755]
debian/rules [new file with mode: 0755]
monit-cn/amavisd.conf [new file with mode: 0644]
monit-cn/apache2.conf [new file with mode: 0644]
monit-cn/bind9.conf [new file with mode: 0644]
monit-cn/clamd.conf [new file with mode: 0644]
monit-cn/dhcpd3.conf [new file with mode: 0644]
monit-cn/dovecot.conf [new file with mode: 0644]
monit-cn/monitrc [new file with mode: 0644]
monit-cn/mysqld.conf [new file with mode: 0644]
monit-cn/openldap.conf [new file with mode: 0644]
monit-cn/postfix.conf [new file with mode: 0644]
monit-cn/sophie.conf [new file with mode: 0644]
monit-cn/thttpd.conf [new file with mode: 0644]
monit-cn/tomcat5.conf [new file with mode: 0644]
update-monit.d [new file with mode: 0755]

diff --git a/README.CARNet b/README.CARNet
new file mode 100644 (file)
index 0000000..2374e41
--- /dev/null
@@ -0,0 +1,8 @@
+monit-cn
+~~~~~~~~
+
+Ovaj paket donosi primjere konfiguracije za monit, instalaciju u inittab,
+kao i skriptu za detekciju aktivnih i radecih servisa koji se mogu pratiti
+kroz monit.
+
+ -- Dinko Korunic <kreator@carnet.hr> at  Mon, 24 Sep 2007 18:51:14 +0200
diff --git a/changelog.CARNet b/changelog.CARNet
new file mode 100644 (file)
index 0000000..5ca8c19
--- /dev/null
@@ -0,0 +1,6 @@
+monit-cn (1:4.5-1) stable; urgency=low
+
+  * inicijalni paket sa skriptama za detekciju aktivnih servisa i generiranje
+    monit.conf, itd.
+
+ -- Dinko Korunic <kreator@carnet.hr>  Mon, 24 Sep 2007 18:34:20 +0200
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..5ca8c19
--- /dev/null
@@ -0,0 +1,6 @@
+monit-cn (1:4.5-1) stable; urgency=low
+
+  * inicijalni paket sa skriptama za detekciju aktivnih servisa i generiranje
+    monit.conf, itd.
+
+ -- Dinko Korunic <kreator@carnet.hr>  Mon, 24 Sep 2007 18:34:20 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..b8626c4
--- /dev/null
@@ -0,0 +1 @@
+4
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..4d2bf95
--- /dev/null
@@ -0,0 +1,47 @@
+Source: monit-cn
+Section: net
+Priority: optional
+Maintainer: Dinko Korunic <kreator@carnet.hr>
+Build-Depends: debhelper (>= 4)
+Standards-Version: 3.7.2
+
+Package: monit-cn
+Architecture: all
+Depends: monit (>= 1:4.5-1), carnet-tools-cn (>= 2.1.8)
+Description: A utility for monitoring and managing daemons or similar programs
+ monit is a utility for monitoring and managing daemons or similar
+ programs running on a Unix system. It will start specified programs
+ if they are not running and restart programs not responding.
+ .
+ monit supports:
+  * Daemon mode - poll programs at a specified interval
+  * Monitoring modes - active, passive or manual
+  * Start, stop and restart of programs
+  * Group and manage groups of programs
+  * Process dependency definition
+  * Logging to syslog or own logfile
+  * Configuration - comprehensive controlfile
+  * Runtime and TCP/IP port checking (tcp and udp)
+  * SSL support for port checking
+  * Unix domain socket checking
+  * Process status and process timeout
+  * Process cpu usage
+  * Process memory usage
+  * Process zombie check
+  * Check the systems load average
+  * Check a file or directory timestamp
+  * Alert, stop or restart a process based on its characteristics
+  * MD5 checksum for programs started and stopped by monit
+  * Alert notification for program timeout, restart, checksum, stop
+    resource and timestamp error
+  * Flexible and customizable email alert messages
+  * Protocol verification. HTTP, FTP, SMTP, POP, IMAP, NNTP, SSH, DWP,
+    LDAPv2 and LDAPv3
+  * An http interface with optional SSL support to make monit
+    accessible from a webbrowser
+ .
+ This is the CARNet Debian customization package which brings
+ update-monit.d script (which will hopefully generate configuration based
+ on currently installed and running services which can be monitored with
+ monit), as well as automagical instalation as respawnable process in
+ inittab.
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..bad5308
--- /dev/null
@@ -0,0 +1,3 @@
+/etc/monit.d
+/usr/share/monit-cn
+/etc/monit
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..ef5ce6c
--- /dev/null
@@ -0,0 +1,2 @@
+changelog.CARNet
+README.CARNet
diff --git a/debian/install b/debian/install
new file mode 100644 (file)
index 0000000..102b8fd
--- /dev/null
@@ -0,0 +1,2 @@
+monit-cn /usr/share
+update-monit.d /usr/sbin
diff --git a/debian/postinst b/debian/postinst
new file mode 100755 (executable)
index 0000000..e387901
--- /dev/null
@@ -0,0 +1,86 @@
+#!/bin/sh
+# postinst script for bind9-cn
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+
+case "$1" in
+    configure|reconfigure)
+      # continue below
+    ;;
+
+    *)
+        exit 0
+    ;;
+esac
+
+# import CN-functions
+. /usr/share/carnet-tools/functions.sh
+
+# check if monitrc is an empty template
+installfile=1
+if [ -e /etc/monit/monitrc ]; then
+    lines=$(grep -v '^#' /etc/monit/monitrc | wc -l)
+    if [ $lines -lt 2 ]; then
+        installfile=1
+        mv -f /etc/monit/monitrc /etc/monit/monitrc.dpkg-old
+    else
+        installfile=0
+    fi
+fi
+if [ $installfile -eq 1 ]; then
+    echo "CN: Installing default monitrc in /etc/monit/monitrc"
+    cp -a /usr/share/monit-cn/monitrc /etc/monit/monitrc
+    chmod u=rw,go= /etc/monit/monitrc
+fi
+
+# generate monit.d files
+update-monit.d
+
+# disable monit startup
+cp_check_and_sed '^startup=1/#startup=1/g' /etc/default/monit \
+    || true
+
+# install as inittab service
+if ! grep -q '/usr/sbin/monit' /etc/inittab; then
+    if [ -x "/etc/init.d/monit" ]; then
+        update-rc.d -f monit remove >/dev/null 2>&1
+        if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+            invoke-rc.d monit stop || true
+        else
+            /etc/init.d/monit stop || true
+        fi
+    fi
+    echo "CN: Installing monit service in /etc/inittab"
+    rm -f /etc/inittab.$$
+    cp /etc/inittab /etc/inittab.$$
+    cp-update monit-cn /etc/inittab.$$ <<EOF
+mo:2345:respawn:/usr/sbin/monit -Ic /etc/monit/monitrc
+m0:06:wait:/usr/sbin/monit -Ic /etc/monit/monitrc stop myprocess
+EOF
+    cp_mv /etc/inittab.$$ /etc/inittab
+fi
+
+# reload init, since we have new configuration
+echo "CN: Starting monit service, please check /var/log/daemon.log"
+kill -HUP 1
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/postrm b/debian/postrm
new file mode 100755 (executable)
index 0000000..eb38a65
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# postrm script for bind9-cn
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+case "$1" in
+    purge)
+      # continue below
+    ;;
+
+    *)
+        exit 0
+    ;;
+esac
+
+# import CN-functions
+. /usr/share/carnet-tools/functions.sh
+
+# remove us from inittab
+echo "CN: Removing monit service from /etc/inittab"
+cp-update -r monit-cn /etc/inittab
+
+# kill monit
+echo "CN: Stopping monit service"
+pkill -9 -f /usr/sbin/monit
+
+# reload init
+kill -HUP 1
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..5c69e32
--- /dev/null
@@ -0,0 +1,74 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper. 
+# This file is public domain software, originally written by Joey Hess.
+#
+# This version is for packages that are architecture independent.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+build: build-stamp
+build-stamp:
+       dh_testdir
+
+       # Add here commands to compile the package.
+       #$(MAKE)
+
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp
+
+       # Add here commands to clean up after the build process.
+       #-$(MAKE) clean
+       #-$(MAKE) distclean
+
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       # Add here commands to install the package into debian/<packagename>.
+       #$(MAKE) prefix=`pwd`/debian/`dh_listpackages`/usr install
+
+# Build architecture-independent files here.
+binary-indep: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs
+       dh_installdocs
+       dh_install
+#      dh_installexamples
+#      dh_installmenu
+#      dh_installdebconf
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installcatalogs
+#      dh_installpam
+#      dh_installmime
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+#      dh_undocumented
+       dh_installman
+       dh_link
+       dh_compress
+       dh_fixperms
+#      dh_perl
+#      dh_python
+       dh_installdeb
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+# Build architecture-dependent files here.
+binary-arch: build install
+# We have nothing to do by default.
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/monit-cn/amavisd.conf b/monit-cn/amavisd.conf
new file mode 100644 (file)
index 0000000..5a96bad
--- /dev/null
@@ -0,0 +1,8 @@
+# amavisd monit-cn template
+
+check process amavisd with pidfile "/var/run/amavis/amavisd.pid"
+       group mail
+       start program = "/etc/init.d/amavis start"
+       stop program = "/etc/init.d/amavis stop"
+       if failed host 127.0.0.1 port 10024 protocol smtp
+               then restart
diff --git a/monit-cn/apache2.conf b/monit-cn/apache2.conf
new file mode 100644 (file)
index 0000000..c1acb35
--- /dev/null
@@ -0,0 +1,9 @@
+# apache2 monit-cn template
+
+check process apache2 with pidfile "/var/run/apache2.pid"
+       start program = "/etc/init.d/apache2 start"
+       stop program = "/etc/init.d/apache2 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/bind9.conf b/monit-cn/bind9.conf
new file mode 100644 (file)
index 0000000..40e57b3
--- /dev/null
@@ -0,0 +1,9 @@
+# bind9 monit-cn template
+
+check process bind with pidfile "/var/run/bind/run/named.pid"
+       start program = "/etc/init.d/bind9 start"
+       stop program = "/etc/init.d/bind9 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/clamd.conf b/monit-cn/clamd.conf
new file mode 100644 (file)
index 0000000..9c8708c
--- /dev/null
@@ -0,0 +1,8 @@
+# clamd monit-cn template
+
+check process clamd with pidfile "/var/run/clamav/clamd.pid"
+       group mail
+       start program = "/etc/init.d/clamav-daemon start"
+       stop program = "/etc/init.d/clamav-daemon stop"
+       if failed unixsocket "/var/run/clamav/clamd.ctl"
+               then restart
diff --git a/monit-cn/dhcpd3.conf b/monit-cn/dhcpd3.conf
new file mode 100644 (file)
index 0000000..5090e6f
--- /dev/null
@@ -0,0 +1,5 @@
+# dhcpd monit-cn template
+
+check process dhcpd with pidfile "/var/run/dhcpd.pid"
+       start program = "/etc/init.d/dhcp3-server start"
+       stop program = "/etc/init.d/dhcp3-server stop"
diff --git a/monit-cn/dovecot.conf b/monit-cn/dovecot.conf
new file mode 100644 (file)
index 0000000..d0a55a1
--- /dev/null
@@ -0,0 +1,10 @@
+# dovecot monit-cn template
+
+check process dovecot with pidfile "/var/run/dovecot/master.pid"
+       group mail
+       start program = "/etc/init.d/dovecot start"
+       stop program = "/etc/init.d/dovecot stop"
+       if failed host 127.0.0.1 port 143 protocol imap
+               then restart
+       if failed host 127.0.0.1 port 110 type tcp
+               then restart
diff --git a/monit-cn/monitrc b/monit-cn/monitrc
new file mode 100644 (file)
index 0000000..a49a0c9
--- /dev/null
@@ -0,0 +1,18 @@
+# monit-cn template
+
+set daemon 300
+set logfile syslog facility log_daemon
+
+set mail-format {
+    from: monit@localhost
+    subject: $SERVICE $EVENT at $DATE
+    message: monit $ACTION $SERVICE at $DATE on $HOST
+    }
+set mailserver 127.0.0.1
+set alert root@localhost
+
+#set httpd port 2812 and use address 127.0.0.1
+#allow localhost
+#allow admin:monit
+
+include /etc/monit.d/*conf
diff --git a/monit-cn/mysqld.conf b/monit-cn/mysqld.conf
new file mode 100644 (file)
index 0000000..857f4d9
--- /dev/null
@@ -0,0 +1,8 @@
+# mysql monit-cn template
+
+check process mysql with pidfile "/var/run/mysqld/mysqld.pid"
+       start program = "/etc/init.d/mysql start"
+       stop program = "/etc/init.d/mysql stop"
+       if failed host 127.0.0.1 port 3306 protocol mysql
+               with timeout 10 seconds
+               then restart
diff --git a/monit-cn/openldap.conf b/monit-cn/openldap.conf
new file mode 100644 (file)
index 0000000..32cf02f
--- /dev/null
@@ -0,0 +1,9 @@
+# openldap monit-cn template
+
+check process openldap with pidfile "/var/run/slapd/slapd.pid"
+       start program = "/etc/init.d/slapd start"
+       stop program = "/etc/init.d/slapd stop"
+       if failed host 127.0.0.1 port 389 protocol ldap3
+               with timeout 10 seconds
+               then restart
+       if 5 restarts within 5 cycles then timeout
diff --git a/monit-cn/postfix.conf b/monit-cn/postfix.conf
new file mode 100644 (file)
index 0000000..6a36dff
--- /dev/null
@@ -0,0 +1,8 @@
+# postfix monit-cn template
+
+check process postfix with pidfile "/var/spool/postfix/pid/master.pid"
+       group mail
+       start program = "/etc/init.d/postfix start"
+       stop program = "/etc/init.d/postfix stop"
+       if failed host 127.0.0.1 port 25 protocol smtp
+               then restart
diff --git a/monit-cn/sophie.conf b/monit-cn/sophie.conf
new file mode 100644 (file)
index 0000000..d3f2a8a
--- /dev/null
@@ -0,0 +1,8 @@
+# sophie monit-cn template
+
+check process sophie with pidfile "/var/run/sophie/pid"
+       group mail
+       start program = "/etc/init.d/sophie start"
+       stop program = "/etc/init.d/sophie stop"
+       if failed unixsocket "/var/run/sophie/sock"
+               then restart
diff --git a/monit-cn/thttpd.conf b/monit-cn/thttpd.conf
new file mode 100644 (file)
index 0000000..7f5d98d
--- /dev/null
@@ -0,0 +1,9 @@
+# thttpd monit-cn template
+
+check process thttpd with pidfile "/var/run/thttpd.pid"
+       start program = "/etc/init.d/thttpd start"
+       stop program = "/etc/init.d/thttpd stop"
+       if failed host 127.0.0.1 port 80
+               with timeout 15 seconds
+               then restart
+       if children > 100 then restart
diff --git a/monit-cn/tomcat5.conf b/monit-cn/tomcat5.conf
new file mode 100644 (file)
index 0000000..ac125b2
--- /dev/null
@@ -0,0 +1,10 @@
+# tomcat5 monit-cn template
+
+check process tomcat5 with pidfile "/usr/share/tomcat5/temp/tomcat5.pid"
+       start program = "/etc/init.d/tomcat5 start"
+       stop program = "/etc/init.d/tomcat5 stop"
+       if failed host 127.0.0.1 port 8081 protocol http
+               with timeout 15 seconds
+               then restart
+       if children > 250 then restart
+
diff --git a/update-monit.d b/update-monit.d
new file mode 100755 (executable)
index 0000000..72e55c5
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+MONIT_DIR=/etc/monit.d
+TEMPLATES_DIR=/usr/share/monit-cn
+
+check_service() {
+    RET=0
+
+    filename="$1"
+    if [ ! -r "$filename" ]; then
+        RET=1
+        return 1
+    fi
+
+    script='BEGIN { RS = "[ \t\n]+" }
+               { line[NR] = $0 "" }
+         END { for (j in line)
+                if (line[j] == "pidfile")
+                    print line[j + 1] }'
+    pidfiles=$(awk "$script" < "$filename" | sed -e 's/"//g')
+    check_pidfile $pidfiles
+    return $RET
+}
+
+check_pidfile() {
+    RET=0
+
+    while [ -n "$1" ]; do
+        if [ -r "$1" ]; then
+            check_pid $(cat "$1")
+            if [ $RET -eq 1 ]; then
+                return 1
+            fi
+        else
+            RET=1
+            return 1
+        fi
+        shift
+    done
+
+    return 0
+}
+
+check_pid() {
+    RET=0
+
+    while [ -n "$1" ]; do
+        if ! kill -0 "$1" >/dev/null 2>&1; then
+            RET=1
+            return 1
+        fi
+        shift
+    done
+
+    return 0
+}
+
+
+if [ ! -d "$MONIT_DIR" ]; then
+    mkdir -p "$MONIT_DIR"
+else
+    for i in $(find "$MONIT_DIR" -name '*.conf'); do
+        check_service $i
+        if [ ! $RET -eq 0 ]; then
+            serviceconf=$(basename $i)
+            echo "CN: Disabled $serviceconf"
+            mv -f $i $i.disabled
+        fi
+    done
+fi
+
+for i in $(find "$TEMPLATES_DIR" -name '*.conf'); do
+    check_service $i
+    if [ $RET -eq 0 ]; then
+        serviceconf=$(basename $i)
+        if [ ! -r "$MONIT_DIR"/$serviceconf ]; then
+            echo "CN: Enabled $serviceconf"
+            cp -a $i "$MONIT_DIR"
+        fi
+    fi
+done