Add a new metric smartctl_device_error_log_count for the SMART error log counts.

This commit is contained in:
Octavian Cerna 2020-07-26 23:48:49 +03:00
parent e8d95208d7
commit 3e17706839
2 changed files with 28 additions and 0 deletions

View File

@ -188,4 +188,16 @@ var (
},
nil,
)
metricDeviceErrorLogCount = prometheus.NewDesc(
"smartctl_device_error_log_count",
"Device SMART error log count",
[]string{
"device",
"model_family",
"model_name",
"serial_number",
"error_log_type",
},
nil,
)
)

View File

@ -52,6 +52,7 @@ func (smart *SMARTctl) Collect() {
smart.mineDeviceSCTStatus()
smart.mineDeviceStatistics()
smart.mineDeviceStatus()
smart.mineDeviceErrorLog()
}
func (smart *SMARTctl) mineExitStatus() {
@ -312,3 +313,18 @@ func (smart *SMARTctl) mineDeviceStatus() {
smart.device.serial,
)
}
func (smart *SMARTctl) mineDeviceErrorLog() {
for logType, status := range smart.json.Get("ata_smart_error_log").Map() {
smart.ch <- prometheus.MustNewConstMetric(
metricDeviceErrorLogCount,
prometheus.GaugeValue,
status.Get("count").Float(),
smart.device.device,
smart.device.family,
smart.device.model,
smart.device.serial,
logType,
)
}
}