Do not export smart_status if object is not present

Signed-off-by: Deezzir <deezzir@gmail.com>
This commit is contained in:
Deezzir 2024-12-19 21:13:06 -05:00
parent 7489f4f7aa
commit 2c2b4aa970
No known key found for this signature in database
GPG key ID: BC9F5289FAC4E96A

View file

@ -468,12 +468,16 @@ func (smart *SMARTctl) mineSCSIBytesWritten() {
} }
func (smart *SMARTctl) mineSmartStatus() { func (smart *SMARTctl) mineSmartStatus() {
smart.ch <- prometheus.MustNewConstMetric( passed_raw := smart.json.Get("smart_status.passed")
metricDeviceSmartStatus,
prometheus.GaugeValue, if passed_raw.Exists() {
smart.json.Get("smart_status.passed").Float(), smart.ch <- prometheus.MustNewConstMetric(
smart.device.device, metricDeviceSmartStatus,
) prometheus.GaugeValue,
passed_raw.Float(),
smart.device.device,
)
}
} }
func (smart *SMARTctl) mineDeviceStatistics() { func (smart *SMARTctl) mineDeviceStatistics() {