mirror of
https://github.com/prometheus-community/smartctl_exporter.git
synced 2024-12-21 02:21:55 +01:00
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:
parent
3e17706839
commit
53399a5e73
2 changed files with 50 additions and 0 deletions
24
metrics.go
24
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,
|
||||
)
|
||||
)
|
||||
|
|
26
smartctl.go
26
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue