Logoj0ke.net Open Build Service > Projects > server:monitoring > nagios-ndoutils > ndoutils-init
Sign Up | Log In

File ndoutils-init of Package nagios-ndoutils

x
 
1
#!/bin/sh
2
#
3
# Startup script for NDO2DB
4
#
5
# /etc/init.d/ndo2db
6
# and its symbolic link
7
# /usr/sbin/rcndo2db
8
#
9
### BEGIN INIT INFO
10
# Provides:         ndo2db
11
# Required-Start:   $syslog $remote_fs mysql
12
# Required-Stop:    $syslog $remote_fs mysql
13
# Default-Start:    3 5
14
# Default-Stop:     0 1 2 6
15
# Short-Description: Nagios Data Output Utilities
16
# Description: Automatic startup and shutdown of Nagios NDO2DB.
17
#   NDOUtils is an Nagios addon allowing you to store Nagios data (current status
18
#   information, state history, notification history, etc.) in a MySQL database.
19
### END INIT INFO
20
21
NDO2DB=/usr/sbin/ndo2db
22
test -x $NDO2DB || { echo "$NDO2DB not installed";
23
    if [ "$1" = "stop" ]; then exit 0;
24
    else exit 5; fi; }
25
26
NDO2DB_CONFIG=/etc/nagios/ndo2db.cfg
27
test -r $NDO2DB_CONFIG || { echo "$NDO2DB_CONFIG not existing";
28
    if [ "$1" = "stop" ]; then exit 0;
29
    else exit 6; fi; }
30
31
. /etc/rc.status
32
rc_reset
33
34
35
case "$1" in
36
    start)
37
        echo -n "Starting ndo2db "
38
        su - nagios -c "$NDO2DB -c $NDO2DB_CONFIG"
39
        rc_status -v
40
    ;;
41
    stop)
42
        echo -n "Shutting down ndo2db "
43
        su - nagios -c "killall -9 $NDO2DB"
44
        test -f /var/lock/ndo.sock && rm /var/lock/ndo.sock
45
        rc_status -v
46
    ;;
47
    try-restart|condrestart)
48
        if test "$1" = "condrestart"; then
49
            echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
50
        fi
51
        $0 status
52
        if test $? = 0; then
53
            $0 restart
54
        else
55
            rc_reset    # Not running is not a failure.
56
        fi
57
        # Remember status and be quiet
58
        rc_status
59
    ;;
60
    restart)
61
        $0 stop
62
        $0 start
63
        rc_status
64
    ;;
65
    force-reload)
66
        echo -n "Reload service ndo2db "
67
        /sbin/killproc -HUP $NDO2DB
68
        rc_status -v
69
        ## Otherwise:
70
        #$0 try-restart
71
        #rc_status
72
    ;;
73
    reload)
74
        echo -n "Reload service ndo2db "
75
        /sbin/killproc -HUP $NDO2DB
76
        rc_status -v
77
        ## Otherwise:
78
        #rc_failed 3
79
        #rc_status -v
80
    ;;
81
    status)
82
        echo -n "Checking for service ndo2db "
83
        /sbin/checkproc $NDO2DB
84
        rc_status -v
85
    ;;
86
    probe)
87
        test $NDO2DB_CONFIG -nt /var/run/ndo2db.pid && echo reload
88
    ;;
89
    *)
90
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
91
        exit 1
92
    ;;
93
esac
94
rc_exit
95