Remove useless error message

All errors are already logged from the called functions: readSMARTctl,
resultCodeIsOk, jsonIsOk. Logging twice due to the same error is useless
and the "smartctl returned bad data for device" message is confusing
since that condition may happen when a device is in a low-power mode.

Signed-off-by: Jakub Klinkovský <j.l.k@gmx.com>
This commit is contained in:
Jakub Klinkovský 2022-11-04 19:42:36 +01:00
parent 97947b0e27
commit 6e2143ca62
2 changed files with 7 additions and 8 deletions

View File

@ -49,12 +49,11 @@ func (i SMARTctlManagerCollector) Describe(ch chan<- *prometheus.Desc) {
func (i SMARTctlManagerCollector) Collect(ch chan<- prometheus.Metric) {
info := NewSMARTctlInfo(ch)
for _, device := range i.Devices {
if json, err := readData(i.logger, device); err == nil {
json := readData(i.logger, device)
if json.Exists() {
info.SetJSON(json)
smart := NewSMARTctl(i.logger, json, ch)
smart.Collect()
} else {
level.Error(i.logger).Log("msg", "Error collecting SMART data", "err", err.Error())
}
}
info.Collect()

View File

@ -89,9 +89,9 @@ func readSMARTctlDevices(logger log.Logger) gjson.Result {
}
// Select json source and parse
func readData(logger log.Logger, device string) (gjson.Result, error) {
func readData(logger log.Logger, device string) gjson.Result {
if *smartctlFakeData {
return readFakeSMARTctl(logger, device), nil
return readFakeSMARTctl(logger, device)
}
cacheValue, cacheOk := jsonCache.Load(device)
@ -103,11 +103,11 @@ func readData(logger log.Logger, device string) (gjson.Result, error) {
if !found {
level.Warn(logger).Log("msg", "device not found", "device", device)
}
return j.(JSONCache).JSON, nil
return j.(JSONCache).JSON
}
return gjson.Parse("{}"), fmt.Errorf("smartctl returned bad data for device %s", device)
return gjson.Result{}
}
return cacheValue.(JSONCache).JSON, nil
return cacheValue.(JSONCache).JSON
}
// Parse smartctl return code