X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=nagios.init;h=f8094c09c120136e0d058ea172094eecd077f4d3;hb=66b4f57f83cb6ea1c3e5297c1631ac15dd7a113c;hp=1bc1b5371cbe43abab2d65dcc9880bb6c883dcce;hpb=9405ddf79f3f570d3af1d2b8dd6c4c1a84c3baa9;p=packages%2Fnagios.git diff --git a/nagios.init b/nagios.init index 1bc1b53..f8094c0 100644 --- a/nagios.init +++ b/nagios.init @@ -1,6 +1,6 @@ #!/bin/sh # -# nagios Host/service/network monitoring daemon +# Nagios Host/service/network monitoring daemon # # chkconfig: 345 85 24 # description: Host/service/network monitoring daemon which uses snort as NIDS @@ -18,53 +18,89 @@ # Check that networking is up. if is_yes "${NETWORKING}"; then if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then - msg_network_down nagios + msg_network_down Nagios exit 1 fi else exit 0 fi -RETVAL=0 -# See how we were called. -case "$1" in - start) +checkconfig() { + /usr/sbin/nagios -v /etc/nagios/nagios.cfg > /dev/null + rc=$? + if [ $rc -gt 0 ]; then + fail + nls 'The configuration is broken. See details with %s "checkconfig"' /etc/rc.d/init.d/nagios + fi + return $rc +} + +start() { # Check if the service is already running? if [ ! -f /var/lock/subsys/nagios ]; then - msg_starting nagios + msg_starting Nagios + checkconfig || exit + # remove stale cmd pipe (or nagios won't start if it exists) rm -f /var/lib/nagios/rw/nagios.cmd daemon /usr/sbin/nagios -d /etc/nagios/nagios.cfg /dev/null 2>&1 else - msg_not_running nagios + msg_not_running Nagios fi +} + +RETVAL=0 +# See how we were called. +case "$1" in +start) + start ;; - status) - status nagios +stop) + stop + ;; +checkconfig|check|configtest) + /usr/sbin/nagios -v /etc/nagios/nagios.cfg exit $? ;; - restart|force-reload) - $0 stop - $0 start +reload|force-reload) + if [ -f /var/lock/subsys/nagios ]; then + msg_reloading Nagios + checkconfig || exit + + killproc nagios -HUP + RETVAL=$? + else + msg_not_running Nagios + exit 7 + fi + ;; +restart) + msg_reloading Nagios + checkconfig || exit && started + stop + start + ;; +status) + status nagios exit $? ;; - *) - msg_usage "$0 {start|stop|restart|force-reload|status}" +*) + msg_usage "$0 {start|stop|restart|reload|force-reload|status|checkconfig}" exit 3 esac