#!/bin/sh # # chkconfig: - 86 14 # description: Zabbix agent daemon # ### BEGIN INIT INFO # Provides: zabbix-agent # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Should-Start: zabbix-server zabbix-proxy # Should-Stop: zabbix-server zabbix-proxy # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix agent # Description: Zabbix agent daemon ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions exec=/usr/sbin/zabbix_agentd prog=${exec##*/} syscf=${0##*/} lockfile=/var/lock/subsys/$syscf [ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf config=${CFG_FILE:-/etc/zabbix_agentd.conf} if [ ! -f $config ]; then echo "Not starting Zabbix agent: Config file $config not found!" echo "Check /etc/sysconfig/$syscf" exit 3 fi pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) param="-c $config" start() { echo -n $"Starting Zabbix agent: " daemon --user zabbix --pidfile "$pidfile" $exec $param rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv } stop() { echo -n $"Shutting down Zabbix agent: " killproc -p "$pidfile" $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p "$pidfile" -l $prog $exec ;; try-restart|condrestart) if status -p "$pidfile" -l $prog $exec >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;; esac