总体思路是利用agent脚本定时抓取3par的各模块功率的具体值,利用定时任务获取功率值,然后分析处理数据,再塞到zabbix服务端,监控功率值的变化。
3par信任zabbix-agent的ssh连接
1.1 agent主机生成公钥key
ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): gz3par
未用DNS所以需要把key中的hostname改为IP
vi gz3par.pub
行尾的root@hostname修改为root@ipaddr
1.2 3par执行信任主机ssh
gz3par cli% setsshkey
Please enter the SSH public key below. When finished, press enter twice.
The key is usually long. It's better to copy it from inside an editor
and paste it here. (Please make sure there are no extra blanks.)
The maximum number of characters used to represent the SSH key
(including the "from" option, key type, and additional comments) is 4095.
此处手动复制粘贴1.1中修改后的gz3par.pub全部内容
▒▒uUUUSSH public key successfully set.
gz3par cli%
1.3 agent主机执行测试
ssh -Tq -i /root/gz3par 3paradm@3parip
首次手动登录输入yes后,连接成功。
The authenticity of host 'xx.xx.xx.xx (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is SHA256:uU2aco922hyEUXNi85CMlfdFyHf7tmeLcsZvly0KLuU.
RSA key fingerprint is MD5:68:a6:c9:60:a1:cb:12:e2:76:1a:ee:47:b0:8b:f9:ee.
Are you sure you want to continue connecting (yes/no)? yes
Check that the client version is appropriate for the server.
Warning: Interface definition mismatch for the following interface variables:
getfsnfshealthInd
gz3par cli% exit
再次执行:
ssh -Tq -i /root/gz3par 3paradm@3parip
直接进入无需输入密码。
验证通过。
zabbix-agent设置定时捞取
crontab设置:
*/10 * * * * /etc/zabbix/scripts/3par/3par1sfp.sh > /etc/zabbix/scripts/3par/3par1sfp.log
3par1sfp.sh内容如下:
#!/bin/bash
loginuser="3paradm"
ipaddr="10.57.19.XX"
keyfile=/etc/zabbix/scripts/3par/gz3par.key
ssh -Tq -i $keyfile $loginuser@$ipaddr <<EOF
showport -sfp -ddm
exit
EOF
解释:
keyfile:为1.2步骤的/root/gz3par拷贝的私钥
showport -sfp -ddm:3par存储查看SFP光模块的收发光功率
zabbix-agent自定义用户参数
vi /etc/zabbix/zabbix_agentd.conf
UserParameter=3par1_Fc1_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '1p' | awk '{print $4}'
UserParameter=3par1_Fc2_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '2p' | awk '{print $4}'
UserParameter=3par1_Fc5_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '3p' | awk '{print $4}'
UserParameter=3par1_Fc6_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '4p' | awk '{print $4}'
UserParameter=3par1_Fc7_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '5p' | awk '{print $4}'
UserParameter=3par1_Fc8_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '6p' | awk '{print $4}'
UserParameter=3par1_Fc11_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '7p' | awk '{print $4}'
UserParameter=3par1_Fc12_txPower,cat /etc/zabbix/scripts/3par/3par1sfp.log | grep "TX Power"| sed -n '8p' | awk '{print $4}'
解释:此处定义了八个自定义参数,分别为每个port的TX功率值
重启zabbix-agent。
zabbix-server测试:
zabbix_get -s 10.57.17.107 -k "3par1_Fc12_txPower"
可以获取值,测试通过。
zabbix-server设置监控项等
监控项:
触发器:
此处设置port tx power<400uW进行报警。