zabbix 监控iptables

参看的文章链接忘了。。。。。。

 

yum -y install iptstate

 

1、脚本位置和内容

[root@web1 scripts]# pwd
/etc/zabbix/scripts
[root@web1 scripts]# cat iptables.sh 
#!/bin/bash
function tcp {  
sudo iptstate --single | grep tcp | wc -l
}  
function tcpsyn {  
sudo iptstate --single | grep SYN | wc -l
}  
function tcptimewait {  
sudo iptstate --single | grep TIME_WAIT | wc -l
}  
function tcpestablished {  
sudo iptstate --single | grep ESTABLISHED | wc -l 
}  
function tcpclose {  
sudo iptstate --single | grep CLOSE | wc -l
}  
function udp {  
sudo iptstate --single | grep udp | wc -l
}  
function icmp {  
sudo iptstate --single | grep icmp | wc -l
}
function all {  
sudo iptstate --single | wc -l  
}
# Run the requested function  
$1
[root@web1 scripts]# 

 

2、visudo

zabbix  ALL=NOPASSWD: /usr/sbin/iptstate

 

3、修改zabbix-agent的配置文件

#iptables status
UserParameter=iptstate[*],/etc/zabbix/scripts/iptables.sh $1

 

4、web页面配置

链接:https://pan.baidu.com/s/1Y2X8I3uqun41GD5KyIACHQ 密码:tar2

 

5、效果

 

posted @ 2018-09-04 17:13  无敌仙人掌  阅读(974)  评论(0编辑  收藏  举报
AmazingCounters.com