@@ -2,6 +2,7 @@ package collector
2
2
3
3
import (
4
4
"fmt"
5
+ "strings"
5
6
"sync"
6
7
7
8
"github.com/apex/log"
15
16
ChassisSubsystem = "chassis"
16
17
ChassisLabelNames = []string {"resource" , "chassis_id" }
17
18
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" }
19
20
ChassisPowerVoltageLabelNames = []string {"resource" , "chassis_id" , "power_voltage" , "power_voltage_id" }
20
21
ChassisPowerSupplyLabelNames = []string {"resource" , "chassis_id" , "power_supply" , "power_supply_id" }
21
22
ChassisNetworkAdapterLabelNames = []string {"resource" , "chassis_id" , "network_adapter" , "network_adapter_id" }
72
73
),
73
74
},
74
75
"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" : {
75
84
desc : prometheus .NewDesc (
76
85
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" ,
78
151
ChassisFanLabelNames ,
79
152
nil ,
80
153
),
@@ -366,9 +439,21 @@ func parseChassisFan(ch chan<- prometheus.Metric, chassisID string, chassisFan r
366
439
chassisFanStausHealth := chassisFanStaus .Health
367
440
chassisFanStausState := chassisFanStaus .State
368
441
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
+ }
369
454
370
455
// 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
372
457
373
458
if chassisFanStausHealthValue , ok := parseCommonStatusHealth (chassisFanStausHealth ); ok {
374
459
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
378
463
ch <- prometheus .MustNewConstMetric (chassisMetrics ["chassis_fan_state" ].desc , prometheus .GaugeValue , chassisFanStausStateValue , chassisFanLabelvalues ... )
379
464
}
380
465
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 ... )
382
473
}
383
474
384
475
func parseChassisPowerInfoVoltage (ch chan <- prometheus.Metric , chassisID string , chassisPowerInfoVoltage redfish.Voltage , wg * sync.WaitGroup ) {
0 commit comments