zabbix监控之lvs
1,zabbix客户端配置
zabbix_agentd.conf末尾添加如下配置
### LVSConn
UserParameter=LVSAll,/usr/local/zabbix/etc/lvs_connstatus.sh LVSAll
UserParameter=LVSConn,/usr/local/zabbix/etc/lvs_connstatus.sh LVSConn
UserParameter=LVSInConn,/usr/local/zabbix/etc/lvs_connstatus.sh LVSInConn
2,lvs连接数脚本如下
cat lvs_connstatus.sh
#!/bin/bash function LVSConn { sudo /sbin/ipvsadm -L -n | sed -n ‘2,$p‘ |awk ‘{print $5}‘|awk ‘BEGIN{sum=0}{sum+=$1}END{print sum}‘ } function LVSInConn { sudo /sbin/ipvsadm -L -n | sed -n ‘2,$p‘ |awk ‘{print $6}‘| awk ‘BEGIN{sum=0}{sum+=$1}END{print sum}‘ } function LVSAll { sudo /sbin/ipvsadm -L -n | sed -n ‘2,$p‘ |awk ‘{print $5 + $6}‘ |awk ‘BEGIN{sum=0}{sum+=$1}END{print sum}‘ } # Run the requested function $1
3,设置sudo权限
echo ‘Defaults:zabbix !requiretty‘ >>/etc/sudoers
echo ‘zabbix ALL=(ALL) NOPASSWD:/sbin/ipvsadm‘ >>/etc/sudoers
4,zabbix web界面添加lvs监控模板,添加lvs客户端监控项 ,lvs监控模板如下
5,监控效果如下
本文出自 “jerrymin” 博客,请务必保留此出处http://jerrymin.blog.51cto.com/3002256/1675752
原文地址:http://jerrymin.blog.51cto.com/3002256/1675752