zabbix_agented啟動關閉重啟指令碼_2018_lcf
阿新 • • 發佈:2018-12-29
請根據自己實際路徑修改第二行路徑即可
#!/bin/bash pfurl='/usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf' PID=0 kill_zabbix_agentd(){ ps aux | awk -r '/zabbix_agentd/{print $2}' | xargs -n1 -exec kill {} &> /dev/null } pfstart(){ num=`ps aux | awk -r '/zabbix_agentd/{print $2}' | wc -l` if [ $num != "1" ];then echo "zabbix_agentd is useing" else echo "zabbix_agentd is starting..." $pfurl echo "start done!" fi } if [ "$1" == "-s" ];then if [ "$2" == "stop" ];then echo "zabbix_agentd is stopping...." kill_zabbix_agentd echo "stop done!" elif [ "$2" == "start" ];then pfstart elif [ "$2" == "restart" ];then echo "zabbix_agentd is stopping...." kill_zabbix_agentd echo "stop done!" echo "zabbix_agentd is starting..." $pfurl echo "start done!" fi elif [ "$1" == "--help" ];then echo "zabbix_agentd -s [start/stop/restart]" else pfstart fi