ngios监控我window主机和LInux主机网卡流量
安装snmp
yum install net-snmp 修改如下 [root@xen etc]# grep -v ‘#‘ /etc/snmp/snmpd.conf |grep -v ‘^$‘ com2sec notConfigUser default mypublic com2sec notConfigUser 192.168.0.138 mypublic group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 access notConfigGroup "" any noauth exact all none none view all included .1 80 view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) dontLogTCPWrappersConnects yes
首先将check_triffic.sh脚本拷贝到/usr/local/nagios/libexec/里面。然后在/usr/local/nagios/etc/objects/commands.cfg 文件中添加
define command{ command_name check_traffic command_line $USER1$/check_traffic.sh -V 2c -C mypublic -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$,$ARG3$ -c $ARG4$,$ARG5$ }
识别自己网卡型号
[root@xen etc]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C mypublic -H 192.168.0.156 -L List Interface for host 192.168.0.156. Interface index 1 orresponding to lo #1号网卡 Interface index 2 orresponding to eth0 #2号网卡
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C mypublic -H 192.168.0.156 -I 2 -w 10,10 -c 30,30
V 代表snmp版本 C 代表community的名称 H 代表主机IP I 代表网卡号 w 警告 c 紧急 补充:10,10 30,30(代表in,out)
OK - The Traffic In is 0.11KB, Out is 0.0KB, Total is 0.11KB. The Check Interval is 109s |In=0.11KB;1200;1700;0;0 Out=0.0KB;1500;1800;0;0 Total=0.11KB;2700;3500;0;0 Interval=109s;1200;1800;0;0
如果你跟我一样报错
[root@xen libexec]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C mypublic -H 192.168.0.156 -L List Interface for host 192.168.0.156. Interface index = No Such Object available on this agent at this OID
请修改
解决: vim /etc/snmp/snmpd.conf 修改两处: 一处: access notConfigGroup "" any noauth exact all none none 或者 access notConfigGroup "" any noauth exact mib2 none none 二处: view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
添加服务
vim /usr/local/nagios/etc/objects/linuxhost.cfg define service{ use generic-service,srv-pnp ; Name of service template to use host_name linuxhost service_description check_traffic check_command check_nrpe!check_traffic }
监控服务未知?
Unknown - Read or Write File /var/tmp/check_traffic_192.168.0.156_2__itnms.hist_dat_64 Error with user uid=542(nagios) gid=543(nagios) groups=543(nagios),544(nagcmd) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023.
修改其权限为nagios.nagios即可
即可恢复看到网卡流量
check_traffic 下载地址http://pan.baidu.com/s/1i3vNlBJ
监控本机网卡流量
先定义commandcf
define command{ command_name check_traffic command_line $USER1$/check_traffic.sh -V 2c -C mypublic -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$,$ARG3$ -c $ARG4$,$ARG5$ }
定义服务
define service{ use local-service,srv-pnp ; Name of service template to use host_name localhost service_description check_traffic check_command check_traffic!3!100!100!300!300 }
单位默认是Kbps
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。