SERVER
################################################## ########################
#!/bin/bash
#
# chkconfig: - 55 45
# description: zabbix_server
# probe: false
. /etc/rc.status
# Check that networking is up. If you are running without a network, comment this out.
#[ "${NETWORKING}" = "no" ] && exit 0
RETVAL=0
USER=zabbix
progdir="/opt/zabbix/bin/"
prog="zabbix_server"
pidfile="/var/run/zabbix/zabbix_server.pid"
start() {
# Start daemons.
if [ -f $pidfile ]; then
if ps `cat $pidfile` >/dev/null; then
echo -n "$prog: already running"
echo -n $"$prog start"
false
rc_status -v
exit
else
rm -f $pidfile
fi
else
rm -f $pidfile
fi
echo -n $"Starting $prog: "
# we can't seem to use daemon here - emulate its functionality
su -c $progdir$prog - $USER
RETVAL=$?
usleep 1000
if [ -z "`/sbin/pidof $progdir$prog`" ]; then
# The child processes have died after fork()ing, e.g.
# because of a broken config file
RETVAL=1
fi
[ $RETVAL -ne 0 ] && rc_status -v
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog && echo -n $"$prog startup" && rc_status -v
return $RETVAL
}
stop() {
RETVAL=0
pid=
# Stop daemons.
echo -n $"Stopping $prog: "
pid=`cat $pidfile`
if [ "$pid" ]; then
kill $pid
else
echo -n $"$prog stop"
rc_status -v
return 1
fi
RETVAL=$?
[ $RETVAL -ne 0 ] && rc_status -v
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && echo $"$prog stop" && rc_status -v
echo
return $RETVAL
}
restart() {
stop
# wait for forked daemons to die
usleep 1000000
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
AGENT
################################################## ########################
#!/bin/bash
#
# chkconfig: - 55 45
# description: zabbix_agentd
# probe: false
. /etc/rc.status
# Check that networking is up. If you are running without a network, comment this out.
#[ "${NETWORKING}" = "no" ] && exit 0
RETVAL=0
progdir="/opt/zabbix/bin/"
prog="zabbix_agentd"
pidfile="/var/run/zabbix/zabbix_agentd.pid"
start() {
# Start daemons.
if [ -f $pidfile ]; then
if ps `cat $pidfile` >/dev/null; then
echo -n "$prog: already running"
echo -n $"$prog start"
false
rc_status -v
exit
else
rm -f $pidfile
fi
else
rm -f $pidfile
fi
echo -n $"Starting $prog: "
# we can't seem to use daemon here - emulate its functionality
su -c $progdir$prog - $USER
usleep 1000
if [ -f /var/run/zabbix/$prog.pid ]; then
ps `cat /var/run/zabbix/$prog.pid` >/dev/null
else
false
fi
rc_status -v
if [ $RETVAL -eq 0 ]; then
touch /var/lock/subsys/$prog
echo -n $"$prog startup"
fi
return $RETVAL
}
stop() {
RETVAL=0
pid=
# Stop daemons.
echo -n $"Stopping $prog: "
pid=`cat $pidfile`
if [ -n "$pid" ]; then
kill $pid
else
echo -n $"$prog stop"
rc_status -v
return 1
fi
RETVAL=$?
[ $RETVAL -ne 0 ] && rc_status -v
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && echo $"$prog stop" && rc_status -v
echo
return $RETVAL
}
restart() {
stop
# wait for forked daemons to die
sleep 2
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
################################################## ########################
#!/bin/bash
#
# chkconfig: - 55 45
# description: zabbix_server
# probe: false
. /etc/rc.status
# Check that networking is up. If you are running without a network, comment this out.
#[ "${NETWORKING}" = "no" ] && exit 0
RETVAL=0
USER=zabbix
progdir="/opt/zabbix/bin/"
prog="zabbix_server"
pidfile="/var/run/zabbix/zabbix_server.pid"
start() {
# Start daemons.
if [ -f $pidfile ]; then
if ps `cat $pidfile` >/dev/null; then
echo -n "$prog: already running"
echo -n $"$prog start"
false
rc_status -v
exit
else
rm -f $pidfile
fi
else
rm -f $pidfile
fi
echo -n $"Starting $prog: "
# we can't seem to use daemon here - emulate its functionality
su -c $progdir$prog - $USER
RETVAL=$?
usleep 1000
if [ -z "`/sbin/pidof $progdir$prog`" ]; then
# The child processes have died after fork()ing, e.g.
# because of a broken config file
RETVAL=1
fi
[ $RETVAL -ne 0 ] && rc_status -v
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog && echo -n $"$prog startup" && rc_status -v
return $RETVAL
}
stop() {
RETVAL=0
pid=
# Stop daemons.
echo -n $"Stopping $prog: "
pid=`cat $pidfile`
if [ "$pid" ]; then
kill $pid
else
echo -n $"$prog stop"
rc_status -v
return 1
fi
RETVAL=$?
[ $RETVAL -ne 0 ] && rc_status -v
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && echo $"$prog stop" && rc_status -v
echo
return $RETVAL
}
restart() {
stop
# wait for forked daemons to die
usleep 1000000
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
AGENT
################################################## ########################
#!/bin/bash
#
# chkconfig: - 55 45
# description: zabbix_agentd
# probe: false
. /etc/rc.status
# Check that networking is up. If you are running without a network, comment this out.
#[ "${NETWORKING}" = "no" ] && exit 0
RETVAL=0
progdir="/opt/zabbix/bin/"
prog="zabbix_agentd"
pidfile="/var/run/zabbix/zabbix_agentd.pid"
start() {
# Start daemons.
if [ -f $pidfile ]; then
if ps `cat $pidfile` >/dev/null; then
echo -n "$prog: already running"
echo -n $"$prog start"
false
rc_status -v
exit
else
rm -f $pidfile
fi
else
rm -f $pidfile
fi
echo -n $"Starting $prog: "
# we can't seem to use daemon here - emulate its functionality
su -c $progdir$prog - $USER
usleep 1000
if [ -f /var/run/zabbix/$prog.pid ]; then
ps `cat /var/run/zabbix/$prog.pid` >/dev/null
else
false
fi
rc_status -v
if [ $RETVAL -eq 0 ]; then
touch /var/lock/subsys/$prog
echo -n $"$prog startup"
fi
return $RETVAL
}
stop() {
RETVAL=0
pid=
# Stop daemons.
echo -n $"Stopping $prog: "
pid=`cat $pidfile`
if [ -n "$pid" ]; then
kill $pid
else
echo -n $"$prog stop"
rc_status -v
return 1
fi
RETVAL=$?
[ $RETVAL -ne 0 ] && rc_status -v
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && echo $"$prog stop" && rc_status -v
echo
return $RETVAL
}
restart() {
stop
# wait for forked daemons to die
sleep 2
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?