Skip to content

Commit 2d8b68b

Browse files
fix: fomat and add pcie_device_partnumber to fix jenningsloy318#57
1 parent d77e8c1 commit 2d8b68b

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

collector/chassis_collector.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package collector
22

33
import (
44
"fmt"
5-
"math"
5+
"math"
66
"strings"
77
"sync"
88

@@ -285,7 +285,7 @@ var (
285285
}
286286
)
287287

288-
//ChassisCollector implements the prometheus.Collector.
288+
// ChassisCollector implements the prometheus.Collector.
289289
type ChassisCollector struct {
290290
redfishClient *gofish.APIClient
291291
metrics map[string]chassisMetric
@@ -490,16 +490,16 @@ func parseChassisFan(ch chan<- prometheus.Metric, chassisID string, chassisFan r
490490

491491
chassisFanPercentage := chassisFanRPM
492492
if chassisFanUnit != redfish.PercentReadingUnits {
493-
// Some vendors (e.g. PowerEdge C6420) report null RPMs for Min/Max, as well as Lower/UpperFatal,
494-
// but provide Lower/UpperCritical, so use largest non-null for max. However, we can't know if
495-
// min is null (reported as zero by gofish) or just zero, so we'll have to assume a min of zero
496-
// if Min is not reported...
497-
min := chassisFanRPMMin
498-
max := math.Max(math.Max(chassisFanRPMMax, chassisFanRPMUpperFatalThreshold), chassisFanRPMUpperCriticalThreshold)
499-
chassisFanPercentage = 0
500-
if max != 0 {
501-
chassisFanPercentage = float64((chassisFanRPM+min)/max) * 100
502-
}
493+
// Some vendors (e.g. PowerEdge C6420) report null RPMs for Min/Max, as well as Lower/UpperFatal,
494+
// but provide Lower/UpperCritical, so use largest non-null for max. However, we can't know if
495+
// min is null (reported as zero by gofish) or just zero, so we'll have to assume a min of zero
496+
// if Min is not reported...
497+
min := chassisFanRPMMin
498+
max := math.Max(math.Max(chassisFanRPMMax, chassisFanRPMUpperFatalThreshold), chassisFanRPMUpperCriticalThreshold)
499+
chassisFanPercentage = 0
500+
if max != 0 {
501+
chassisFanPercentage = float64((chassisFanRPM+min)/max) * 100
502+
}
503503
}
504504

505505
// chassisFanStatusLabelNames :=[]string{BaseLabelNames,"fan_name","fan_member_id")

collector/manager_collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type managerMetric struct {
1414
desc *prometheus.Desc
1515
}
1616

17-
//ManagerSubmanager is the manager subsystem
17+
// ManagerSubmanager is the manager subsystem
1818
var (
1919
ManagerSubmanager = "manager"
2020
ManagerLabelNames = []string{"manager_id", "name", "model", "type"}
@@ -46,7 +46,7 @@ var (
4646
}
4747
)
4848

49-
//ManagerCollector implemented prometheus.Collector
49+
// ManagerCollector implemented prometheus.Collector
5050
type ManagerCollector struct {
5151
redfishClient *gofish.APIClient
5252
metrics map[string]managerMetric

collector/system_collector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var (
2626
SystemDeviceLabelNames = []string{"hostname", "resource", "device"}
2727
SystemDriveLabelNames = []string{"hostname", "resource", "drive", "drive_id"}
2828
SystemStorageControllerLabelNames = []string{"hostname", "resource", "storage_controller", "storage_controller_id"}
29-
SystemPCIeDeviceLabelNames = []string{"hostname", "resource", "pcie_device", "pcie_device_id"}
29+
SystemPCIeDeviceLabelNames = []string{"hostname", "resource", "pcie_device", "pcie_device_id", "pcie_device_partnumber"}
3030
SystemNetworkInterfaceLabelNames = []string{"hostname", "resource", "network_interface", "network_interface_id"}
3131
SystemEthernetInterfaceLabelNames = []string{"hostname", "resource", "ethernet_interface", "ethernet_interface_id", "ethernet_interface_speed"}
3232
systemMetrics = map[string]systemMetric{
@@ -673,7 +673,8 @@ func parsePcieDevice(ch chan<- prometheus.Metric, systemHostName string, pcieDev
673673
pcieDeviceID := pcieDevice.ID
674674
pcieDeviceState := pcieDevice.Status.State
675675
pcieDeviceHealthState := pcieDevice.Status.Health
676-
systemPCIeDeviceLabelValues := []string{systemHostName, "pcie_device", pcieDeviceName, pcieDeviceID}
676+
pcieDevicePartNumber := pcieDevice.PartNumber
677+
systemPCIeDeviceLabelValues := []string{systemHostName, "pcie_device", pcieDeviceName, pcieDeviceID, pcieDevicePartNumber}
677678

678679
if pcieStateVaule, ok := parseCommonStatusState(pcieDeviceState); ok {
679680
ch <- prometheus.MustNewConstMetric(systemMetrics["system_pcie_device_state"].desc, prometheus.GaugeValue, pcieStateVaule, systemPCIeDeviceLabelValues...)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030
"config.file",
3131
"Path to configuration file.",
3232
).String()
33-
webConfig = webflag.AddFlags(kingpin.CommandLine)
33+
webConfig = webflag.AddFlags(kingpin.CommandLine)
3434
listenAddress = kingpin.Flag(
3535
"web.listen-address",
3636
"Address to listen on for web interface and telemetry.",

0 commit comments

Comments
 (0)