zabbix客户端一键安装脚本(主动模式监控)

#!/bin/bash

basepath=$(cd `dirname $0`; pwd)
SHELL_DIR="${basepath}/shell"
PACKAGE_DIR="${basepath}/package"


#获取参数
while getopts "n:" opt; do
case $opt in
n)
host_name=$OPTARG
;;
\?)
;;
esac
done

rpm -ivh $PACKAGE_DIR/zabbix-release-2.4-1.el6.noarch.rpm

yum install -y zabbix-agent

 

cat >/etc/zabbix/zabbix_agentd.conf <<EOF
PidFile=/tmp/zabbix_agentd.pid
LogFile=/tmp/zabbix_agentd.log
DebugLevel=3
ListenPort=10050
StartAgents=0
ServerActive=*.*.*.*
Hostname=$host_name
RefreshActiveChecks=120
BufferSend=5
BufferSize=10000
# MaxLinesPerSecond=100
# Timeout=3
# UnsafeUserParameters=1
EOF

systemctl enable zabbix-agent.service
systemctl restart zabbix-agent.service

zabbixagentpid=`ps aux|grep zabbix_agentd|grep -v "grep"|awk '{print $2}'`

if [ "$zabbixagentpid" ];then
echo "success ! zabbix agent is running now"
fi

 

posted @ 2017-11-07 15:05  Oops!#  阅读(771)  评论(0编辑  收藏  举报