mirror of
https://github.com/prometheus-community/ipmi_exporter
synced 2025-02-21 05:06:49 +00:00
Try to parse bmc-info even if command failed
This is a workaround for an issue described in #57. The bmc-info command might produce usable output minus the system firmware revision, but then choke on that. Try to recover in that scenario by attempting to parse the output even if the command failed. Since the system firmware revision is already optional, this should at least produce all other values. It is not pretty, but it avoids both folks having to change their configs as well a second round-trip, which can be quite expensive in IPMI.
This commit is contained in:
parent
a138b9ae59
commit
27f27b902f
18
collector.go
18
collector.go
@ -575,13 +575,21 @@ func collectChassisState(ch chan<- prometheus.Metric, target ipmiTarget) (int, e
|
||||
}
|
||||
|
||||
func collectBmcInfo(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) {
|
||||
output, err := bmcInfoOutput(target)
|
||||
if err != nil {
|
||||
log.Debugf("Failed to collect bmc-info data from %s: %s", targetName(target.host), err)
|
||||
return 0, err
|
||||
}
|
||||
output, cmderr := bmcInfoOutput(target)
|
||||
// Workaround for an issue described here: https://github.com/soundcloud/ipmi_exporter/issues/57
|
||||
// The command may fail, but produce usable output (minus the system firmware revision).
|
||||
// Try to recover gracefully from that situation by first trying to parse the output, and only
|
||||
// raise the initial error if that also fails.
|
||||
|
||||
firmwareRevision, err := getBMCInfoFirmwareRevision(output)
|
||||
if err != nil {
|
||||
// If the command failed, return that error now, we tried to recover but to no avail.
|
||||
if cmderr != nil {
|
||||
log.Debugf("Failed to collect bmc-info data from %s: %s", targetName(target.host), cmderr)
|
||||
return 0, cmderr
|
||||
}
|
||||
|
||||
// Handling of successful command but failed parsing.
|
||||
log.Errorf("Failed to parse bmc-info data from %s: %s", targetName(target.host), err)
|
||||
return 0, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user