From 7e5c643b90f118133d5ee7e5b94c501254232d04 Mon Sep 17 00:00:00 2001 From: Danny Kulchinsky Date: Sat, 16 Mar 2019 12:41:05 -0400 Subject: [PATCH 1/4] adding rcmp.host to error log messages --- collector.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/collector.go b/collector.go index d2bb25e..12883a6 100644 --- a/collector.go +++ b/collector.go @@ -370,13 +370,13 @@ func collectGenericSensor(ch chan<- prometheus.Metric, state float64, data senso func collectMonitoring(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { output, err := ipmiMonitoringOutput(target) if err != nil { - log.Errorf("Failed to collect ipmimonitoring data: %s", err) + log.Errorf("Failed to collect ipmimonitoring data from %s: %s", rcmp.host, err) return 0, err } excludeIds := target.config.ExcludeSensorIDs results, err := splitMonitoringOutput(output, excludeIds) if err != nil { - log.Errorf("Failed to parse ipmimonitoring data: %s", err) + log.Errorf("Failed to parse ipmimonitoring data from %s: %s", rcmp.host, err) return 0, err } for _, data := range results { @@ -419,12 +419,12 @@ func collectMonitoring(ch chan<- prometheus.Metric, target ipmiTarget) (int, err func collectDCMI(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { output, err := ipmiDCMIOutput(target) if err != nil { - log.Debugf("Failed to collect ipmi-dcmi data: %s", err) + log.Debugf("Failed to collect ipmi-dcmi data from %s: %s", rcmp.host, err) return 0, err } currentPowerConsumption, err := getCurrentPowerConsumption(output) if err != nil { - log.Errorf("Failed to parse ipmi-dcmi data: %s", err) + log.Errorf("Failed to parse ipmi-dcmi data from %s: %s", rcmp.host, err) return 0, err } ch <- prometheus.MustNewConstMetric( @@ -438,17 +438,17 @@ func collectDCMI(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { 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: %s", err) + log.Debugf("Failed to collect bmc-info data from %s: %s", rcmp.host, err) return 0, err } firmwareRevision, err := getBMCInfoFirmwareRevision(output) if err != nil { - log.Errorf("Failed to parse bmc-info data: %s", err) + log.Errorf("Failed to parse bmc-info data from %s: %s", rcmp.host, err) return 0, err } manufacturerID, err := getBMCInfoManufacturerID(output) if err != nil { - log.Errorf("Failed to parse bmc-info data: %s", err) + log.Errorf("Failed to parse bmc-info data from %s: %s", rcmp.host, err) return 0, err } ch <- prometheus.MustNewConstMetric( From a908a3481231abd04fe6047eb80f1e24dc23c3c1 Mon Sep 17 00:00:00 2001 From: Danny Kulchinsky Date: Sat, 16 Mar 2019 12:45:32 -0400 Subject: [PATCH 2/4] typo :) --- collector.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/collector.go b/collector.go index 12883a6..58b4410 100644 --- a/collector.go +++ b/collector.go @@ -370,13 +370,13 @@ func collectGenericSensor(ch chan<- prometheus.Metric, state float64, data senso func collectMonitoring(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { output, err := ipmiMonitoringOutput(target) if err != nil { - log.Errorf("Failed to collect ipmimonitoring data from %s: %s", rcmp.host, err) + log.Errorf("Failed to collect ipmimonitoring data from %s: %s", rmcp.host, err) return 0, err } excludeIds := target.config.ExcludeSensorIDs results, err := splitMonitoringOutput(output, excludeIds) if err != nil { - log.Errorf("Failed to parse ipmimonitoring data from %s: %s", rcmp.host, err) + log.Errorf("Failed to parse ipmimonitoring data from %s: %s", rmcp.host, err) return 0, err } for _, data := range results { @@ -419,12 +419,12 @@ func collectMonitoring(ch chan<- prometheus.Metric, target ipmiTarget) (int, err func collectDCMI(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { output, err := ipmiDCMIOutput(target) if err != nil { - log.Debugf("Failed to collect ipmi-dcmi data from %s: %s", rcmp.host, err) + log.Debugf("Failed to collect ipmi-dcmi data from %s: %s", rmcp.host, err) return 0, err } currentPowerConsumption, err := getCurrentPowerConsumption(output) if err != nil { - log.Errorf("Failed to parse ipmi-dcmi data from %s: %s", rcmp.host, err) + log.Errorf("Failed to parse ipmi-dcmi data from %s: %s", rmcp.host, err) return 0, err } ch <- prometheus.MustNewConstMetric( @@ -438,17 +438,17 @@ func collectDCMI(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { 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", rcmp.host, err) + log.Debugf("Failed to collect bmc-info data from %s: %s", rmcp.host, err) return 0, err } firmwareRevision, err := getBMCInfoFirmwareRevision(output) if err != nil { - log.Errorf("Failed to parse bmc-info data from %s: %s", rcmp.host, err) + log.Errorf("Failed to parse bmc-info data from %s: %s", rmcp.host, err) return 0, err } manufacturerID, err := getBMCInfoManufacturerID(output) if err != nil { - log.Errorf("Failed to parse bmc-info data from %s: %s", rcmp.host, err) + log.Errorf("Failed to parse bmc-info data from %s: %s", rmcp.host, err) return 0, err } ch <- prometheus.MustNewConstMetric( From 710870138975f5475ef48eaa4abd2cc4b8cef2c1 Mon Sep 17 00:00:00 2001 From: Danny Kulchinsky Date: Sat, 16 Mar 2019 12:57:43 -0400 Subject: [PATCH 3/4] one more log --- collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector.go b/collector.go index 58b4410..0ee623a 100644 --- a/collector.go +++ b/collector.go @@ -228,7 +228,7 @@ func freeipmiOutput(cmd string, target ipmiTarget, arg ...string) ([]byte, error log.Debugf("Executing %s %v", fqcmd, args) out, err := exec.Command(fqcmd, args...).CombinedOutput() if err != nil { - log.Errorf("Error while calling %s: %s", cmd, out) + log.Errorf("Error while calling %s for %s: %s", cmd, rmcp.host, out) } return out, err } From 6aa7866dc1502305f7ed945cc2d27ace1f175333 Mon Sep 17 00:00:00 2001 From: Danny Kulchinsky Date: Wed, 20 Mar 2019 11:08:18 -0400 Subject: [PATCH 4/4] rebased and adjusted per #17 --- collector.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/collector.go b/collector.go index 0ee623a..f7ee2b9 100644 --- a/collector.go +++ b/collector.go @@ -228,7 +228,7 @@ func freeipmiOutput(cmd string, target ipmiTarget, arg ...string) ([]byte, error log.Debugf("Executing %s %v", fqcmd, args) out, err := exec.Command(fqcmd, args...).CombinedOutput() if err != nil { - log.Errorf("Error while calling %s for %s: %s", cmd, rmcp.host, out) + log.Errorf("Error while calling %s for %s: %s", cmd, targetName(target.host), out) } return out, err } @@ -370,13 +370,13 @@ func collectGenericSensor(ch chan<- prometheus.Metric, state float64, data senso func collectMonitoring(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { output, err := ipmiMonitoringOutput(target) if err != nil { - log.Errorf("Failed to collect ipmimonitoring data from %s: %s", rmcp.host, err) + log.Errorf("Failed to collect ipmimonitoring data from %s: %s", targetName(target.host), err) return 0, err } excludeIds := target.config.ExcludeSensorIDs results, err := splitMonitoringOutput(output, excludeIds) if err != nil { - log.Errorf("Failed to parse ipmimonitoring data from %s: %s", rmcp.host, err) + log.Errorf("Failed to parse ipmimonitoring data from %s: %s", targetName(target.host), err) return 0, err } for _, data := range results { @@ -419,12 +419,12 @@ func collectMonitoring(ch chan<- prometheus.Metric, target ipmiTarget) (int, err func collectDCMI(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { output, err := ipmiDCMIOutput(target) if err != nil { - log.Debugf("Failed to collect ipmi-dcmi data from %s: %s", rmcp.host, err) + log.Debugf("Failed to collect ipmi-dcmi data from %s: %s", targetName(target.host), err) return 0, err } currentPowerConsumption, err := getCurrentPowerConsumption(output) if err != nil { - log.Errorf("Failed to parse ipmi-dcmi data from %s: %s", rmcp.host, err) + log.Errorf("Failed to parse ipmi-dcmi data from %s: %s", targetName(target.host), err) return 0, err } ch <- prometheus.MustNewConstMetric( @@ -438,17 +438,17 @@ func collectDCMI(ch chan<- prometheus.Metric, target ipmiTarget) (int, error) { 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", rmcp.host, err) + log.Debugf("Failed to collect bmc-info data from %s: %s", targetName(target.host), err) return 0, err } firmwareRevision, err := getBMCInfoFirmwareRevision(output) if err != nil { - log.Errorf("Failed to parse bmc-info data from %s: %s", rmcp.host, err) + log.Errorf("Failed to parse bmc-info data from %s: %s", targetName(target.host), err) return 0, err } manufacturerID, err := getBMCInfoManufacturerID(output) if err != nil { - log.Errorf("Failed to parse bmc-info data from %s: %s", rmcp.host, err) + log.Errorf("Failed to parse bmc-info data from %s: %s", targetName(target.host), err) return 0, err } ch <- prometheus.MustNewConstMetric(