温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nagios监控网卡流量

发布时间:2020-07-17 13:43:46 来源:网络 阅读:313 作者:adpanshi 栏目:移动开发

有个机器流量带宽比较小,担心跑慢,就做个流量监控

1、配置snmp

   主要配置

   com2sec notConfigUser  default      public

   此处source字段配的是default,因为nagios服务器和cacti我放在不同服务器上了,能让他们都访问

   access  notConfigGroup ""      any       noauth    exact  all none none

   view all    included  .1                               80

   view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc


配置好后重启snmpd

2、下载脚本

   下载好后放在libexec目录,给执行权限

[root@localhost libexec]# ./check_traffic.sh -V 2c -C public -H 127.0.0.1 -L

List Interface for host 127.0.0.1.

Interface index 1 orresponding to  lo

Interface index 2 orresponding to  eth0

Interface index 3 orresponding to  eth2

找到要监控的网卡,我这里是eth0

./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2   -w 4,6  -c 6,10  -M -b

OK - It's the first time for this plugins run. We'll get the data from the next time.

[root@server_67 libexec]# ./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2   -w 6,8  -c 8,10  -M -b

Warning - The Traffic In is 0.33Mbps, Out is 8.28Mbps, Total is 8.61Mbps. The Check Interval is 69s |In=0.33Mbps;6;8;0;0 Out=8.28Mbps;8;10;0;0 Total=8.61Mbps;14;18;0;0 Interval=69s;1200;1800;0;0

间隔需要30秒,配置好nrpe,再nagios服务器上添加,重启nagios就好了

如果以非nagios用户身份,手动测试执行过该脚本,请在正式使用该脚本前,删除/var/tmp下对应测试生成的/var/tmp/check_traffic_${Host}_${Interface}.hist_dat文件,否则会造成nagios用户无法读写该文件的错误。

V 代表snmp版本

C 代表community的名称

H 代表主机IP

I 代表网卡号

w 、c就不必说了吧

补充:10,10 30,30(代表in,out)


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI