Skip to content

Commit

Permalink
feat: add bmc url (#219)
Browse files Browse the repository at this point in the history
* feat: add bmc url

Signed-off-by: happyfx <[email protected]>
  • Loading branch information
HappyFX authored Dec 6, 2024
1 parent 4b683aa commit 50d22df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions collector_bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions freeipmi/freeipmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (
bmcInfoFirmwareRevisionRegex = regexp.MustCompile(`^Firmware Revision\s*:\s*(?P<value>[0-9.]*).*`)
bmcInfoSystemFirmwareVersionRegex = regexp.MustCompile(`^System Firmware Version\s*:\s*(?P<value>[0-9.]*).*`)
bmcInfoManufacturerIDRegex = regexp.MustCompile(`^Manufacturer ID\s*:\s*(?P<value>.*)`)
bmcInfoBmcUrlRegex = regexp.MustCompile(`^BMC URL\s*:\s*(?P<value>.*)`)
bmcWatchdogTimerStateRegex = regexp.MustCompile(`^Timer:\s*(?P<value>Running|Stopped)`)
bmcWatchdogTimerUseRegex = regexp.MustCompile(`^Timer Use:\s*(?P<value>.*)`)
bmcWatchdogTimerLoggingRegex = regexp.MustCompile(`^Logging:\s*(?P<value>Enabled|Disabled)`)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 50d22df

Please sign in to comment.