Skip to content

Commit 3b44c59

Browse files
committed
Add support new metrics: endurance, verify errors
1 parent ef5c03d commit 3b44c59

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

metrics.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ var (
290290
},
291291
nil,
292292
)
293+
metricSCSIUsedEnduranceIndicator = prometheus.NewDesc(
294+
"smartctl_scsi_percentage_used_endurance_indicator",
295+
"Device SCSI percentage used endurance indicator",
296+
[]string{
297+
"device",
298+
},
299+
nil,
300+
)
293301
metricReadErrorsCorrectedByRereadsRewrites = prometheus.NewDesc(
294302
"smartctl_read_errors_corrected_by_rereads_rewrites",
295303
"Read Errors Corrected by ReReads/ReWrites",
@@ -354,4 +362,36 @@ var (
354362
},
355363
nil,
356364
)
365+
metricVerifyErrorsCorrectedByRereadsRewrites = prometheus.NewDesc(
366+
"smartctl_verify_errors_corrected_by_rereads_rewrites",
367+
"Verify Errors Corrected by ReReads/ReWrites",
368+
[]string{
369+
"device",
370+
},
371+
nil,
372+
)
373+
metricVerifyErrorsCorrectedByEccFast = prometheus.NewDesc(
374+
"smartctl_verify_errors_corrected_by_eccfast",
375+
"Verify Errors Corrected by ECC Fast",
376+
[]string{
377+
"device",
378+
},
379+
nil,
380+
)
381+
metricVerifyErrorsCorrectedByEccDelayed = prometheus.NewDesc(
382+
"smartctl_verify_errors_corrected_by_eccdelayed",
383+
"Verify Errors Corrected by ECC Delayed",
384+
[]string{
385+
"device",
386+
},
387+
nil,
388+
)
389+
metricVerifyTotalUncorrectedErrors = prometheus.NewDesc(
390+
"smartctl_verify_total_uncorrected_errors",
391+
"Verify Total Uncorrected Errors",
392+
[]string{
393+
"device",
394+
},
395+
nil,
396+
)
357397
)

smartctl.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func (smart *SMARTctl) Collect() {
114114
}
115115
// SCSI, SAS
116116
if smart.device.interface_ == "scsi" {
117+
smart.mineSCSIUsedEnduranceIndicator()
117118
smart.mineSCSIGrownDefectList()
118119
smart.mineSCSIErrorCounterLog()
119120
smart.mineSCSIBytesRead()
@@ -586,6 +587,18 @@ func (smart *SMARTctl) mineSCSIGrownDefectList() {
586587
}
587588
}
588589

590+
func (smart *SMARTctl) mineSCSIUsedEnduranceIndicator() {
591+
scsi_percentage_used_endurance_indicator := smart.json.Get("scsi_percentage_used_endurance_indicator")
592+
if scsi_percentage_used_endurance_indicator.Exists() {
593+
smart.ch <- prometheus.MustNewConstMetric(
594+
metricSCSIUsedEnduranceIndicator,
595+
prometheus.GaugeValue,
596+
scsi_percentage_used_endurance_indicator.Float(),
597+
smart.device.device,
598+
)
599+
}
600+
}
601+
589602
func (smart *SMARTctl) mineSCSIErrorCounterLog() {
590603
SCSIHealth := smart.json.Get("scsi_error_counter_log")
591604
if SCSIHealth.Exists() {
@@ -637,6 +650,29 @@ func (smart *SMARTctl) mineSCSIErrorCounterLog() {
637650
SCSIHealth.Get("write.total_uncorrected_errors").Float(),
638651
smart.device.device,
639652
)
640-
// TODO: Should we also export the verify category?
653+
smart.ch <- prometheus.MustNewConstMetric(
654+
metricVerifyErrorsCorrectedByRereadsRewrites,
655+
prometheus.GaugeValue,
656+
SCSIHealth.Get("verify.errors_corrected_by_rereads_rewrites").Float(),
657+
smart.device.device,
658+
)
659+
smart.ch <- prometheus.MustNewConstMetric(
660+
metricVerifyErrorsCorrectedByEccFast,
661+
prometheus.GaugeValue,
662+
SCSIHealth.Get("verify.errors_corrected_by_eccfast").Float(),
663+
smart.device.device,
664+
)
665+
smart.ch <- prometheus.MustNewConstMetric(
666+
metricVerifyErrorsCorrectedByEccDelayed,
667+
prometheus.GaugeValue,
668+
SCSIHealth.Get("verify.errors_corrected_by_eccdelayed").Float(),
669+
smart.device.device,
670+
)
671+
smart.ch <- prometheus.MustNewConstMetric(
672+
metricVerifyTotalUncorrectedErrors,
673+
prometheus.GaugeValue,
674+
SCSIHealth.Get("verify.total_uncorrected_errors").Float(),
675+
smart.device.device,
676+
)
641677
}
642678
}

0 commit comments

Comments
 (0)