#!/bin/ksh
#Variables
BASEDIR=/usr/local/zabbix/bin/
PIDDIR=/var/tmp/
PGREP=`which pgrep`
#Functions
funct_start(){
if $PGREP -x $PR >/dev/null 2>&1; then
echo "$0: $PR is already running `$PGREP -d ' ' -x $PR`"
else
${BASEDIR}$PR
sleep 1
echo "$0: $PR has started `$PGREP -d ' ' -x $PR`"
fi
}
funct_stop(){
kill -9 `ps -aef | grep $PR | grep -v grep | awk '{print $2}'`
if [[ -f ${PIDDIR}${PR}.pid ]]
then
rm ${PIDDIR}${PR}.pid
fi
if $PGREP -x $PR >/dev/null 2>&1; then
echo "$0: $PR is running"
exit 0
else
echo "$0: $PR stopped"
fi
}
case "$1" in
'start')
PR=zabbix_agentd
funct_start
PR=zabbix_suckerd
funct_start
PR=zabbix_trapperd
funct_start
;;
'stop')
PR=zabbix_agentd
funct_stop
PR=zabbix_suckerd
funct_stop
PR=zabbix_trapperd
funct_stop
;;
'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
$0 stop
sleep 5
$0 start
;;
*)
# usage
echo "Usage: $0 start|stop|restart"
exit 1
;;
esac
exit
#Variables
BASEDIR=/usr/local/zabbix/bin/
PIDDIR=/var/tmp/
PGREP=`which pgrep`
#Functions
funct_start(){
if $PGREP -x $PR >/dev/null 2>&1; then
echo "$0: $PR is already running `$PGREP -d ' ' -x $PR`"
else
${BASEDIR}$PR
sleep 1
echo "$0: $PR has started `$PGREP -d ' ' -x $PR`"
fi
}
funct_stop(){
kill -9 `ps -aef | grep $PR | grep -v grep | awk '{print $2}'`
if [[ -f ${PIDDIR}${PR}.pid ]]
then
rm ${PIDDIR}${PR}.pid
fi
if $PGREP -x $PR >/dev/null 2>&1; then
echo "$0: $PR is running"
exit 0
else
echo "$0: $PR stopped"
fi
}
case "$1" in
'start')
PR=zabbix_agentd
funct_start
PR=zabbix_suckerd
funct_start
PR=zabbix_trapperd
funct_start
;;
'stop')
PR=zabbix_agentd
funct_stop
PR=zabbix_suckerd
funct_stop
PR=zabbix_trapperd
funct_stop
;;
'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
$0 stop
sleep 5
$0 start
;;
*)
# usage
echo "Usage: $0 start|stop|restart"
exit 1
;;
esac
exit