diff --git a/metrics.go b/metrics.go index f08298b..fd694b7 100644 --- a/metrics.go +++ b/metrics.go @@ -200,4 +200,28 @@ var ( }, nil, ) + metricDeviceSelfTestLogCount = prometheus.NewDesc( + "smartctl_device_self_test_log_count", + "Device SMART self test log count", + []string{ + "device", + "model_family", + "model_name", + "serial_number", + "self_test_log_type", + }, + nil, + ) + metricDeviceSelfTestLogErrorCount = prometheus.NewDesc( + "smartctl_device_self_test_log_error_count", + "Device SMART self test log error count", + []string{ + "device", + "model_family", + "model_name", + "serial_number", + "self_test_log_type", + }, + nil, + ) ) diff --git a/smartctl.go b/smartctl.go index 0958cf7..d8aab2d 100644 --- a/smartctl.go +++ b/smartctl.go @@ -53,6 +53,7 @@ func (smart *SMARTctl) Collect() { smart.mineDeviceStatistics() smart.mineDeviceStatus() smart.mineDeviceErrorLog() + smart.mineDeviceSelfTestLog() } func (smart *SMARTctl) mineExitStatus() { @@ -328,3 +329,28 @@ func (smart *SMARTctl) mineDeviceErrorLog() { ) } } + +func (smart *SMARTctl) mineDeviceSelfTestLog() { + for logType, status := range smart.json.Get("ata_smart_self_test_log").Map() { + smart.ch <- prometheus.MustNewConstMetric( + metricDeviceSelfTestLogCount, + prometheus.GaugeValue, + status.Get("count").Float(), + smart.device.device, + smart.device.family, + smart.device.model, + smart.device.serial, + logType, + ) + smart.ch <- prometheus.MustNewConstMetric( + metricDeviceSelfTestLogErrorCount, + prometheus.GaugeValue, + status.Get("error_count_total").Float(), + smart.device.device, + smart.device.family, + smart.device.model, + smart.device.serial, + logType, + ) + } +}