@@ -87,10 +87,10 @@ func (c *fibrechannelCollector) pushMetric(ch chan<- prometheus.Metric, name str
87
87
ch <- prometheus .MustNewConstMetric (c .metricDescs [name ], valueType , float64 (value ), host )
88
88
}
89
89
90
- func (c * fibrechannelCollector ) pushCounter (ch chan <- prometheus.Metric , name string , value uint64 , host string ) {
90
+ func (c * fibrechannelCollector ) pushCounter (ch chan <- prometheus.Metric , name string , value * uint64 , host string ) {
91
91
// Don't push counters that aren't implemented (a counter equal to maxUint64 is unimplemented by the HBA firmware)
92
- if value != maxUint64 {
93
- c .pushMetric (ch , name , value , host , prometheus .CounterValue )
92
+ if value != nil && * value != maxUint64 {
93
+ c .pushMetric (ch , name , * value , host , prometheus .CounterValue )
94
94
}
95
95
}
96
96
@@ -114,24 +114,34 @@ func (c *fibrechannelCollector) Update(ch chan<- prometheus.Metric) error {
114
114
infoValue := 1.0
115
115
116
116
// First push the Host values
117
- ch <- prometheus .MustNewConstMetric (infoDesc , prometheus .GaugeValue , infoValue , host .Name , host .Speed , host .PortState , host .PortType , host .PortID , host .PortName , host .FabricName , host .SymbolicName , host .SupportedClasses , host .SupportedSpeeds , host .DevLossTMO )
117
+ ch <- prometheus .MustNewConstMetric (infoDesc , prometheus .GaugeValue , infoValue ,
118
+ nilToEmpty (host .Name ), nilToEmpty (host .Speed ), nilToEmpty (host .PortState ), nilToEmpty (host .PortType ),
119
+ nilToEmpty (host .PortID ), nilToEmpty (host .PortName ), nilToEmpty (host .FabricName ), nilToEmpty (host .SymbolicName ),
120
+ nilToEmpty (host .SupportedClasses ), nilToEmpty (host .SupportedSpeeds ), nilToEmpty (host .DevLossTMO ))
118
121
119
122
// Then the counters
120
- c .pushCounter (ch , "dumped_frames_total" , host .Counters .DumpedFrames , host .Name )
121
- c .pushCounter (ch , "error_frames_total" , host .Counters .ErrorFrames , host .Name )
122
- c .pushCounter (ch , "invalid_crc_total" , host .Counters .InvalidCRCCount , host .Name )
123
- c .pushCounter (ch , "rx_frames_total" , host .Counters .RXFrames , host .Name )
124
- c .pushCounter (ch , "rx_words_total" , host .Counters .RXWords , host .Name )
125
- c .pushCounter (ch , "tx_frames_total" , host .Counters .TXFrames , host .Name )
126
- c .pushCounter (ch , "tx_words_total" , host .Counters .TXWords , host .Name )
127
- c .pushCounter (ch , "seconds_since_last_reset_total" , host .Counters .SecondsSinceLastReset , host .Name )
128
- c .pushCounter (ch , "invalid_tx_words_total" , host .Counters .InvalidTXWordCount , host .Name )
129
- c .pushCounter (ch , "link_failure_total" , host .Counters .LinkFailureCount , host .Name )
130
- c .pushCounter (ch , "loss_of_sync_total" , host .Counters .LossOfSyncCount , host .Name )
131
- c .pushCounter (ch , "loss_of_signal_total" , host .Counters .LossOfSignalCount , host .Name )
132
- c .pushCounter (ch , "nos_total" , host .Counters .NosCount , host .Name )
133
- c .pushCounter (ch , "fcp_packet_aborts_total" , host .Counters .FCPPacketAborts , host .Name )
123
+ c .pushCounter (ch , "dumped_frames_total" , host .Counters .DumpedFrames , nilToEmpty ( host .Name ) )
124
+ c .pushCounter (ch , "error_frames_total" , host .Counters .ErrorFrames , nilToEmpty ( host .Name ) )
125
+ c .pushCounter (ch , "invalid_crc_total" , host .Counters .InvalidCRCCount , nilToEmpty ( host .Name ) )
126
+ c .pushCounter (ch , "rx_frames_total" , host .Counters .RXFrames , nilToEmpty ( host .Name ) )
127
+ c .pushCounter (ch , "rx_words_total" , host .Counters .RXWords , nilToEmpty ( host .Name ) )
128
+ c .pushCounter (ch , "tx_frames_total" , host .Counters .TXFrames , nilToEmpty ( host .Name ) )
129
+ c .pushCounter (ch , "tx_words_total" , host .Counters .TXWords , nilToEmpty ( host .Name ) )
130
+ c .pushCounter (ch , "seconds_since_last_reset_total" , host .Counters .SecondsSinceLastReset , nilToEmpty ( host .Name ) )
131
+ c .pushCounter (ch , "invalid_tx_words_total" , host .Counters .InvalidTXWordCount , nilToEmpty ( host .Name ) )
132
+ c .pushCounter (ch , "link_failure_total" , host .Counters .LinkFailureCount , nilToEmpty ( host .Name ) )
133
+ c .pushCounter (ch , "loss_of_sync_total" , host .Counters .LossOfSyncCount , nilToEmpty ( host .Name ) )
134
+ c .pushCounter (ch , "loss_of_signal_total" , host .Counters .LossOfSignalCount , nilToEmpty ( host .Name ) )
135
+ c .pushCounter (ch , "nos_total" , host .Counters .NosCount , nilToEmpty ( host .Name ) )
136
+ c .pushCounter (ch , "fcp_packet_aborts_total" , host .Counters .FCPPacketAborts , nilToEmpty ( host .Name ) )
134
137
}
135
138
136
139
return nil
137
140
}
141
+
142
+ func nilToEmpty (s * string ) string {
143
+ if s == nil {
144
+ return ""
145
+ }
146
+ return * s
147
+ }
0 commit comments