Ignore bit 6 in smartctl exit-code during detect #794
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.
The return value of
smartctl
is a bitmask, and bit 6 being set signifies the presence of entries in the SMART error log. Therefore, an exit code of 64 does not necessarily mean the disk is in imminent failure, but it does indicate that past issues have occurred and are logged within the drive's SMART data.This patch ignores that bit from the exit code of smartctl, during detection, allowing the collector to continue working with that drive.
Note: Masking with
0xBF
(AKA0b10111111
, AKA 191) ignores bit 6. That trick comes from here.Tested with:
Result with this fix:
Without this patch, the collector was NOT sending anything to the scrutiny frontend, resulting in drives appearing red, since no data has been received for more than a month. Here's the log I have, for the same test with the original code: