check_centreon_snmp_traffic插件监控Linux虚拟机网卡的bug修订方法

测试check_centreon_snmp_traffic可以检测Windows的网卡流量,可以检测交换机的网卡流量,但不能检测Linux虚拟机的eth0网卡,显示的错误是 Error : Card speed is null, check command options

修复这个错误的方法如下:

把430行附近的

if (!$speed_card && !defined($opt_T)) {
    print "Error : Card speed is null, check command options\n";
    exit $ERRORS{'UNKNOWN'};
}


改为

if (!$speed_card && !defined($opt_T)) {
    #print "Error : Card speed is null, check command options\n";
    #exit $ERRORS{'UNKNOWN'};
    #xiugai
    if(!defined($in_bits)&&!defined($out_bits))
    {
        print "Error : Card speed is null, check command options\n";
        exit $ERRORS{'UNKNOWN'};
    }
    #set default 100Mb
    $speed_card = 100000000;
}


也就是当检测不到网卡速度($speed_card==0),但已经得到网卡流量数值($in_bits和$out_bits)时,把网卡速度默认赋值为100000000,即100Mb。这样就能得到检测结果了,由于-w和-c参数使用的是百分比,所以在设置这两个参数时要注意数值大小。

此外,默认命令行不输出状态结果,可以做如下修改,使得输出结果带状态字符串,例如下面开头的OK:

OK: Traffic In : 30.04 Mb/s (3.0 %), Out : 4.80 Mb/s (0.5 %) |traffic_in=30039837,6Bits/s;40000000;200000000;0;1000000000 traffic_out=4801448,7Bits/s;40000000;200000000;0;1000000000


修改方法是,把590行附近的

printf("Traffic In : %.2f ".$in_prefix."b/s (".$in_usage." %%), Out : %.2f ".$out_prefix."b/s (".$out_usage." %%) ", $in_traffic, $out_traffic);


改为

printf($status.": Traffic In : %.2f ".$in_prefix."b/s (".$in_usage." %%), Out : %.2f ".$out_prefix."b/s (".$out_usage." %%) ", $in_traffic, $out_traffic);

 



转载于:https://www.cnblogs.com/smartdog/archive/2012/08/20/2647835.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
STG (SNMP Traffic Grapher) version 1.4.5 Copyright (C) 2000 Leonid Mikhailov This freeware utility allows monitoring of supporting SNMPv1 and SNMPv2c devices including Cisco, Livingstone, Riverstone etc. Intended as fast aid for network administrators who need prompt access to current information about state of network equipment. Copyright In brief: You may use STG for any commercial and non commercial purpose. You may distribute STG for free. You may charge a fee for the physical act of transferring a copy only. This program is distributed WITHOUT ANY WARRANTY. Use it at your own risk. I cannot guarantee accuracy of displayed data. I am not liable to you for any possible damages etc... Source code is not available. Features: Single graph displays changes of two configurable SNMP variables with display of Current, Average, Maximum values. Screen snapshot: http://www.chat.ru/~leonidvm/stg.jpg Could be downloaded from: http://www.chat.ru/~leonidvm/ ftp://ftp.naytov.com/pub/stg/ Newer versions will be there too. STG was written as an add-on for MRTG application by Tobias Oetiker. MRTG (http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html) is absolutely necessary for every network and system administrator. It provides SNMP monitoring of any number devices simultaneously. However during my duties I often have to check state of ports on different routers that are not always in my domain and setting MRTG configuration takes some time. And does not allow to see last second changes in traffic. That's why STG was written. It allows monitoring of SNMP devices with different update periods starting from 0.01s so you could see what's happening right now. Also STG could be useful during network problems troubleshooting. It runs on MS Windows 2000, Windows NT 4.0, Windows 98 and Windows Millenium. To run it on WinNT 4.0 you may need mgmtapi.dll and mib.bin (see below) To run it on Win98 and Millenium you will need mg
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值