diff --git a/collector_bmc.go b/collector_bmc.go index 84b8ce3..493cea1 100644 --- a/collector_bmc.go +++ b/collector_bmc.go @@ -27,7 +27,7 @@ var ( bmcInfoDesc = prometheus.NewDesc( prometheus.BuildFQName(namespace, "bmc", "info"), "Constant metric with value '1' providing details about the BMC.", - []string{"firmware_revision", "manufacturer_id", "system_firmware_version"}, + []string{"firmware_revision", "manufacturer_id", "system_firmware_version", "bmc_url"}, nil, ) ) @@ -63,11 +63,17 @@ func (c BMCCollector) Collect(result freeipmi.Result, ch chan<- prometheus.Metri logger.Debug("Failed to parse bmc-info data", "target", targetName(target.host), "error", err) systemFirmwareVersion = "N/A" } + bmcUrl, err := freeipmi.GetBMCInfoBmcUrl(result) + if err != nil { + // This one is not always available. + logger.Debug("Failed to parse bmc-info data", "target", targetName(target.host), "error", err) + bmcUrl = "N/A" + } ch <- prometheus.MustNewConstMetric( bmcInfoDesc, prometheus.GaugeValue, 1, - firmwareRevision, manufacturerID, systemFirmwareVersion, + firmwareRevision, manufacturerID, systemFirmwareVersion, bmcUrl, ) return 1, nil } diff --git a/freeipmi/freeipmi.go b/freeipmi/freeipmi.go index 1d6c8d5..cc2987d 100644 --- a/freeipmi/freeipmi.go +++ b/freeipmi/freeipmi.go @@ -43,6 +43,7 @@ var ( bmcInfoFirmwareRevisionRegex = regexp.MustCompile(`^Firmware Revision\s*:\s*(?P[0-9.]*).*`) bmcInfoSystemFirmwareVersionRegex = regexp.MustCompile(`^System Firmware Version\s*:\s*(?P[0-9.]*).*`) bmcInfoManufacturerIDRegex = regexp.MustCompile(`^Manufacturer ID\s*:\s*(?P.*)`) + bmcInfoBmcUrlRegex = regexp.MustCompile(`^BMC URL\s*:\s*(?P.*)`) bmcWatchdogTimerStateRegex = regexp.MustCompile(`^Timer:\s*(?PRunning|Stopped)`) bmcWatchdogTimerUseRegex = regexp.MustCompile(`^Timer Use:\s*(?P.*)`) bmcWatchdogTimerLoggingRegex = regexp.MustCompile(`^Logging:\s*(?PEnabled|Disabled)`) @@ -313,6 +314,13 @@ func GetBMCInfoSystemFirmwareVersion(ipmiOutput Result) (string, error) { return getValue(ipmiOutput.output, bmcInfoSystemFirmwareVersionRegex) } +func GetBMCInfoBmcUrl(ipmiOutput Result) (string, error) { + if ipmiOutput.err != nil { + return "", fmt.Errorf("%s: %s", ipmiOutput.err, ipmiOutput.output) + } + return getValue(ipmiOutput.output, bmcInfoBmcUrlRegex) +} + func GetSELInfoEntriesCount(ipmiOutput Result) (float64, error) { if ipmiOutput.err != nil { return -1, fmt.Errorf("%s: %s", ipmiOutput.err, ipmiOutput.output)