Track NVMe unsafe shutdowns and flag controller resets#1
Merged
Conversation
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.
Adds the NVMe
unsafe_shutdownslifetime counter as a tracked metric and a live recommendation that flags it climbing without a reboot.Tracking
The counter is parsed from the smartctl NVMe health log (
nvme_smart_health_information_log.unsafe_shutdowns), with SATA power-loss attribute fallbacks for non-NVMe drives. It is aggregated per device and logged to CSV as two columns:smart_unsafe_shutdowns_total(scalar aggregate) andsmart_unsafe_shutdowns(per-disk string, e.g.nvme0:44,nvme2:0). The dual representation mirrors the existingdisk_temp_max/disk_tempsconvention, keeping which-drive detail in the log alongside a scalar to scan. The total also shows in the TUI Temps/Sys panel.The fields stay
Noneunless at least one disk actually reports the counter, so a SATA-only host does not log a misleading0.Detection
build_recommendationsis a new history-aware entry point that combines the existing single-snapshot checks with checks that need more than one sample.generate_recommendationsis unchanged, so its tests stay valid.unsafe_shutdown_recommendationflags the counter rising while the host stays up. The baseline is taken from the start of the current uninterrupted uptime run, found by walking back through the in-memory history until uptime drops (a reboot boundary). Any increment that coincides with a real reboot or power loss is therefore excluded, and only the controller-reset-on-bus signature is reported. When it fires:Tests
Adds parsing of the NVMe health log field, per-device aggregation, and four detection cases: flat counter stays quiet, a rise with monotonic uptime fires, a rise across an uptime reset is ignored, and
build_recommendationssurfaces the finding end to end. Full suite is 54 passing, fmt and clippy-Dwarningsclean.