]> git.pld-linux.org Git - packages/nagios.git/blame - nagios.init
- rel .43
[packages/nagios.git] / nagios.init
CommitLineData
96018fcf
TO
1#!/bin/sh
2#
3# nagios Host/service/network monitoring daemon
4#
20cccccd 5# chkconfig: 345 85 24
96018fcf
TO
6# description: Host/service/network monitoring daemon which uses snort as NIDS
7#
8
9# Source function library
10. /etc/rc.d/init.d/functions
11
12# Get network config
13. /etc/sysconfig/network
14
15# Get service config
16[ -f /etc/sysconfig/nagios ] && . /etc/sysconfig/nagios
17
18# Check that networking is up.
19if is_yes "${NETWORKING}"; then
9405ddf7 20 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
043169b2 21 msg_network_down nagios
22 exit 1
23 fi
96018fcf 24else
043169b2 25 exit 0
96018fcf
TO
26fi
27
20bd359d
AG
28checkconfig() {
29 res=`/usr/sbin/nagios -v /etc/nagios/nagios.cfg`
30 rc=$?
31 if [ $rc -gt 0 ]; then
c0fc57b8
ER
32 fail
33 nls 'The configuration is broken. See details with %s "checkconfig"' $0
20bd359d
AG
34 fi
35 return $rc
36}
37
64d31ef5 38RETVAL=0
96018fcf
TO
39# See how we were called.
40case "$1" in
62e2d388 41start)
96018fcf 42 # Check if the service is already running?
043169b2 43 if [ ! -f /var/lock/subsys/nagios ]; then
96018fcf 44 msg_starting nagios
c0fc57b8
ER
45 checkconfig || exit
46
043169b2 47 # remove stale cmd pipe (or nagios won't start if it exists)
48 rm -f /var/lib/nagios/rw/nagios.cmd
5e5e55c4 49 daemon /usr/sbin/nagios -d /etc/nagios/nagios.cfg </dev/null
043169b2 50 RETVAL=$?
1d9bbb7b
TO
51 if [ $RETVAL -eq 0 ]; then
52 touch /var/lock/subsys/nagios
1d9bbb7b 53 fi
96018fcf 54 else
043169b2 55 msg_already_running nagios
96018fcf
TO
56 fi
57 ;;
62e2d388 58stop)
043169b2 59 # Stop daemons.
96018fcf 60 if [ -f /var/lock/subsys/nagios ]; then
043169b2 61 msg_stopping nagios
62 killproc nagios -TERM
63 rm -f /var/lock/subsys/nagios > /dev/null 2>&1
64 else
96018fcf 65 msg_not_running nagios
96018fcf
TO
66 fi
67 ;;
62e2d388 68status)
96018fcf 69 status nagios
64d31ef5 70 exit $?
96018fcf 71 ;;
62e2d388 72checkconfig|check)
20bd359d
AG
73 /usr/sbin/nagios -v /etc/nagios/nagios.cfg
74 exit $?
75 ;;
62e2d388
ER
76reload|force-reload)
77 if [ -f /var/lock/subsys/nagios ]; then
78 msg_reloading nagios
79 checkconfig || exit
c0fc57b8 80
62e2d388
ER
81 killproc nagios -HUP
82 RETVAL=$?
83 else
84 msg_not_running nagios >&2
85 exit 7
86 fi
87 ;;
88restart)
c0fc57b8
ER
89 msg_reloading nagios
90 checkconfig || exit && started
96018fcf
TO
91 $0 stop
92 $0 start
64d31ef5 93 exit $?
96018fcf 94 ;;
62e2d388 95*)
c0fc57b8 96 msg_usage "$0 {start|stop|restart|reload|force-reload|status|checkconfig}"
64d31ef5 97 exit 3
96018fcf
TO
98esac
99
100exit $RETVAL
This page took 0.130538 seconds and 4 git commands to generate.