From f452e3bc80291c484ed907d38eb06d3c7fa18d5b Mon Sep 17 00:00:00 2001 From: FoxTrot75 Date: Tue, 19 Aug 2025 10:52:25 +0300 Subject: [PATCH] Add support new metrics: endurance, verify errors Signed-off-by: FoxTrot75 --- metrics.go | 40 ++++++++++++++++++++++++++++++++++++++++ smartctl.go | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/metrics.go b/metrics.go index 0ac083f..fa488b7 100644 --- a/metrics.go +++ b/metrics.go @@ -290,6 +290,14 @@ var ( }, nil, ) + metricSCSIUsedEnduranceIndicator = prometheus.NewDesc( + "smartctl_scsi_percentage_used_endurance_indicator", + "Device SCSI percentage used endurance indicator", + []string{ + "device", + }, + nil, + ) metricReadErrorsCorrectedByRereadsRewrites = prometheus.NewDesc( "smartctl_read_errors_corrected_by_rereads_rewrites", "Read Errors Corrected by ReReads/ReWrites", @@ -354,4 +362,36 @@ var ( }, nil, ) + metricVerifyErrorsCorrectedByRereadsRewrites = prometheus.NewDesc( + "smartctl_verify_errors_corrected_by_rereads_rewrites", + "Verify Errors Corrected by ReReads/ReWrites", + []string{ + "device", + }, + nil, + ) + metricVerifyErrorsCorrectedByEccFast = prometheus.NewDesc( + "smartctl_verify_errors_corrected_by_eccfast", + "Verify Errors Corrected by ECC Fast", + []string{ + "device", + }, + nil, + ) + metricVerifyErrorsCorrectedByEccDelayed = prometheus.NewDesc( + "smartctl_verify_errors_corrected_by_eccdelayed", + "Verify Errors Corrected by ECC Delayed", + []string{ + "device", + }, + nil, + ) + metricVerifyTotalUncorrectedErrors = prometheus.NewDesc( + "smartctl_verify_total_uncorrected_errors", + "Verify Total Uncorrected Errors", + []string{ + "device", + }, + nil, + ) ) diff --git a/smartctl.go b/smartctl.go index b136b8b..0d644b8 100644 --- a/smartctl.go +++ b/smartctl.go @@ -114,6 +114,7 @@ func (smart *SMARTctl) Collect() { } // SCSI, SAS if smart.device.interface_ == "scsi" { + smart.mineSCSIUsedEnduranceIndicator() smart.mineSCSIGrownDefectList() smart.mineSCSIErrorCounterLog() smart.mineSCSIBytesRead() @@ -586,6 +587,18 @@ func (smart *SMARTctl) mineSCSIGrownDefectList() { } } +func (smart *SMARTctl) mineSCSIUsedEnduranceIndicator() { + scsi_percentage_used_endurance_indicator := smart.json.Get("scsi_percentage_used_endurance_indicator") + if scsi_percentage_used_endurance_indicator.Exists() { + smart.ch <- prometheus.MustNewConstMetric( + metricSCSIUsedEnduranceIndicator, + prometheus.GaugeValue, + scsi_percentage_used_endurance_indicator.Float(), + smart.device.device, + ) + } +} + func (smart *SMARTctl) mineSCSIErrorCounterLog() { SCSIHealth := smart.json.Get("scsi_error_counter_log") if SCSIHealth.Exists() { @@ -637,6 +650,29 @@ func (smart *SMARTctl) mineSCSIErrorCounterLog() { SCSIHealth.Get("write.total_uncorrected_errors").Float(), smart.device.device, ) - // TODO: Should we also export the verify category? + smart.ch <- prometheus.MustNewConstMetric( + metricVerifyErrorsCorrectedByRereadsRewrites, + prometheus.GaugeValue, + SCSIHealth.Get("verify.errors_corrected_by_rereads_rewrites").Float(), + smart.device.device, + ) + smart.ch <- prometheus.MustNewConstMetric( + metricVerifyErrorsCorrectedByEccFast, + prometheus.GaugeValue, + SCSIHealth.Get("verify.errors_corrected_by_eccfast").Float(), + smart.device.device, + ) + smart.ch <- prometheus.MustNewConstMetric( + metricVerifyErrorsCorrectedByEccDelayed, + prometheus.GaugeValue, + SCSIHealth.Get("verify.errors_corrected_by_eccdelayed").Float(), + smart.device.device, + ) + smart.ch <- prometheus.MustNewConstMetric( + metricVerifyTotalUncorrectedErrors, + prometheus.GaugeValue, + SCSIHealth.Get("verify.total_uncorrected_errors").Float(), + smart.device.device, + ) } }