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

ZABBIX之TCP连接数监控

时间:2016-06-02 00:44:54      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

ss -ant | awk ‘NR>1 {++s[$1]} END {for(k in s) print k,s[k]}‘
1,配置文件
cat > /etc/zabbix/zabbix_agentd.d/tcp_status.conf <<end
## Monitor tcp status
UserParameter=tcp[*],/etc/zabbix/scripts/tcp_status.sh \$1
end
 
2,脚本
cat >/etc/zabbix/scripts/tcp_status.sh <<end
#!/bin/bash
#scripts for tcp status
function SYNRECV {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘SYN-RECV‘ | awk ‘{print \$2}‘
}
function ESTAB {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘ESTAB‘ | awk ‘{print \$2}‘
}
function FINWAIT1 {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘FIN-WAIT-1‘ | awk ‘{print \$2}‘
}
function FINWAIT2 {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘FIN-WAIT-2‘ | awk ‘{print \$2}‘
}
function TIMEWAIT {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘TIME-WAIT‘ | awk ‘{print \$2}‘
}
function LASTACK {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘LAST-ACK‘ | awk ‘{print \$2}‘
}
function LISTEN {
/usr/sbin/ss -ant | awk ‘{++s[\$1]} END {for(k in s) print k,s[k]}‘ | grep ‘LISTEN‘ | awk ‘{print \$2}‘
}
\$1
end
 
chmod a+x /etc/zabbix/scripts/tcp_status.sh

ZABBIX之TCP连接数监控

标签:

原文地址:http://www.cnblogs.com/tankt101/p/5551590.html

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