zabbix监控之lvs
1,zabbix客户端配置
zabbix_agentd.conf末尾添加如下配置
### LVSConn
UserParameter=LVSAll,/usr/local/zabbix/etc/lvs_connstatus.sh LVSAllUserParameter=LVSConn,/usr/local/zabbix/etc/lvs_connstatus.sh LVSConnUserParameter=LVSInConn,/usr/local/zabbix/etc/lvs_connstatus.sh LVSInConn2,lvs连接数脚本如下
cat lvs_connstatus.sh
#!/bin/bashfunction 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,监控效果如下