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"
28 cfg_file=/etc/nagios/nagios.cfg
31 precached_object_file=$(awk -F= '/^precached_object_file/{print $2}' $cfg_file)
35 /usr/sbin/nagios ${precached_object_file:+-p} -v $cfg_file
38 # wrapper for configtest:
42 if [ $details = 1 ]; then
43 # run config test and display report (status action)
44 show "Checking %s configuration" "Nagios"; busy
48 if [ $RETVAL = 0 ]; then
53 [ "$out" ] && echo >&2 "$out"
55 # run config test and abort with nice message if failed
56 # (for actions checking status before action).
57 configtest >/dev/null 2>&1
59 if [ $RETVAL != 0 ]; then
60 show "Checking %s configuration" "Nagios"; fail
61 nls 'Configuration test failed. See details with %s "checkconfig"' $0
68 # Check if the service is already running?
69 if [ -f /var/lock/subsys/nagios ]; then
70 msg_already_running "Nagios"
77 # remove stale cmd pipe (or nagios won't start if it exists)
78 rm -f /var/lib/nagios/rw/nagios.cmd
80 # we're safe to use -x as we did verify config prior startup
81 # precached object file also is created in configtest.
82 daemon /usr/sbin/nagios ${precached_object_file:+-u} -x -d $cfg_file
84 if [ $RETVAL -eq 0 ]; then
85 touch /var/lock/subsys/nagios
91 if [ ! -f /var/lock/subsys/nagios ]; then
92 msg_not_running "Nagios"
98 rm -f /var/lock/subsys/nagios > /dev/null 2>&1
102 if [ ! -f /var/lock/subsys/nagios ]; then
103 msg_not_running "Nagios"
109 msg_reloading "Nagios"
111 # NOTE: precached object file is created in configtest.
117 if [ ! -f /var/lock/subsys/nagios ]; then
118 msg_not_running "Nagios"
129 # See how we were called.
148 checkconfig|configtest)
156 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"