~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to misc/init.d/redhat/zabbix_suckerd_ctl

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2007-07-02 09:06:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070702090651-8l6fl3fjw9rh6l2u
Tags: 1:1.4.1-2
Add patch from SVN in order to fix Incorrect processing of character '%'
in user parameters and remote commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
# zabbix_suckerd_ctl 
4
 
#
5
 
# control script to stop/start/restart zabbix_suckerd
6
 
# author: charlie collins
7
 
# date: 01.21.2002
8
 
#
9
 
# revised 09.21.2003
10
 
# (setup for Red Hat 7.3 with Zabbix 1.0 beta)
11
 
# (should work for other Red Hat and Sys V style init machines as well)
12
 
#
13
 
# (modeled after apache style control scripts)
14
 
# (this script can be placed in init.d and respective runlevel for startup usage)
15
 
16
 
#
17
 
# The exit codes returned are:
18
 
#       0 - operation completed successfully
19
 
#       1 - 
20
 
#       2 - usage error
21
 
#       3 - zabbix_suckerd could not be started
22
 
#       4 - zabbix_suckerd could not be stopped
23
 
#       5 - zabbix_suckerd could not be started during a restart
24
 
#       6 - zabbix_suckerd could not be restarted during a restart
25
 
#
26
 
#
27
 
#
28
 
 
29
 
# **************
30
 
# config options
31
 
# **************
32
 
#
33
 
# (set config options to match your system settings) 
34
 
 
35
 
# base zabbix dir
36
 
BASEDIR=/opt/zabbix
37
 
# PID file
38
 
PIDFILE=/var/tmp/zabbix_suckerd.pid
39
 
# binary file
40
 
ZABBIX_SUCKERD=$BASEDIR/bin/zabbix_suckerd
41
 
 
42
 
 
43
 
# **************
44
 
# logic section (below here) does NOT normally need any modification
45
 
# **************
46
 
 
47
 
# establish args
48
 
ERROR=0
49
 
ARGV="$@"
50
 
if [ "x$ARGV" = "x" ] ; then 
51
 
    ARGS="help"
52
 
fi
53
 
 
54
 
 
55
 
# perform action based on args
56
 
for ARG in $@ $ARGS
57
 
do
58
 
        # check if PIDFILE exists and ensure is not zero size and react accordingly
59
 
        if [ -f $PIDFILE  ] && [ -s $PIDFILE ] ; then
60
 
            PID=`cat $PIDFILE`
61
 
                if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
62
 
                STATUS="zabbix_suckerd (pid $PID) running"
63
 
                RUNNING=1                       
64
 
            else
65
 
                STATUS="zabbix_suckerd (pid $PID?) not running"
66
 
                RUNNING=0                       
67
 
            fi
68
 
    else
69
 
            STATUS="zabbix_suckerd (no pid file) not running"
70
 
            RUNNING=0           
71
 
    fi
72
 
        
73
 
        # parse arg and react accordingly
74
 
    case $ARG in
75
 
    
76
 
        start)
77
 
        if [ $RUNNING -eq 1 ]; then
78
 
            echo "$0 $ARG: zabbix_suckerd (pid $PID) already running"
79
 
            continue
80
 
        fi
81
 
        if $ZABBIX_SUCKERD ; then
82
 
            echo "$0 $ARG: zabbix_suckerd started"
83
 
        else
84
 
            echo "$0 $ARG: zabbix_suckerd could not be started"
85
 
            ERROR=3
86
 
        fi
87
 
        ;;
88
 
    
89
 
        stop)
90
 
        if [ $RUNNING -eq 0 ]; then
91
 
            echo "stop called - in running eq 0"
92
 
                echo "$0 $ARG: $STATUS"
93
 
            continue
94
 
        fi
95
 
        if kill $PID ; then
96
 
                        echo "$0 $ARG: zabbix_suckerd process(es) stopped"
97
 
            else
98
 
                echo "$0 $ARG: zabbix_suckerd process(es) could not be stopped"
99
 
                ERROR=4
100
 
            fi
101
 
        ;;
102
 
    
103
 
        restart)
104
 
        if [ $RUNNING -eq 0 ]; then
105
 
            echo "$0 $ARG: zabbix_suckerd not running, trying to start"
106
 
            if $ZABBIX_SUCKERD ; then
107
 
                    echo "$0 $ARG: zabbix_suckerd started"
108
 
            else
109
 
                    echo "$0 $ARG: zabbix_suckerd could not be started"
110
 
                        ERROR=5
111
 
            fi
112
 
        else
113
 
            if kill $PID ; then
114
 
                    if $ZABBIX_SUCKERD ; then
115
 
                    echo "$0 $ARG: zabbix_suckerd restarted"
116
 
                        else
117
 
                                echo "$0 $ARG: zabbix_suckerd could not be started"
118
 
                                ERROR=3
119
 
                        fi
120
 
                else
121
 
                    echo "$0 $ARG: zabbix_suckerd could not be restarted"
122
 
                    ERROR=6
123
 
                fi          
124
 
    fi          
125
 
        ;;
126
 
    
127
 
        *)             
128
 
        
129
 
        echo "usage: $0 (start|stop|restart|help)"
130
 
        cat <<EOF
131
 
 
132
 
start      - start zabbix_suckerd
133
 
stop       - stop zabbix_suckerd
134
 
restart    - restart zabbix_suckerd if running by sending a SIGHUP or start if not running
135
 
help       - this screen
136
 
 
137
 
EOF
138
 
 
139
 
    ERROR=2
140
 
    ;;
141
 
 
142
 
    esac
143
 
 
144
 
done
145
 
 
146
 
exit $ERROR
147
 
 
148
 
 
149