mirror of
https://github.com/prometheus-community/ipmi_exporter
synced 2024-12-21 21:50:05 +00:00
feat: add bmc url (#219)
* feat: add bmc url Signed-off-by: happyfx <happyfx@mayflower.work>
This commit is contained in:
parent
4b683aa1c9
commit
50d22df5dc
@ -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
|
||||
}
|
||||
|
@ -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)`)
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user