Ignore bit 6 in smartctl exit-code during detect#794
Open
gboudreau wants to merge 1 commit into
Open
Conversation
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` (`10111111`) ignores the bit 6.
Owner
|
can we re-use scrutiny/collector/pkg/collector/base.go Line 44 in 5f7e4a3 |
Starosdev
added a commit
to Starosdev/scrutiny
that referenced
this pull request
Nov 30, 2025
…tream PR AnalogJ#794) Smartctl exit code bit 6 indicates "Device error log contains records of errors" which is informational and doesn't mean the device info retrieval failed. This fix ignores bit 6 (masking with 0xBF) to prevent false failures during device detection when drives have historical errors logged. Origin: AnalogJ#794 Original author: @gboudreau
3 tasks
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.
The return value of
smartctlis 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: