diff --git a/CHANGELOG.md b/CHANGELOG.md index bcf4f57..21191a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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] diff --git a/common/credentials.go b/common/credentials.go index 10c6377..1ed024b 100644 --- a/common/credentials.go +++ b/common/credentials.go @@ -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) diff --git a/exporter/exporter.go b/exporter/exporter.go index 992c943..6c3eb9a 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -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))) + } } } } diff --git a/exporter/handlers.go b/exporter/handlers.go index 3e1625c..261d7c4 100644 --- a/exporter/handlers.go +++ b/exporter/handlers.go @@ -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) { @@ -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 @@ -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