Skip to content

Commit 17c2dea

Browse files
committed
Update procfs to v0.15.1 and fix compilation errors.
1 parent dc185bc commit 17c2dea

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

collector/fibrechannel_linux.go

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ func (c *fibrechannelCollector) pushMetric(ch chan<- prometheus.Metric, name str
8787
ch <- prometheus.MustNewConstMetric(c.metricDescs[name], valueType, float64(value), host)
8888
}
8989

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) {
9191
// 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)
9494
}
9595
}
9696

@@ -114,24 +114,34 @@ func (c *fibrechannelCollector) Update(ch chan<- prometheus.Metric) error {
114114
infoValue := 1.0
115115

116116
// 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))
118121

119122
// 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))
134137
}
135138

136139
return nil
137140
}
141+
142+
func nilToEmpty(s *string) string {
143+
if s == nil {
144+
return ""
145+
}
146+
return *s
147+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/prometheus/client_model v0.6.1
2727
github.com/prometheus/common v0.53.0
2828
github.com/prometheus/exporter-toolkit v0.11.0
29-
github.com/prometheus/procfs v0.14.0
29+
github.com/prometheus/procfs v0.15.1
3030
github.com/safchain/ethtool v0.3.0
3131
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
3232
golang.org/x/sys v0.20.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+a
8282
github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U=
8383
github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g=
8484
github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q=
85-
github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s=
86-
github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ=
85+
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
86+
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
8787
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
8888
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
8989
github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0=

0 commit comments

Comments
 (0)