Add a new metric smartctl_device_status for the SMART health status.

This commit is contained in:
Octavian Cerna 2020-07-26 22:31:04 +03:00
parent 81e49a31c3
commit 9e10465744
2 changed files with 25 additions and 0 deletions

View file

@ -166,4 +166,15 @@ var (
},
nil,
)
metricDeviceStatus = prometheus.NewDesc(
"smartctl_device_status",
"Device status",
[]string{
"device",
"model_family",
"model_name",
"serial_number",
},
nil,
)
)

View file

@ -50,6 +50,7 @@ func (smart *SMARTctl) Collect() {
smart.mineTemperatures()
smart.minePowerCycleCount()
smart.mineDeviceStatistics()
smart.mineDeviceStatus()
}
func (smart *SMARTctl) mineExitStatus() {
@ -266,3 +267,16 @@ func (smart *SMARTctl) mineLongFlags(json gjson.Result, flags []string) string {
}
return strings.Join(result, ",")
}
func (smart *SMARTctl) mineDeviceStatus() {
status := smart.json.Get("smart_status")
smart.ch <- prometheus.MustNewConstMetric(
metricDeviceStatus,
prometheus.GaugeValue,
status.Get("passed").Float(),
smart.device.device,
smart.device.family,
smart.device.model,
smart.device.serial,
)
}