#!/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
# 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
fi
checkconfig() {
- res=`/usr/sbin/nagios -v /etc/nagios/nagios.cfg`
+ /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"' $0
+ nls 'The configuration is broken. See details with %s "checkconfig"' /etc/rc.d/init.d/nagios
fi
return $rc
}
-RETVAL=0
-# See how we were called.
-case "$1" in
-start)
+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)
touch /var/lock/subsys/nagios
fi
else
- msg_already_running nagios
+ msg_already_running Nagios
fi
- ;;
-stop)
+}
+
+stop() {
# Stop daemons.
if [ -f /var/lock/subsys/nagios ]; then
- msg_stopping nagios
+ msg_stopping Nagios
killproc nagios -TERM
rm -f /var/lock/subsys/nagios > /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
- exit $?
+stop)
+ stop
;;
-checkconfig|check)
+checkconfig|check|configtest)
/usr/sbin/nagios -v /etc/nagios/nagios.cfg
exit $?
;;
reload|force-reload)
if [ -f /var/lock/subsys/nagios ]; then
- msg_reloading nagios
+ msg_reloading Nagios
checkconfig || exit
killproc nagios -HUP
RETVAL=$?
else
- msg_not_running nagios >&2
+ msg_not_running Nagios
exit 7
fi
;;
restart)
- msg_reloading nagios
+ msg_reloading Nagios
checkconfig || exit && started
- $0 stop
- $0 start
+ stop
+ start
+ ;;
+status)
+ status nagios
exit $?
;;
*)