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_state for the device state from ATA SCT.
This commit is contained in:
parent
9e10465744
commit
3feff84fbb
2 changed files with 27 additions and 0 deletions
11
metrics.go
11
metrics.go
|
@ -151,6 +151,17 @@ var (
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
metricDeviceState = prometheus.NewDesc(
|
||||||
|
"smartctl_device_state",
|
||||||
|
"Device state (0=active, 1=standby, 2=sleep, 3=dst, 4=offline, 5=sct)",
|
||||||
|
[]string{
|
||||||
|
"device",
|
||||||
|
"model_family",
|
||||||
|
"model_name",
|
||||||
|
"serial_number",
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
metricDeviceStatistics = prometheus.NewDesc(
|
metricDeviceStatistics = prometheus.NewDesc(
|
||||||
"smartctl_device_statistics",
|
"smartctl_device_statistics",
|
||||||
"Device statistics",
|
"Device statistics",
|
||||||
|
|
16
smartctl.go
16
smartctl.go
|
@ -49,6 +49,7 @@ func (smart *SMARTctl) Collect() {
|
||||||
smart.mineRotationRate()
|
smart.mineRotationRate()
|
||||||
smart.mineTemperatures()
|
smart.mineTemperatures()
|
||||||
smart.minePowerCycleCount()
|
smart.minePowerCycleCount()
|
||||||
|
smart.mineDeviceSCTStatus()
|
||||||
smart.mineDeviceStatistics()
|
smart.mineDeviceStatistics()
|
||||||
smart.mineDeviceStatus()
|
smart.mineDeviceStatus()
|
||||||
}
|
}
|
||||||
|
@ -231,6 +232,21 @@ func (smart *SMARTctl) minePowerCycleCount() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (smart *SMARTctl) mineDeviceSCTStatus() {
|
||||||
|
status := smart.json.Get("ata_sct_status")
|
||||||
|
if status.Exists() {
|
||||||
|
smart.ch <- prometheus.MustNewConstMetric(
|
||||||
|
metricDeviceState,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
status.Get("device_state").Float(),
|
||||||
|
smart.device.device,
|
||||||
|
smart.device.family,
|
||||||
|
smart.device.model,
|
||||||
|
smart.device.serial,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (smart *SMARTctl) mineDeviceStatistics() {
|
func (smart *SMARTctl) mineDeviceStatistics() {
|
||||||
for _, page := range smart.json.Get("ata_device_statistics.pages").Array() {
|
for _, page := range smart.json.Get("ata_device_statistics.pages").Array() {
|
||||||
table := strings.TrimSpace(page.Get("name").String())
|
table := strings.TrimSpace(page.Get("name").String())
|
||||||
|
|
Loading…
Reference in a new issue