Key SMART history and metrics by drive serial/WWN, not device path #41

Open
opened 2026-11-24 01:08:51 -05:00 by jared · 0 comments
Owner

Problem

SMART trend history is stored per device path (/var/log/hwmonDaemon/smart_history__dev_sdX.json, see _analyze_smart_trends). Linux device names are not stable: they reshuffle at boot and change on hot-plug, so one file collects several physical drives and trend checks compare unrelated disks.

Evidence (compute-storage-01, checked 2026-11-24)

smart_history__dev_sdf.json (717 entries) holds three different drives:

Period Drive Power-on hours
2026-10-25 some other disk that was sdf before a reboot ~13.2k
2026-10-28 → 11-15 WD RE4 1TB, S/N WD-WCAW37306731 (osd.30, removed) ~53k
2026-11-16 → now Seagate SkyHawk 3TB, S/N ZTT3Y6JM (osd.18) ~15k

On the same day osd.7's 16TB disk (S/N ZL2L59XD) dropped off the HBA and re-enumerated as sdk: smart_history__dev_sda.json stopped on 11-15, and sdk started a fresh file with no history.

smartd had the same path-keyed problem: it sent a false daily "Failed SMART usage Attribute: 5 Reallocated_Sector_Ct" alert for the removed RE4, because it was comparing the new Seagate's values against the WD's cached thresholds.

Proposal

  1. Identity key: use the WWN (smartctl -j → wwn), falling back to model + serial when there's no WWN. Resolve the device path to an identity on every run.
  2. History files: name them smart_history_<key>.json. Store model, serial, wwn, and the last-seen host/device inside each entry.
  3. Migration: on first run, split each existing path-keyed file wherever the drive identity changes. Use Power_On_Hours going backwards, or a change in the attribute set, as the split signal, since old entries have no serial. Archive anything that can't be split cleanly; don't merge it.
  4. Prometheus labels: add serial, wwn and model labels to hwmon_drive_*, and keep device as an informational label.
  5. Drive-change detection: log it when a known serial disappears from a host, or a new serial appears. That's the signal for "drive removed/replaced" (and for future HomeBox sync, #27).
  6. Prometheus export: turn it on and get it scraped. Right now Prometheus (10.10.10.48) has zero hwmon_* series, so grafana-dashboard.json has no data. Check PROMETHEUS_ENABLED / the textfile path on the nodes.

Acceptance

  • Moving a disk to a different /dev/sdX, or rebooting, keeps a single unbroken history for that drive.
  • Replacing a drive starts a new history; the removed drive's history is kept, not overwritten.
  • A test replays the compute-storage-01 sdf file and gets three separate per-drive histories.

Related

  • #27: HomeBox now stores serials (serialNumber) for drives, so serial is the shared lookup key that issue asks for.
  • #40: SMART stays in hwmonDaemon, since only the host can read it. thor consumes these serial-keyed metrics.
  • Worth watching once history is trustworthy: the SkyHawk's Power-Off_Retract_Count rose 3 → 11 in a week while Power_Cycle_Count stayed at 3. This is probably the power dips on that SATA power lead.
## Problem SMART trend history is stored per **device path** (`/var/log/hwmonDaemon/smart_history__dev_sdX.json`, see `_analyze_smart_trends`). Linux device names are not stable: they reshuffle at boot and change on hot-plug, so one file collects several physical drives and trend checks compare unrelated disks. ## Evidence (compute-storage-01, checked 2026-11-24) `smart_history__dev_sdf.json` (717 entries) holds **three different drives**: | Period | Drive | Power-on hours | |---|---|---| | 2026-10-25 | some other disk that was `sdf` before a reboot | ~13.2k | | 2026-10-28 → 11-15 | WD RE4 1TB, S/N WD-WCAW37306731 (osd.30, removed) | ~53k | | 2026-11-16 → now | Seagate SkyHawk 3TB, S/N ZTT3Y6JM (osd.18) | ~15k | On the same day osd.7's 16TB disk (S/N ZL2L59XD) dropped off the HBA and re-enumerated as `sdk`: `smart_history__dev_sda.json` stopped on 11-15, and `sdk` started a fresh file with no history. smartd had the same path-keyed problem: it sent a false daily "Failed SMART usage Attribute: 5 Reallocated_Sector_Ct" alert for the removed RE4, because it was comparing the new Seagate's values against the WD's cached thresholds. ## Proposal 1. **Identity key:** use the WWN (`smartctl -j` → `wwn`), falling back to `model + serial` when there's no WWN. Resolve the device path to an identity on every run. 2. **History files:** name them `smart_history_<key>.json`. Store `model`, `serial`, `wwn`, and the last-seen `host`/`device` inside each entry. 3. **Migration:** on first run, split each existing path-keyed file wherever the drive identity changes. Use `Power_On_Hours` going backwards, or a change in the attribute set, as the split signal, since old entries have no serial. Archive anything that can't be split cleanly; don't merge it. 4. **Prometheus labels:** add `serial`, `wwn` and `model` labels to `hwmon_drive_*`, and keep `device` as an informational label. 5. **Drive-change detection:** log it when a known serial disappears from a host, or a new serial appears. That's the signal for "drive removed/replaced" (and for future HomeBox sync, #27). 6. **Prometheus export:** turn it on and get it scraped. Right now Prometheus (10.10.10.48) has **zero `hwmon_*` series**, so `grafana-dashboard.json` has no data. Check `PROMETHEUS_ENABLED` / the textfile path on the nodes. ## Acceptance - Moving a disk to a different `/dev/sdX`, or rebooting, keeps a single unbroken history for that drive. - Replacing a drive starts a new history; the removed drive's history is kept, not overwritten. - A test replays the compute-storage-01 `sdf` file and gets three separate per-drive histories. ## Related - #27: HomeBox now stores serials (`serialNumber`) for drives, so serial is the shared lookup key that issue asks for. - #40: SMART stays in hwmonDaemon, since only the host can read it. thor consumes these serial-keyed metrics. - Worth watching once history is trustworthy: the SkyHawk's `Power-Off_Retract_Count` rose 3 → 11 in a week while `Power_Cycle_Count` stayed at 3. This is probably the power dips on that SATA power lead.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Reference: LotusGuild/hwmonDaemon#41