备注声明:最好是使用官方server模版
#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=zabbix_server
ZABBIX_BIN=/usr/local/zabbix_server/sbin/$NAME
CONFIGFILE=/usr/local/zabbix_server/etc/$NAME.conf
case "$1" in
start)
$ZABBIX_BIN -c $CONFIGFILE
echo "$NAME 服务已经启用了!"
;;
stop)
kill `ps aux | grep zabbix | awk '{print $2}' | head -n 1`
echo "$NAME 服务已经停止了"
;;
status)
if netstat -tnpl | grep -q zabbix; then
echo "$NAME 运行中..."
else
echo "$NAME 停止运行状态!"
exit 0
fi
;;
restart)
kill `ps aux | grep zabbix | awk '{print $2}' | head -n 1`
$ZABBIX_BIN -c $CONFIGFILE
echo "$NAME 服务重启成功!!!"
;;
esac