Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Sensor Warnings for non-numeric comparison #317

Closed
wants to merge 0 commits into from

Conversation

arnotron
Copy link
Contributor

Hello,
we encountered the same problem referenced in #310 - With check_nwc_health version 10.0 the error looks as follows:

Argument "ON" isn't numeric in numeric eq (==) at /usr/lib64/nagios/plugins/check_nwc_health line 71087.
Argument "LOST" isn't numeric in numeric eq (==) at /usr/lib64/nagios/plugins/check_nwc_health line 71087.
CRITICAL - sensor PSU [2] alarm status is true | 'sensor_PSU [1] '=0;;;; 'sensor_PSU [2] '=0;;;;

Unfortunately, even after applying the fix from dcec checking the value for being actually "-1" in string comparison before doing a numeric eq, I received another error:

Argument "ON" isn't numeric in sprintf at ./check_nwc_health.new line 514.
Argument "LOST" isn't numeric in sprintf at ./check_nwc_health.new line 514.
CRITICAL - sensor PSU [2] alarm status is true | 'sensor_PSU [1] '=0;;;; 'sensor_PSU [2] '=0;;;;

So I dusted off my perl skills and tried to fix that, too, by sending perfdata only if the value is numeric. Please let me know if this is sufficient and the proper way to do it.

Copy link

codeautopilot bot commented Sep 23, 2024

PR summary

This Pull Request addresses a bug in the check_nwc_health plugin where non-numeric sensor values such as "ON" and "LOST" were causing errors during numeric comparisons and formatting. The fix involves adding checks to ensure that only numeric values are processed in numeric comparisons and performance data output. This should resolve the errors and improve the stability of the plugin when handling non-numeric sensor values.

Suggestion

Consider adding unit tests to verify that non-numeric values are handled correctly and do not cause errors in future updates. This will help ensure the robustness of the fix.

Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect.

Current plan usage: 75.15%

Have feedback or need help?
Discord
Documentation
[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant