3 # Nagios Host/service/network monitoring daemon
6 # description: Host/service/network monitoring daemon which uses snort as NIDS
9 # Source function library
10 . /etc/rc.d/init.d/functions
13 . /etc/sysconfig/network
16 [ -f /etc/sysconfig/nagios ] && . /etc/sysconfig/nagios
18 # Check that networking is up.
19 if is_yes "${NETWORKING}"; then
20 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
21 msg_network_down "Nagios"
30 /usr/sbin/nagios -v /etc/nagios/nagios.cfg 2>&1
34 # wrapper for configtest:
38 if [ $details = 1 ]; then
39 # run config test and display report (status action)
40 show "Checking %s configuration" "Nagios"; busy
44 if [ $RETVAL = 0 ]; then
49 [ "$out" ] && echo >&2 "$out"
51 # run config test and abort with nice message if failed
52 # (for actions checking status before action).
53 configtest >/dev/null 2>&1
55 if [ $RETVAL != 0 ]; then
56 show "Checking %s configuration" "Nagios"; fail
57 nls 'Configuration test failed. See details with %s "checkconfig"' $0
64 # Check if the service is already running?
65 if [ -f /var/lock/subsys/nagios ]; then
66 msg_already_running "Nagios"
73 # remove stale cmd pipe (or nagios won't start if it exists)
74 rm -f /var/lib/nagios/rw/nagios.cmd
75 daemon /usr/sbin/nagios -d /etc/nagios/nagios.cfg </dev/null
77 if [ $RETVAL -eq 0 ]; then
78 touch /var/lock/subsys/nagios
84 if [ ! -f /var/lock/subsys/nagios ]; then
85 msg_not_running "Nagios"
91 rm -f /var/lock/subsys/nagios > /dev/null 2>&1
95 if [ ! -f /var/lock/subsys/nagios ]; then
96 msg_not_running "Nagios"
102 msg_reloading "Nagios"
109 if [ ! -f /var/lock/subsys/nagios ]; then
110 msg_not_running "Nagios"
121 # See how we were called.
140 checkconfig|configtest)
148 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"