Add a new metrics smartctl_device_self_test_log_count and smartctl_device_self_test_log_error_count for the device SMART Self-Test Logs.

This commit is contained in:
Octavian Cerna 2020-07-27 00:16:08 +03:00
parent 3e17706839
commit 53399a5e73
2 changed files with 50 additions and 0 deletions

View file

@ -200,4 +200,28 @@ var (
}, },
nil, 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,
)
) )

View file

@ -53,6 +53,7 @@ func (smart *SMARTctl) Collect() {
smart.mineDeviceStatistics() smart.mineDeviceStatistics()
smart.mineDeviceStatus() smart.mineDeviceStatus()
smart.mineDeviceErrorLog() smart.mineDeviceErrorLog()
smart.mineDeviceSelfTestLog()
} }
func (smart *SMARTctl) mineExitStatus() { 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,
)
}
}