From 25e5f1c4b6abdd478a74bac51218a8ababbace6b Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Sat, 30 Nov 2019 02:15:06 -0800 Subject: [PATCH] Add port ID to switch ports. --- pkg/promunifi/usw.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/promunifi/usw.go b/pkg/promunifi/usw.go index 88f7e190..a02b15f4 100644 --- a/pkg/promunifi/usw.go +++ b/pkg/promunifi/usw.go @@ -49,7 +49,7 @@ func descUSW(ns string) *usw { pns := ns + "port_" // labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"} labelS := []string{"site_name", "name"} // labels[6:] - labelP := []string{"port_num", "port_name", "port_mac", "port_ip", "site_name", "name"} + labelP := []string{"port_id", "port_num", "port_name", "port_mac", "port_ip", "site_name", "name"} return &usw{ SwRxPackets: prometheus.NewDesc(ns+"switch_receive_packets_total", "Switch Packets Received Total", labelS, nil), SwRxBytes: prometheus.NewDesc(ns+"switch_receive_bytes_total", "Switch Bytes Received Total", labelS, nil), @@ -147,11 +147,11 @@ func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) { func (u *promUnifi) exportPortTable(r report, labels []string, pt []unifi.Port) { // Per-port data on a switch for _, p := range pt { - if !p.Up.Val { + if !p.Up.Val || !p.Enable.Val { continue } // Copy labels, and add four new ones. - labelP := []string{p.PortIdx.Txt, p.Name, p.Mac, p.IP, labels[6], labels[7]} + labelP := []string{labels[7] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt, p.Name, p.Mac, p.IP, labels[6], labels[7]} if p.PoeEnable.Val && p.PortPoe.Val { r.send([]*metric{ {u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, labelP},