Skip to content

Commit 2c6089f

Browse files
dylnggDylan Gardner
authored andcommitted
Collect fan low/hi RPMs thresholds and properly compute fan percentage
1 parent 4bdfc07 commit 2c6089f

File tree

1 file changed

+95
-4
lines changed

1 file changed

+95
-4
lines changed

collector/chassis_collector.go

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

33
import (
44
"fmt"
5+
"strings"
56
"sync"
67

78
"github.com/apex/log"
@@ -15,7 +16,7 @@ var (
1516
ChassisSubsystem = "chassis"
1617
ChassisLabelNames = []string{"resource", "chassis_id"}
1718
ChassisTemperatureLabelNames = []string{"resource", "chassis_id", "sensor", "sensor_id"}
18-
ChassisFanLabelNames = []string{"resource", "chassis_id", "fan", "fan_id"}
19+
ChassisFanLabelNames = []string{"resource", "chassis_id", "fan", "fan_id", "fan_unit"}
1920
ChassisPowerVoltageLabelNames = []string{"resource", "chassis_id", "power_voltage", "power_voltage_id"}
2021
ChassisPowerSupplyLabelNames = []string{"resource", "chassis_id", "power_supply", "power_supply_id"}
2122
ChassisNetworkAdapterLabelNames = []string{"resource", "chassis_id", "network_adapter", "network_adapter_id"}
@@ -72,9 +73,81 @@ var (
7273
),
7374
},
7475
"chassis_fan_rpm": {
76+
desc: prometheus.NewDesc(
77+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm"),
78+
"fan RPM or percentage on this chassis component",
79+
ChassisFanLabelNames,
80+
nil,
81+
),
82+
},
83+
"chassis_fan_rpm_percentage": {
7584
desc: prometheus.NewDesc(
7685
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_percentage"),
77-
"fan rpm percentage on this chassis component",
86+
"fan RPM, as a percentage of the min-max RPMs possible, on this chassis component",
87+
ChassisFanLabelNames,
88+
nil,
89+
),
90+
},
91+
"chassis_fan_rpm_min": {
92+
desc: prometheus.NewDesc(
93+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_min"),
94+
"lowest possible fan RPM or percentage, on this chassis component",
95+
ChassisFanLabelNames,
96+
nil,
97+
),
98+
},
99+
"chassis_fan_rpm_max": {
100+
desc: prometheus.NewDesc(
101+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_max"),
102+
"highest possible fan RPM or percentage, on this chassis component",
103+
ChassisFanLabelNames,
104+
nil,
105+
),
106+
},
107+
"chassis_fan_rpm_lower_threshold_critical": {
108+
desc: prometheus.NewDesc(
109+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_lower_threshold_critical"),
110+
"threshold below the normal range fan RPM or percentage, but not fatal, on this chassis component",
111+
ChassisFanLabelNames,
112+
nil,
113+
),
114+
},
115+
"chassis_fan_rpm_lower_threshold_non_critical": {
116+
desc: prometheus.NewDesc(
117+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_lower_threshold_non_critical"),
118+
"threshold below the normal range fan RPM or percentage, but not critical, on this chassis component",
119+
ChassisFanLabelNames,
120+
nil,
121+
),
122+
},
123+
"chassis_fan_rpm_lower_threshold_fatal": {
124+
desc: prometheus.NewDesc(
125+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_lower_threshold_fatal"),
126+
"threshold below the normal range fan RPM or percentage, and is fatal, on this chassis component",
127+
ChassisFanLabelNames,
128+
nil,
129+
),
130+
},
131+
"chassis_fan_rpm_upper_threshold_critical": {
132+
desc: prometheus.NewDesc(
133+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_upper_threshold_critical"),
134+
"threshold above the normal range fan RPM or percentage, but not fatal, on this chassis component",
135+
ChassisFanLabelNames,
136+
nil,
137+
),
138+
},
139+
"chassis_fan_rpm_upper_threshold_non_critical": {
140+
desc: prometheus.NewDesc(
141+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_upper_threshold_non_critical"),
142+
"threshold above the normal range fan RPM or percentage, but not critical, on this chassis component",
143+
ChassisFanLabelNames,
144+
nil,
145+
),
146+
},
147+
"chassis_fan_rpm_upper_threshold_fatal": {
148+
desc: prometheus.NewDesc(
149+
prometheus.BuildFQName(namespace, ChassisSubsystem, "fan_rpm_upper_threshold_fatal"),
150+
"threshold above the normal range fan RPM or percentage, and is fatal, on this chassis component",
78151
ChassisFanLabelNames,
79152
nil,
80153
),
@@ -366,9 +439,21 @@ func parseChassisFan(ch chan<- prometheus.Metric, chassisID string, chassisFan r
366439
chassisFanStausHealth := chassisFanStaus.Health
367440
chassisFanStausState := chassisFanStaus.State
368441
chassisFanRPM := chassisFan.Reading
442+
chassisFanUnit := chassisFan.ReadingUnits
443+
chassisFanRPMLowerCriticalThreshold := chassisFan.LowerThresholdCritical
444+
chassisFanRPMUpperCriticalThreshold := chassisFan.UpperThresholdCritical
445+
chassisFanRPMLowerFatalThreshold := chassisFan.LowerThresholdFatal
446+
chassisFanRPMUpperFatalThreshold := chassisFan.UpperThresholdFatal
447+
chassisFanRPMMin := chassisFan.MinReadingRange
448+
chassisFanRPMMax := chassisFan.MaxReadingRange
449+
450+
chassisFanPercentage := chassisFanRPM
451+
if chassisFanUnit != redfish.PercentReadingUnits {
452+
chassisFanPercentage = float32((chassisFanRPM+chassisFanRPMMin)/chassisFanRPMMax) * 100
453+
}
369454

370455
// chassisFanStatusLabelNames :=[]string{BaseLabelNames,"fan_name","fan_member_id")
371-
chassisFanLabelvalues := []string{"fan", chassisID, chassisFanName, chassisFanID}
456+
chassisFanLabelvalues := []string{"fan", chassisID, chassisFanName, chassisFanID, strings.ToLower(string(chassisFanUnit))} // e.g. RPM -> rpm, Percentage -> percentage
372457

373458
if chassisFanStausHealthValue, ok := parseCommonStatusHealth(chassisFanStausHealth); ok {
374459
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_health"].desc, prometheus.GaugeValue, chassisFanStausHealthValue, chassisFanLabelvalues...)
@@ -378,7 +463,13 @@ func parseChassisFan(ch chan<- prometheus.Metric, chassisID string, chassisFan r
378463
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_state"].desc, prometheus.GaugeValue, chassisFanStausStateValue, chassisFanLabelvalues...)
379464
}
380465
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm"].desc, prometheus.GaugeValue, float64(chassisFanRPM), chassisFanLabelvalues...)
381-
466+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_min"].desc, prometheus.GaugeValue, float64(chassisFanRPMMin), chassisFanLabelvalues...)
467+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_max"].desc, prometheus.GaugeValue, float64(chassisFanRPMMax), chassisFanLabelvalues...)
468+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_percentage"].desc, prometheus.GaugeValue, float64(chassisFanPercentage), chassisFanLabelvalues...)
469+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_lower_threshold_critical"].desc, prometheus.GaugeValue, float64(chassisFanRPMLowerCriticalThreshold), chassisFanLabelvalues...)
470+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_upper_threshold_critical"].desc, prometheus.GaugeValue, float64(chassisFanRPMUpperCriticalThreshold), chassisFanLabelvalues...)
471+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_lower_threshold_fatal"].desc, prometheus.GaugeValue, float64(chassisFanRPMLowerFatalThreshold), chassisFanLabelvalues...)
472+
ch <- prometheus.MustNewConstMetric(chassisMetrics["chassis_fan_rpm_upper_threshold_fatal"].desc, prometheus.GaugeValue, float64(chassisFanRPMUpperFatalThreshold), chassisFanLabelvalues...)
382473
}
383474

384475
func parseChassisPowerInfoVoltage(ch chan<- prometheus.Metric, chassisID string, chassisPowerInfoVoltage redfish.Voltage, wg *sync.WaitGroup) {

0 commit comments

Comments
 (0)