mirror of
https://github.com/prometheus-community/smartctl_exporter.git
synced 2024-11-23 01:43:07 +01:00
Add a new metric smartctl_device_status for the SMART health status.
This commit is contained in:
parent
81e49a31c3
commit
9e10465744
2 changed files with 25 additions and 0 deletions
11
metrics.go
11
metrics.go
|
@ -166,4 +166,15 @@ var (
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
metricDeviceStatus = prometheus.NewDesc(
|
||||||
|
"smartctl_device_status",
|
||||||
|
"Device status",
|
||||||
|
[]string{
|
||||||
|
"device",
|
||||||
|
"model_family",
|
||||||
|
"model_name",
|
||||||
|
"serial_number",
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
14
smartctl.go
14
smartctl.go
|
@ -50,6 +50,7 @@ func (smart *SMARTctl) Collect() {
|
||||||
smart.mineTemperatures()
|
smart.mineTemperatures()
|
||||||
smart.minePowerCycleCount()
|
smart.minePowerCycleCount()
|
||||||
smart.mineDeviceStatistics()
|
smart.mineDeviceStatistics()
|
||||||
|
smart.mineDeviceStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (smart *SMARTctl) mineExitStatus() {
|
func (smart *SMARTctl) mineExitStatus() {
|
||||||
|
@ -266,3 +267,16 @@ func (smart *SMARTctl) mineLongFlags(json gjson.Result, flags []string) string {
|
||||||
}
|
}
|
||||||
return strings.Join(result, ",")
|
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,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue