Repository navigation
Conversation
smartctl can print the SATA Phy Event Counters log (GP log 0x11), whose link-level counters (ICRC errors, COMRESETs, CRC errors in host-to-device FISes, ...) help to tell failing cables, backplanes and HBAs from failing disks. smartctl is only asked for it with --log=sataphy, which the exporter never passed (see prometheus-community#92 about logs smartctl is not asked for). Add --smartctl.sata-phy-log (default false). When set, --log=sataphy is appended to the smartctl arguments before --device, and the counters are exported for ATA devices as smartctl_device_sata_phy_events_total, a counter labelled with device, id (the decimal counter id) and event (smartctl's name for it). It is opt-in because it costs an extra log read per ATA device and poll. prometheus-community#410 (ATA SSD device statistics with --log=devstat,7) is orthogonal and follows the same opt-in pattern. The code that exported these counters through smartctl_device_statistics never ran, as nothing requested the log, so no such series ever existed and it is replaced rather than kept. It labelled counters by name only, but smartctl names every vendor specific counter "Vendor specific" and every unlisted id "Unknown". A drive reporting two of them would produce duplicate label sets, which fail Gather() and turn the whole scrape into an HTTP 500. The new metric adds the id label to keep series unique, and skips a repeated id. A counter that smartctl flags as overflowed has reached its maximum and stays there; its value is still exported and the metric help says so. Facts checked in smartmontools 7.0 to 7.5: the JSON output, and with it sata_phy_event_counters, exists since 7.0. Whether the log is available comes from the drive's IDENTIFY data: unless the GP log directory has been read (the exporter does not request it), smartctl proceeds only if IDENTIFY word 76 reports phy event counter support. Otherwise it prints "SATA Phy Event Counters (GP Log 0x11) not supported" and sets no exit status bit; the option is ignored for SCSI and NVMe devices. Only a failed read of the log sets bit 2 of the exit status, which the exporter logs as a warning and reports in smartctl_device_smartctl_exit_status. Tests cover the rendering of a real smartctl 7.4 capture of a SATA hard disk, duplicate "Vendor specific"/"Unknown" names and ids, the ATA-only gate in Collect(), the descriptor being sent by Describe(), and the smartctl argument wiring using a fake smartctl. go.mod gains the indirect godebug dependency required by prometheus/testutil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
jhoblitt
marked this pull request as ready for review
November 30, 2026 23:10
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.
Motivation
SATA link CRC/COMRESET errors point at cables, backplanes and HBAs rather than media, and the drive records them in the SATA Phy Event Counters log. The collector already parsed that log, but smartctl was never asked for it (one of the logs in #92).
What changed
Opt-in
--smartctl.sata-phy-logpasses--log=sataphy, exported assmartctl_device_sata_phy_events_total{device,id,event}for ATA devices.Notable decisions
A dedicated counter replaces the never-reachable
smartctl_device_statisticsrows: smartctl names every vendor-specific counter identically, so only theidlabel keeps series unique. Orthogonal to #410.This PR was prepared with an AI coding assistant (Claude Code) at my direction; I own it.