Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix psu status metric and large fw scrape time #86

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ log is based on the [Keep a CHANGELOG](http://keepachangelog.com/) project.
- Chassis ComputerSystems field is handled improperly [#68](https://github.com/Comcast/fishymetrics/issues/68)
- Power and Thermal metrics collection for Dell R7xxXD server models [#77](https://github.com/Comcast/fishymetrics/issues/77)
- Firmware metrics and request headers update for Dell iDRAC9 with FW ver.3.xx and 4.xx [#77](https://github.com/Comcast/fishymetrics/issues/77)
- Power supply status duplicate bay number metrics [#85] (https://github.com/Comcast/fishymetrics/issues/85)

## Updated

Expand All @@ -44,6 +45,7 @@ log is based on the [Keep a CHANGELOG](http://keepachangelog.com/) project.
- get chassis serial number from JSON response instead of url path [#50](https://github.com/Comcast/fishymetrics/issues/50)
- HP DL380 module to include CPU metrics and all HP models to include bayNumber in PSU metrics [#57](https://github.com/Comcast/fishymetrics/issues/57)
- use standard library for http routing instead of gorilla mux package [#47](https://github.com/Comcast/fishymetrics/issues/47)
- Avoid collecting firmware metrics if count of endpoints are 75 or greater [#77] (https://github.com/Comcast/fishymetrics/issues/77)

## [0.7.1]

Expand Down
2 changes: 1 addition & 1 deletion common/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (cp *CredentialProfilesFlag) Set(value string) error {
// if json was passed in we will attempt to unmarshal differently
err := json.Unmarshal([]byte(value), cp)
if err != nil {
panic(fmt.Errorf("Error parsing argument flag \"--credentials.profiles\" - %s", err.Error()))
panic(fmt.Errorf("error parsing argument flag \"--credentials.profiles\" - %s", err.Error()))
}
}
ChassisCreds.populateProfiles(cp)
Expand Down
17 changes: 10 additions & 7 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,16 @@ func NewExporter(ctx context.Context, target, uri, profile, model string, exclud
}

// Firmware Inventory
for _, fwEp := range firmwareInventoryEndpoints.Members {
// this list can potentially be large and cause scrapes to take a long time
// see the '--collector.firmware.modules-exclude' config in the README for more information
if reg, ok := excludes["firmware"]; ok {
if !reg.(*regexp.Regexp).MatchString(fwEp.URL) {
tasks = append(tasks,
pool.NewTask(common.Fetch(exp.url+fwEp.URL, target, profile, retryClient), exp.url+fwEp.URL, handle(&exp, FIRMWAREINVENTORY)))
// To avoid scraping a large number of firmware endpoints, we will only scrape if there are less than 75 members
if len(firmwareInventoryEndpoints.Members) < 75 {
for _, fwEp := range firmwareInventoryEndpoints.Members {
// this list can potentially be large and cause scrapes to take a long time
// see the '--collector.firmware.modules-exclude' config in the README for more information
if reg, ok := excludes["firmware"]; ok {
if !reg.(*regexp.Regexp).MatchString(fwEp.URL) {
tasks = append(tasks,
pool.NewTask(common.Fetch(exp.url+fwEp.URL, target, profile, retryClient), exp.url+fwEp.URL, handle(&exp, FIRMWAREINVENTORY)))
}
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions exporter/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ func (e *Exporter) exportPowerMetrics(body []byte) error {
}

for _, ps := range pm.PowerSupplies {
// if power supply status state is present, capture the bay number
if ps.Oem.Hp.PowerSupplyStatus.State != "" {
bay = ps.Oem.Hp.BayNumber
} else if ps.Oem.Hpe.PowerSupplyStatus.State != "" {
bay = ps.Oem.Hpe.BayNumber
}

if ps.Status.State == "Enabled" {
var watts float64
switch ps.LastPowerOutputWatts.(type) {
Expand All @@ -156,12 +163,6 @@ func (e *Exporter) exportPowerMetrics(body []byte) error {
watts, _ = strconv.ParseFloat(ps.LastPowerOutputWatts.(string), 32)
}

if ps.Oem.Hp.PowerSupplyStatus.State != "" {
bay = ps.Oem.Hp.BayNumber
} else if ps.Oem.Hpe.PowerSupplyStatus.State != "" {
bay = ps.Oem.Hpe.BayNumber
}

(*pow)["supplyOutput"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), ps.SerialNumber, ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), ps.Model).Set(watts)
if ps.Status.Health == "OK" {
state = OK
Expand All @@ -174,7 +175,9 @@ func (e *Exporter) exportPowerMetrics(body []byte) error {
state = BAD
}

(*pow)["supplyStatus"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), ps.SerialNumber, ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), ps.Model).Set(state)
if ps.Status.State != "Absent" {
(*pow)["supplyStatus"].WithLabelValues(ps.Name, e.ChassisSerialNumber, e.Model, strings.TrimRight(ps.Manufacturer, " "), ps.SerialNumber, ps.FirmwareVersion, ps.PowerSupplyType, strconv.Itoa(bay), ps.Model).Set(state)
}
}

return nil
Expand Down
Loading