diff --git a/collector/fibrechannel_linux.go b/collector/fibrechannel_linux.go index a0528d168a..79548f165b 100644 --- a/collector/fibrechannel_linux.go +++ b/collector/fibrechannel_linux.go @@ -129,7 +129,24 @@ func (c *fibrechannelCollector) Update(ch chan<- prometheus.Metric) error { )...) // Then the counters - // Note: `procfs` guarantees these a safe dereference for these counters. + // Note: `procfs` does not guarantee a safe dereference for these counters. + // A disabled host returns no statistics counters. + if host.PortState == nil || *host.PortState == "Unknown" { + host.Counters.DumpedFrames = new(uint64) + host.Counters.ErrorFrames = new(uint64) + host.Counters.InvalidCRCCount = new(uint64) + host.Counters.RXFrames = new(uint64) + host.Counters.RXWords = new(uint64) + host.Counters.TXFrames = new(uint64) + host.Counters.TXWords = new(uint64) + host.Counters.SecondsSinceLastReset = new(uint64) + host.Counters.InvalidTXWordCount = new(uint64) + host.Counters.LinkFailureCount = new(uint64) + host.Counters.LossOfSyncCount = new(uint64) + host.Counters.LossOfSignalCount = new(uint64) + host.Counters.NosCount = new(uint64) + host.Counters.FCPPacketAborts = new(uint64) + } c.pushCounter(ch, "dumped_frames_total", *host.Counters.DumpedFrames, *host.Name) c.pushCounter(ch, "error_frames_total", *host.Counters.ErrorFrames, *host.Name) c.pushCounter(ch, "invalid_crc_total", *host.Counters.InvalidCRCCount, *host.Name) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 380e812c98..6ac6ace066 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -1397,7 +1397,7 @@ node_fibrechannel_error_frames_total{fc_host="host1"} 19 node_fibrechannel_fcp_packet_aborts_total{fc_host="host0"} 19 # HELP node_fibrechannel_info Non-numeric data from /sys/class/fc_host/, value is always 1. # TYPE node_fibrechannel_info gauge -node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 +node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="Online",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1 node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1 # HELP node_fibrechannel_invalid_crc_total Invalid Cyclic Redundancy Check count # TYPE node_fibrechannel_invalid_crc_total counter diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar index bc8744cbe7..c64234c7cc 100644 --- a/collector/fixtures/sys.ttar +++ b/collector/fixtures/sys.ttar @@ -1130,6 +1130,11 @@ Mode: 644 Directory: sys/class/fc_host/host1 Mode: 755 # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Path: sys/class/fc_host/host1/port_state +Lines: 1 +Online +Mode: 644 +# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Path: sys/class/fc_host/host1/speed Lines: 1 8 Gbit