Fix/status and exit code handling - #121
Open
arekm wants to merge 4 commits into
Open
Conversation
escalate_status() guarded against downgrades with ($exit_status|$exit_status_local), which is a bitwise string OR, not a logical one: 'CRITICAL'|'OK' is 'O[ITICAL', so the guard only ever matched while both variables were already equal. Under -g the per-device variable is reset for every disk, so a WARNING on a later disk silently overwrote a CRITICAL from an earlier one and the plugin exited 1 instead of 2. Rank the statuses and raise each variable only when the new one is worse. This also keeps the per-device status correct when the global status is already higher.
…e bits system() sets $? to the wait status, so the exit code is $? >> 8. Testing $? & 0x01 .. 0x80 inspects the low byte, which is 0 for every normal exit, so none of the exit status checks could ever fire. Shifting alone would make a smartctl killed by a signal look like a clean run, so handle abnormal termination explicitly and report it as UNKNOWN.
The flag suppressed the ATA Error Count check on the attribute output but not bit 6 of smartctl's exit status, which reports the same condition.
Bit 2 is "Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure", and in practice it is usually the former: an optional command the drive or controller does not support. Calling it a checksum failure sends the operator after the wrong problem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
escalate_status()used a bitwise string OR as its downgrade guard(
'CRITICAL'|'OK'is'O[ITICAL'), so under-ga later disk's WARNINGoverwrote an earlier disk's CRITICAL. Statuses are now ranked.
$?is the wait status, so the exit code is$? >> 8; every$? & 0x01..0x80test read the low byte and could never fire. Signaldeath now reports UNKNOWN instead of looking clean.
--skip-error-lognow also covers exit status bit 6.former —
Checksum failurepoints at the wrong problem.