码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix_agent 设置脚本使用

时间:2020-01-16 14:20:43      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:tar   使用   end   bsp   rac   hostname   metadata   add   name   

zabbix_agent.conf

SourceIP=zabbix_agentIP
Hostname=zabbix_agentIP
Server=127.0.0.1
ServerActive=127.0.0.1
EnableRemoteCommands=1
LogRemoteCommands=1
HostMetadataItem=system.uname
Timeout=30
AllowRoot=0
User=bestpay
Include=/tools/zabbix_agent/etc/zabbix_agentd.conf.d/
UnsafeUserParameters=1

disk_sh

#!/bin/bash

diskarray=(`cat /proc/diskstats |grep -E "\bsd[a-z][0-9]*\b|\bxvd[a-z][0-9]*\b|\bvd[a-z][0-9]*\b"|awk ‘{print $3}‘|sort|uniq 2>/dev/null`)
length=${#diskarray[@]}
printf "{\n"
printf ‘\t‘"\"data\":["
for ((i=0;i<$length;i++))
do
printf ‘\n\t\t{‘
printf "\"{#DISK_NAME}\":\"${diskarray[$i]}\"}"
if [ $i -lt $[$length-1] ];then
printf ‘,‘
fi
done
printf "\n\t]\n"
printf "}\n"

 

zabbix_agent 修改

#/bin/bash
for line in $(cat ip_list)
do
function ssh_command() {
expect -c "
set timeout 2
spawn ssh root@$line
expect {
\"yes/no)? \" { send \"yes\r\"; exp_continue }
\"word: \" { send \"$PASS\r\" }
}
expect \"# \"
send \"$1\r\"
expect \"$# \"
send \"exit\r\"
expect eof
"
}
ssh -tt $line<<EOF
sed -i -e ‘s/Server=127.0.0.1/Server=zabbix_serverIP/g‘ /tools/zabbix_agent/etc/zabbix_agentd.conf >>/dev/null
sed -i -e ‘s/ServerActive=127.0.0.1/ServerActive=zabbix_serverIP/g‘ /tools/zabbix_agent/etc/zabbix_agentd.conf >> /dev/null
sed -i ‘s/SourceIP=/&$line/g‘ /tools/zabbix_agent/etc/zabbix_agentd.conf >> /dev/null
sed -i ‘s/Hostname=/&$line/g‘ /tools/zabbix_agent/etc/zabbix_agentd.conf >> /dev/null
bash /etc/init.d/zabbix-agent start >> /dev/null
bash chkconfig --add zabbix-agent /dev/null
bash chkconfig zabbix-agent on >> /dev/null
echo "success $line "
exit
EOF

echo $line
done

zabbix_agent 设置脚本使用

标签:tar   使用   end   bsp   rac   hostname   metadata   add   name   

原文地址:https://www.cnblogs.com/quemengqio/p/12200800.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!