]> git.pld-linux.org Git - packages/nagios.git/blame - nagios.init
- don't output screens of errors on start
[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
41 start)
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
0aff5e34
ER
53
54 if [ -e /var/lib/nagios/rw/nagios.cmd ]; then
55 chgrp http /var/lib/nagios/rw/nagios.cmd
56 fi
1d9bbb7b 57 fi
96018fcf 58 else
043169b2 59 msg_already_running nagios
96018fcf
TO
60 fi
61 ;;
62 stop)
043169b2 63 # Stop daemons.
96018fcf 64 if [ -f /var/lock/subsys/nagios ]; then
043169b2 65 msg_stopping nagios
66 killproc nagios -TERM
67 rm -f /var/lock/subsys/nagios > /dev/null 2>&1
68 else
96018fcf 69 msg_not_running nagios
96018fcf
TO
70 fi
71 ;;
72 status)
73 status nagios
64d31ef5 74 exit $?
96018fcf 75 ;;
c0fc57b8 76 checkconfig|check)
20bd359d
AG
77 /usr/sbin/nagios -v /etc/nagios/nagios.cfg
78 exit $?
79 ;;
b5170100
ŁJM
80 reload|force-reload)
81 if [ -f /var/lock/subsys/nagios ]; then
82 msg_reloading nagios
c0fc57b8
ER
83 checkconfig || exit
84
b5170100
ŁJM
85 killproc nagios -HUP
86 RETVAL=$?
87 else
88 msg_not_running nagios >&2
89 exit 7
90 fi
91 ;;
92 restart)
c0fc57b8
ER
93 msg_reloading nagios
94 checkconfig || exit && started
96018fcf
TO
95 $0 stop
96 $0 start
64d31ef5 97 exit $?
96018fcf
TO
98 ;;
99 *)
c0fc57b8 100 msg_usage "$0 {start|stop|restart|reload|force-reload|status|checkconfig}"
64d31ef5 101 exit 3
96018fcf
TO
102esac
103
104exit $RETVAL
This page took 0.067728 seconds and 4 git commands to generate.