zbbix-agent启动脚本

今天重新写一下,这里用的zabbix-agent5.2版本

#!/bin/bash

# zabbix-agent启停脚本
# 示例:./当前脚本名  可选参数[start/stop/restart/status]

# 配置项
# conf 配置文件路径,start启动脚本路径,pid文件存放路径(自定义)
conf=/opt/zabbix-agent5.2/conf/zabbix_agentd.conf
start="/opt/zabbix-agent5.2/sbin/zabbix_agentd"
pid="/tmp/zabbix-agent.pid"

# 主程序
pidcat=`cat $pid`
[ ! -f "$pid" ] && ps aux | egrep "./zabbix_agentd\ -c $conf" | awk '{print $2}' >$pid

if [ "$1" == "start" -o "$1" == "restart" ];then
        [ "$1" == "restart" ] && [[ ! "$pidcat" == "" ]] && kill $pidcat  && : > $pid
        $start -c $conf
        ps aux | egrep "./zabbix_agentd\ -c $conf" | awk '{print $2}' >$pid
        if [ "$pidcat" == "" ];then
                [[ ! "$pidcat" == "" ]] && echo "zabbix-agent started" || echo "zabix-agent start fail"
        else
                [ "$1" == "restart" ] && echo "zabbix-agent restarted"  || echo "zabbix-agent started"
        fi
elif [ "$1" == "stop" ];then
        [[ ! "$pidcat" == "" ]] && kill $pidcat  && : > $pid
        echo "zabbix-agent stopped"
elif [ "$1" == "status" ];then
        [[ ! "$pidcat" == "" ]] && echo "zabbix-agent started(pid:$pidcat)" || echo "zabbix-agent not started"
else
        echo "./zabbix-aget [start/stop/restart/status]"
fi

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

璐程风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值