lausser / check_nwc_health

nwc = network component. This plugin checks lots of aspects of routers, switches, wlan controllers, firewalls,.....
http://labs.consol.de/nagios/check_nwc_health
GNU General Public License v2.0
146 stars 88 forks source link

Wrong DiscardsPercent for check_nwc_health mode interface-health (FIX) #298

Open attiliobroglio opened 2 years ago

attiliobroglio commented 2 years ago

Using the check_nwc_health (10.0.0.2), mode interface-health on a Fortinet (but also other vendor/device), I obtain weird values of percentage of discarded in /out packets. It exceeds the 100% (for example 5716%). Analyzing the device interface via SNMP I see that the interface is generating not so much traffic (delta=128), but a very high number of discarded packets (delta=7317), so I check the code. In my opinion, the formula used to compute this percentage is not correct, because it doesn't take into account the number of discarded packets in the denominator. So I fix the code in this way (line 73907).

Percentage of Percent of Discards In:

    $self->{inputDiscardsPercent} = $self->{delta_ifInPkts} == 0 ? 0 :
#       100 * $self->{delta_ifInDiscards} / $self->{delta_ifInPkts};
        100 * $self->{delta_ifInDiscards} / ($self->{delta_ifInPkts} + $self->{delta_ifInDiscards});

Percentage of Percent of Discards Out:

    $self->{outputDiscardsPercent} = $self->{delta_ifOutPkts} == 0 ? 0 :
#       100 * $self->{delta_ifOutDiscards} / $self->{delta_ifOutPkts};
        100 * $self->{delta_ifOutDiscards} / ($self->{delta_ifOutPkts} + $self->{delta_ifOutDiscards});

From your point of view, is this proposed fix a valid solution? Hope this helps

andytlc68 commented 2 years ago

I agree with "attiliobroglio". I had the same problem and the only way was to change the formula. If you agree with this change, it might be a good idea to implement the change/fix in the next check_nwc_health release. Best regards ..

log1-c commented 2 years ago

The issue also exists with Cisco C3750 switches Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE1

CRITICAL - interface GigabitEthernet3/0/5 (alias ***MPLS Router***) discards in:0.00% out:158.01% , [...]