Fix interface error/discard percentage calculation exceeding 100% #346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Description
My customer encountered this issue on several firewall switches with WAN interfaces where the plugin reported error values exceeding 4000%. This mathematical impossibility indicated a bug in the percentage calculation logic.
Root Cause Analysis
The current calculation uses only successful packets as the denominator:
100 * $self->{delta_ifInErrors} / $self->{delta_ifInPkts}
However, according to RFC 2863, the
ifInPkts
/ifOutPkts
counters represent only successfully received packets, excluding errored/discarded packets. This means:Errors / Successful_packets * 100
Errors / (Successful_packets + Errors) * 100
Note: This analysis was assisted by AI and should be verified against the full RFC specification.
Solution
This PR corrects the mathematical formula for both error and discard percentage calculations by including the errors/discards in the denominator.
Related Issue
This fix addresses issue #307 opened by @andytlc68, who independently identified the same problem and proposed an identical solution. The issue already has community support with additional users confirming the problem, indicating this affects at least 3+ users in different environments.
Testing
Disclaimer and Considerations
This fix modifies a core component of the plugin. While I've implemented this to the best of my knowledge and successfully tested it in our customer environment, I cannot provide absolute guarantee of correctness due to several considerations:
Potential Side Effects: This change affects core interface calculations and may have implications for other parts of the plugin that weren't immediately apparent.
Scope Limitation: I've only been able to verify this issue with error rates, but applied the same fix to discard calculations based on logical consistency.
Calculation Precision: The new calculation may still have edge cases or imprecision issues (e.g., lack of distinction between unicast/broadcast/multicast traffic).
Vendor Implementation: It's possible that only certain vendors incorrectly implement the SNMP specification, and this change might affect others differently.
Recommendation: Please conduct thorough testing across different network equipment vendors and gather community feedback before merging this PR.
Fixes #307