From e8764b802a2e826eae560de9fea7d848a665ab82 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Sat, 3 Oct 2026 12:49:36 +0800 Subject: [PATCH] fix(overlays): backport smartctl_exporter Describe fix (upstream #329) smartctl_exporter 0.14.0 derives Describe() from the devices it can read at startup. A device that only becomes readable later (an NVMe whose ACL arrives late, or an HDD waking from standby) then makes Collect() emit metrics with unregistered descriptors, so /metrics returns HTTP 500 and the whole scrape fails, hiding even the healthy disks. Backport upstream PR #329, which makes Describe() send the full explicit descriptor set. Carry it as an overlay until smartctl_exporter 0.15.0 is released and packaged in nixpkgs. Refs: https://github.com/prometheus-community/smartctl_exporter/pull/329 --- overlays/README.md | 6 +++ .../329-explicit-descriptors.patch | 50 +++++++++++++++++++ overlays/smartctl-exporter/default.nix | 15 ++++++ 3 files changed, 71 insertions(+) create mode 100644 overlays/smartctl-exporter/329-explicit-descriptors.patch create mode 100644 overlays/smartctl-exporter/default.nix diff --git a/overlays/README.md b/overlays/README.md index f410f62c..1b87f9d3 100644 --- a/overlays/README.md +++ b/overlays/README.md @@ -13,6 +13,9 @@ overlays/ ├── default.nix # Entrypoint for all overlays ├── computer-use-linux.nix # trycua/computer-use-linux package ├── cua-driver.nix # trycua/cua driver (cua-driver) package +├── smartctl-exporter/ # smartctl_exporter backport (upstream PR #329) +│ ├── default.nix +│ └── 329-explicit-descriptors.patch └── fcitx5/ # Chinese input method configuration ├── README.md ├── default.nix # fcitx5 overlay definition @@ -55,3 +58,6 @@ This overlay provides: - `computer-use-linux.nix`: packages `pkgs/computer-use-linux`. - `cua-driver.nix`: packages `pkgs/cua-driver` (used by the computer-use VMs). +- `smartctl-exporter/`: patches `prometheus-smartctl-exporter` with upstream PR + [#329](https://github.com/prometheus-community/smartctl_exporter/pull/329) until smartctl_exporter + 0.15.0 is released; see `overlays/smartctl-exporter/default.nix`. diff --git a/overlays/smartctl-exporter/329-explicit-descriptors.patch b/overlays/smartctl-exporter/329-explicit-descriptors.patch new file mode 100644 index 00000000..6fdeb6c8 --- /dev/null +++ b/overlays/smartctl-exporter/329-explicit-descriptors.patch @@ -0,0 +1,50 @@ +diff --git a/main.go b/main.go +index c5b138a..05a222e 100644 +--- a/main.go ++++ b/main.go +@@ -57,7 +57,44 @@ type SMARTctlManagerCollector struct { + + // Describe sends the super-set of all possible descriptors of metrics + func (i *SMARTctlManagerCollector) Describe(ch chan<- *prometheus.Desc) { +- prometheus.DescribeByCollect(i, ch) ++ ch <- metricSmartctlVersion ++ ch <- metricDeviceModel ++ ch <- metricDeviceCount ++ ch <- metricDeviceCapacityBlocks ++ ch <- metricDeviceCapacityBytes ++ ch <- metricDeviceTotalCapacityBytes ++ ch <- metricDeviceBlockSize ++ ch <- metricDeviceInterfaceSpeed ++ ch <- metricDeviceAttribute ++ ch <- metricDevicePowerOnSeconds ++ ch <- metricDeviceRotationRate ++ ch <- metricDeviceTemperature ++ ch <- metricDevicePowerCycleCount ++ ch <- metricDevicePercentageUsed ++ ch <- metricDeviceAvailableSpare ++ ch <- metricDeviceAvailableSpareThreshold ++ ch <- metricDeviceCriticalWarning ++ ch <- metricDeviceMediaErrors ++ ch <- metricDeviceNumErrLogEntries ++ ch <- metricDeviceBytesRead ++ ch <- metricDeviceBytesWritten ++ ch <- metricDeviceSmartStatus ++ ch <- metricDeviceExitStatus ++ ch <- metricDeviceState ++ ch <- metricDeviceStatistics ++ ch <- metricDeviceErrorLogCount ++ ch <- metricDeviceSelfTestLogCount ++ ch <- metricDeviceSelfTestLogErrorCount ++ ch <- metricDeviceERCSeconds ++ ch <- metricSCSIGrownDefectList ++ ch <- metricReadErrorsCorrectedByRereadsRewrites ++ ch <- metricReadErrorsCorrectedByEccFast ++ ch <- metricReadErrorsCorrectedByEccDelayed ++ ch <- metricReadTotalUncorrectedErrors ++ ch <- metricWriteErrorsCorrectedByRereadsRewrites ++ ch <- metricWriteErrorsCorrectedByEccFast ++ ch <- metricWriteErrorsCorrectedByEccDelayed ++ ch <- metricWriteTotalUncorrectedErrors + } + + // Collect is called by the Prometheus registry when collecting metrics. diff --git a/overlays/smartctl-exporter/default.nix b/overlays/smartctl-exporter/default.nix new file mode 100644 index 00000000..3eb42568 --- /dev/null +++ b/overlays/smartctl-exporter/default.nix @@ -0,0 +1,15 @@ +# smartctl_exporter 0.14.0 derives `Describe()` from the devices it can read at +# startup, so when a device only becomes readable later (an NVMe whose ACL +# arrives late, or an HDD waking from standby) `Collect()` emits metrics whose +# descriptors were never registered and `/metrics` starts returning HTTP 500, +# which fails the whole scrape and hides even the healthy disks. +# +# Backport of upstream PR #329: `Describe()` now sends the full, explicit +# descriptor set. Drop this overlay once smartctl_exporter 0.15.0 is released +# and packaged in nixpkgs: +# https://github.com/prometheus-community/smartctl_exporter/pull/329 +_: _final: prev: { + prometheus-smartctl-exporter = prev.prometheus-smartctl-exporter.overrideAttrs (prevAttrs: { + patches = (prevAttrs.patches or [ ]) ++ [ ./329-explicit-descriptors.patch ]; + }); +}