diff --git a/metrics.go b/metrics.go index fd694b7..5edbcc9 100644 --- a/metrics.go +++ b/metrics.go @@ -224,4 +224,16 @@ var ( }, nil, ) + metricDeviceERCSeconds = prometheus.NewDesc( + "smartctl_device_erc_seconds", + "Device SMART Error Recovery Control Seconds", + []string{ + "device", + "model_family", + "model_name", + "serial_number", + "op_type", + }, + nil, + ) ) diff --git a/smartctl.go b/smartctl.go index d8aab2d..96eee23 100644 --- a/smartctl.go +++ b/smartctl.go @@ -54,6 +54,7 @@ func (smart *SMARTctl) Collect() { smart.mineDeviceStatus() smart.mineDeviceErrorLog() smart.mineDeviceSelfTestLog() + smart.mineDeviceERC() } func (smart *SMARTctl) mineExitStatus() { @@ -354,3 +355,18 @@ func (smart *SMARTctl) mineDeviceSelfTestLog() { ) } } + +func (smart *SMARTctl) mineDeviceERC() { + for ercType, status := range smart.json.Get("ata_sct_erc").Map() { + smart.ch <- prometheus.MustNewConstMetric( + metricDeviceERCSeconds, + prometheus.GaugeValue, + status.Get("deciseconds").Float()/10.0, + smart.device.device, + smart.device.family, + smart.device.model, + smart.device.serial, + ercType, + ) + } +}