use fewer tags

This commit is contained in:
davidnewhall2 2019-11-29 14:43:23 -08:00
parent 9743a83aff
commit 23f4c9bdc4
5 changed files with 69 additions and 66 deletions

View File

@ -102,7 +102,7 @@ func (u *unifiCollector) exportClient(r report, c *unifi.Client) {
labels[len(labels)-1] = "false" labels[len(labels)-1] = "false"
r.send([]*metricExports{ r.send([]*metricExports{
{u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labels}, {u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labels},
{u.Client.CCQ, prometheus.GaugeValue, c.Ccq, labels}, {u.Client.CCQ, prometheus.GaugeValue, c.Ccq / 10, labels},
{u.Client.Noise, prometheus.GaugeValue, c.Noise, labels}, {u.Client.Noise, prometheus.GaugeValue, c.Noise, labels},
{u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labels}, {u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labels},
{u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labels}, {u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labels},

View File

@ -83,10 +83,10 @@ type uap struct {
} }
func descUAP(ns string) *uap { func descUAP(ns string) *uap {
labels := []string{"ip", "type", "version", "site_name", "mac", "model", "name", "serial"} labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
labelA := append([]string{"stat"}, labels[2:]...) labelA := append([]string{"stat"}, labels[6:]...)
labelV := append([]string{"vap_name", "bssid", "radio", "radio_name", "essid", "usage"}, labels[2:]...) labelV := append([]string{"vap_name", "bssid", "radio", "radio_name", "essid", "usage"}, labels[6:]...)
labelR := append([]string{"radio_name", "radio"}, labels[2:]...) labelR := append([]string{"radio_name", "radio"}, labels[6:]...)
return &uap{ return &uap{
// 3x each - stat table: total, guest, user // 3x each - stat table: total, guest, user
ApWifiTxDropped: prometheus.NewDesc(ns+"stat_wifi_transmt_dropped_total", "Wifi Transmissions Dropped", labelA, nil), ApWifiTxDropped: prometheus.NewDesc(ns+"stat_wifi_transmt_dropped_total", "Wifi Transmissions Dropped", labelA, nil),
@ -179,7 +179,7 @@ func (u *unifiCollector) exportUAPs(r report) {
} }
func (u *unifiCollector) exportUAP(r report, d *unifi.UAP) { func (u *unifiCollector) exportUAP(r report, d *unifi.UAP) {
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial} labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
// AP data. // AP data.
r.send([]*metricExports{ r.send([]*metricExports{
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels}, {u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
@ -209,8 +209,8 @@ func (u *unifiCollector) exportUAP(r report, d *unifi.UAP) {
func (u *unifiCollector) exportUAPstats(r report, labels []string, ap *unifi.Ap) { func (u *unifiCollector) exportUAPstats(r report, labels []string, ap *unifi.Ap) {
// labelA := append([]string{"all"}, labels[2:]...) // labelA := append([]string{"all"}, labels[2:]...)
labelU := append([]string{"user"}, labels[2:]...) labelU := append([]string{"user"}, labels[6:]...)
labelG := append([]string{"guest"}, labels[2:]...) labelG := append([]string{"guest"}, labels[6:]...)
r.send([]*metricExports{ r.send([]*metricExports{
/* // all /* // all
{u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.WifiTxDropped, labelA}, {u.UAP.ApWifiTxDropped, prometheus.CounterValue, ap.WifiTxDropped, labelA},
@ -267,10 +267,10 @@ func (u *unifiCollector) exportVAPtable(r report, labels []string, vt unifi.VapT
if !v.Up.Val { if !v.Up.Val {
continue continue
} }
labelV := append([]string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage}, labels[2:]...) labelV := append([]string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage}, labels[6:]...)
r.send([]*metricExports{ r.send([]*metricExports{
{u.UAP.VAPCcq, prometheus.GaugeValue, v.Ccq, labelV}, {u.UAP.VAPCcq, prometheus.GaugeValue, v.Ccq / 10, labelV},
{u.UAP.VAPMacFilterRejections, prometheus.CounterValue, v.MacFilterRejections, labelV}, {u.UAP.VAPMacFilterRejections, prometheus.CounterValue, v.MacFilterRejections, labelV},
{u.UAP.VAPNumSatisfactionSta, prometheus.GaugeValue, v.NumSatisfactionSta, labelV}, {u.UAP.VAPNumSatisfactionSta, prometheus.GaugeValue, v.NumSatisfactionSta, labelV},
{u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal, labelV}, {u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal, labelV},
@ -314,7 +314,7 @@ func (u *unifiCollector) exportVAPtable(r report, labels []string, vt unifi.VapT
func (u *unifiCollector) exportRadtable(r report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) { func (u *unifiCollector) exportRadtable(r report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) {
// radio table // radio table
for _, p := range rt { for _, p := range rt {
labelR := append([]string{p.Name, p.Radio}, labels[2:]...) labelR := append([]string{p.Name, p.Radio}, labels[6:]...)
r.send([]*metricExports{ r.send([]*metricExports{
{u.UAP.RadioCurrentAntennaGain, prometheus.GaugeValue, p.CurrentAntennaGain, labelR}, {u.UAP.RadioCurrentAntennaGain, prometheus.GaugeValue, p.CurrentAntennaGain, labelR},
{u.UAP.RadioHt, prometheus.GaugeValue, p.Ht, labelR}, {u.UAP.RadioHt, prometheus.GaugeValue, p.Ht, labelR},

View File

@ -36,7 +36,7 @@ type unifiDevice struct {
} }
func descDevice(ns string) *unifiDevice { func descDevice(ns string) *unifiDevice {
labels := []string{"ip", "type", "version", "site_name", "mac", "model", "name", "serial"} labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
return &unifiDevice{ return &unifiDevice{
Uptime: prometheus.NewDesc(ns+"uptime", "Uptime", labels, nil), Uptime: prometheus.NewDesc(ns+"uptime", "Uptime", labels, nil),
Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil), Temperature: prometheus.NewDesc(ns+"temperature_celsius", "Temperature", labels, nil),
@ -82,7 +82,7 @@ func (u *unifiCollector) exportUDMs(r report) {
// UDM is a collection of stats from USG, USW and UAP. It has no unique stats. // UDM is a collection of stats from USG, USW and UAP. It has no unique stats.
func (u *unifiCollector) exportUDM(r report, d *unifi.UDM) { func (u *unifiCollector) exportUDM(r report, d *unifi.UDM) {
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial} labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
// Gateway System Data. // Gateway System Data.
r.send([]*metricExports{ r.send([]*metricExports{
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels}, {u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
@ -105,7 +105,7 @@ func (u *unifiCollector) exportUDM(r report, d *unifi.UDM) {
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels}, {u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
}) })
u.exportUSWstats(r, labels, d.Stat.Sw) u.exportUSWstats(r, labels, d.Stat.Sw)
u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus) u.exportUSGstats(r, labels, d.SpeedtestStatus)
u.exportWANPorts(r, labels, d.Wan1, d.Wan2) u.exportWANPorts(r, labels, d.Wan1, d.Wan2)
u.exportPortTable(r, labels, d.PortTable) u.exportPortTable(r, labels, d.PortTable)
if d.Stat.Ap != nil && d.VapTable != nil { if d.Stat.Ap != nil && d.VapTable != nil {

View File

@ -34,8 +34,8 @@ type usg struct {
} }
func descUSG(ns string) *usg { func descUSG(ns string) *usg {
labels := []string{"ip", "type", "version", "site_name", "mac", "model", "name", "serial"} labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
labelWan := append([]string{"port"}, labels...) labelWan := append([]string{"port"}, labels[6:]...)
return &usg{ return &usg{
WanRxPackets: prometheus.NewDesc(ns+"wan_receive_packets_total", "WAN Receive Packets Total", labelWan, nil), WanRxPackets: prometheus.NewDesc(ns+"wan_receive_packets_total", "WAN Receive Packets Total", labelWan, nil),
WanRxBytes: prometheus.NewDesc(ns+"wan_receive_bytes_total", "WAN Receive Bytes Total", labelWan, nil), WanRxBytes: prometheus.NewDesc(ns+"wan_receive_bytes_total", "WAN Receive Bytes Total", labelWan, nil),
@ -58,10 +58,10 @@ func descUSG(ns string) *usg {
LanRxDropped: prometheus.NewDesc(ns+"lan_receive_dropped_total", "LAN Receive Dropped Total", labels, nil), LanRxDropped: prometheus.NewDesc(ns+"lan_receive_dropped_total", "LAN Receive Dropped Total", labels, nil),
LanTxPackets: prometheus.NewDesc(ns+"lan_transmit_packets_total", "LAN Transmit Packets Total", labels, nil), LanTxPackets: prometheus.NewDesc(ns+"lan_transmit_packets_total", "LAN Transmit Packets Total", labels, nil),
LanTxBytes: prometheus.NewDesc(ns+"lan_transmit_bytes_total", "LAN Transmit Bytes Total", labels, nil), LanTxBytes: prometheus.NewDesc(ns+"lan_transmit_bytes_total", "LAN Transmit Bytes Total", labels, nil),
Latency: prometheus.NewDesc(ns+"speedtest_latency_seconds", "Speedtest Latency", labels, nil), Latency: prometheus.NewDesc(ns+"speedtest_latency_seconds", "Speedtest Latency", labelWan, nil),
Runtime: prometheus.NewDesc(ns+"speedtest_runtime", "Speedtest Run Time", labels, nil), Runtime: prometheus.NewDesc(ns+"speedtest_runtime", "Speedtest Run Time", labelWan, nil),
XputDownload: prometheus.NewDesc(ns+"speedtest_download", "Speedtest Download Rate", labels, nil), XputDownload: prometheus.NewDesc(ns+"speedtest_download", "Speedtest Download Rate", labelWan, nil),
XputUpload: prometheus.NewDesc(ns+"speedtest_upload", "Speedtest Upload Rate", labels, nil), XputUpload: prometheus.NewDesc(ns+"speedtest_upload", "Speedtest Upload Rate", labelWan, nil),
} }
} }
@ -79,7 +79,7 @@ func (u *unifiCollector) exportUSGs(r report) {
} }
func (u *unifiCollector) exportUSG(r report, d *unifi.USG) { func (u *unifiCollector) exportUSG(r report, d *unifi.USG) {
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial} labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
// Gateway System Data. // Gateway System Data.
r.send([]*metricExports{ r.send([]*metricExports{
{u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels}, {u.Device.Uptime, prometheus.GaugeValue, d.Uptime, labels},
@ -102,13 +102,13 @@ func (u *unifiCollector) exportUSG(r report, d *unifi.USG) {
{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels}, {u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels},
}) })
u.exportWANPorts(r, labels, d.Wan1, d.Wan2) u.exportWANPorts(r, labels, d.Wan1, d.Wan2)
u.exportUSGstats(r, labels, d.Stat.Gw, d.SpeedtestStatus) u.exportUSGstats(r, labels, d.SpeedtestStatus)
} }
func (u *unifiCollector) exportUSGstats(r report, labels []string, gw *unifi.Gw, st unifi.SpeedtestStatus) { func (u *unifiCollector) exportUSGstats(r report, labels []string, st unifi.SpeedtestStatus) {
labelWan := append([]string{"all"}, labels...) labelWan := append([]string{"all"}, labels[6:]...)
r.send([]*metricExports{ r.send([]*metricExports{
// Combined Port Stats /* // Combined Port Stats
{u.USG.WanRxPackets, prometheus.CounterValue, gw.WanRxPackets, labelWan}, {u.USG.WanRxPackets, prometheus.CounterValue, gw.WanRxPackets, labelWan},
{u.USG.WanRxBytes, prometheus.CounterValue, gw.WanRxBytes, labelWan}, {u.USG.WanRxBytes, prometheus.CounterValue, gw.WanRxBytes, labelWan},
{u.USG.WanRxDropped, prometheus.CounterValue, gw.WanRxDropped, labelWan}, {u.USG.WanRxDropped, prometheus.CounterValue, gw.WanRxDropped, labelWan},
@ -120,11 +120,12 @@ func (u *unifiCollector) exportUSGstats(r report, labels []string, gw *unifi.Gw,
{u.USG.LanTxPackets, prometheus.CounterValue, gw.LanTxPackets, labels}, {u.USG.LanTxPackets, prometheus.CounterValue, gw.LanTxPackets, labels},
{u.USG.LanTxBytes, prometheus.CounterValue, gw.LanTxBytes, labels}, {u.USG.LanTxBytes, prometheus.CounterValue, gw.LanTxBytes, labels},
{u.USG.LanRxDropped, prometheus.CounterValue, gw.LanRxDropped, labels}, {u.USG.LanRxDropped, prometheus.CounterValue, gw.LanRxDropped, labels},
*/
// Speed Test Stats // Speed Test Stats
{u.USG.Latency, prometheus.GaugeValue, st.Latency.Val / 1000, labels}, {u.USG.Latency, prometheus.GaugeValue, st.Latency.Val / 1000, labelWan},
{u.USG.Runtime, prometheus.GaugeValue, st.Runtime, labels}, {u.USG.Runtime, prometheus.GaugeValue, st.Runtime, labelWan},
{u.USG.XputDownload, prometheus.GaugeValue, st.XputDownload, labels}, {u.USG.XputDownload, prometheus.GaugeValue, st.XputDownload, labelWan},
{u.USG.XputUpload, prometheus.GaugeValue, st.XputUpload, labels}, {u.USG.XputUpload, prometheus.GaugeValue, st.XputUpload, labelWan},
}) })
} }
@ -133,7 +134,7 @@ func (u *unifiCollector) exportWANPorts(r report, labels []string, wans ...unifi
if !wan.Up.Val { if !wan.Up.Val {
continue // only record UP interfaces. continue // only record UP interfaces.
} }
l := append([]string{wan.Name}, labels...) l := append([]string{wan.Name}, labels[6:]...)
r.send([]*metricExports{ r.send([]*metricExports{
{u.USG.WanRxPackets, prometheus.CounterValue, wan.RxPackets, l}, {u.USG.WanRxPackets, prometheus.CounterValue, wan.RxPackets, l},
{u.USG.WanRxBytes, prometheus.CounterValue, wan.RxBytes, l}, {u.USG.WanRxBytes, prometheus.CounterValue, wan.RxBytes, l},

View File

@ -48,26 +48,27 @@ type usw struct {
func descUSW(ns string) *usw { func descUSW(ns string) *usw {
pns := ns + "port_" pns := ns + "port_"
// The first five labels for switch are shared with (the same as) switch ports. // The first five labels for switch are shared with (the same as) switch ports.
labels := []string{"ip", "type", "version", "site_name", "mac", "model", "name", "serial"} // labels := []string{"ip", "version", "model", "serial", "type", "mac", "site_name", "name"}
labelS := []string{"site_name", "name"} // labels[6:]
// Copy labels, and replace first four with different names. // Copy labels, and replace first four with different names.
labelP := append([]string{"port_num", "port_name", "port_mac", "port_ip"}, labels[4:]...) labelP := append([]string{"port_num", "port_name", "port_mac", "port_ip"}, labelS...)
return &usw{ return &usw{
SwRxPackets: prometheus.NewDesc(ns+"switch_receive_packets_total", "Switch Packets Received Total", labels, nil), 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), SwRxBytes: prometheus.NewDesc(ns+"switch_receive_bytes_total", "Switch Bytes Received Total", labelS, nil),
SwRxErrors: prometheus.NewDesc(ns+"switch_receive_errors_total", "Switch Errors Received Total", labels, nil), SwRxErrors: prometheus.NewDesc(ns+"switch_receive_errors_total", "Switch Errors Received Total", labelS, nil),
SwRxDropped: prometheus.NewDesc(ns+"switch_receive_dropped_total", "Switch Dropped Received Total", labels, nil), SwRxDropped: prometheus.NewDesc(ns+"switch_receive_dropped_total", "Switch Dropped Received Total", labelS, nil),
SwRxCrypts: prometheus.NewDesc(ns+"switch_receive_crypts_total", "Switch Crypts Received Total", labels, nil), SwRxCrypts: prometheus.NewDesc(ns+"switch_receive_crypts_total", "Switch Crypts Received Total", labelS, nil),
SwRxFrags: prometheus.NewDesc(ns+"switch_receive_frags_total", "Switch Frags Received Total", labels, nil), SwRxFrags: prometheus.NewDesc(ns+"switch_receive_frags_total", "Switch Frags Received Total", labelS, nil),
SwTxPackets: prometheus.NewDesc(ns+"switch_transmit_packets_total", "Switch Packets Transmit Total", labels, nil), SwTxPackets: prometheus.NewDesc(ns+"switch_transmit_packets_total", "Switch Packets Transmit Total", labelS, nil),
SwTxBytes: prometheus.NewDesc(ns+"switch_transmit_bytes_total", "Switch Bytes Transmit Total", labels, nil), SwTxBytes: prometheus.NewDesc(ns+"switch_transmit_bytes_total", "Switch Bytes Transmit Total", labelS, nil),
SwTxErrors: prometheus.NewDesc(ns+"switch_transmit_errors_total", "Switch Errors Transmit Total", labels, nil), SwTxErrors: prometheus.NewDesc(ns+"switch_transmit_errors_total", "Switch Errors Transmit Total", labelS, nil),
SwTxDropped: prometheus.NewDesc(ns+"switch_transmit_dropped_total", "Switch Dropped Transmit Total", labels, nil), SwTxDropped: prometheus.NewDesc(ns+"switch_transmit_dropped_total", "Switch Dropped Transmit Total", labelS, nil),
SwTxRetries: prometheus.NewDesc(ns+"switch_transmit_retries_total", "Switch Retries Transmit Total", labels, nil), SwTxRetries: prometheus.NewDesc(ns+"switch_transmit_retries_total", "Switch Retries Transmit Total", labelS, nil),
SwRxMulticast: prometheus.NewDesc(ns+"switch_receive_multicast_total", "Switch Multicast Receive Total", labels, nil), SwRxMulticast: prometheus.NewDesc(ns+"switch_receive_multicast_total", "Switch Multicast Receive Total", labelS, nil),
SwRxBroadcast: prometheus.NewDesc(ns+"switch_receive_broadcast_total", "Switch Broadcast Receive Total", labels, nil), SwRxBroadcast: prometheus.NewDesc(ns+"switch_receive_broadcast_total", "Switch Broadcast Receive Total", labelS, nil),
SwTxMulticast: prometheus.NewDesc(ns+"switch_transmit_multicast_total", "Switch Multicast Transmit Total", labels, nil), SwTxMulticast: prometheus.NewDesc(ns+"switch_transmit_multicast_total", "Switch Multicast Transmit Total", labelS, nil),
SwTxBroadcast: prometheus.NewDesc(ns+"switch_transmit_broadcast_total", "Switch Broadcast Transmit Total", labels, nil), SwTxBroadcast: prometheus.NewDesc(ns+"switch_transmit_broadcast_total", "Switch Broadcast Transmit Total", labelS, nil),
SwBytes: prometheus.NewDesc(ns+"switch_bytes_total", "Switch Bytes Transferred Total", labels, nil), SwBytes: prometheus.NewDesc(ns+"switch_bytes_total", "Switch Bytes Transferred Total", labelS, nil),
// per-port data // per-port data
PoeCurrent: prometheus.NewDesc(pns+"poe_amperes", "POE Current", labelP, nil), PoeCurrent: prometheus.NewDesc(pns+"poe_amperes", "POE Current", labelP, nil),
PoePower: prometheus.NewDesc(pns+"poe_watts", "POE Power", labelP, nil), PoePower: prometheus.NewDesc(pns+"poe_watts", "POE Power", labelP, nil),
@ -105,7 +106,7 @@ func (u *unifiCollector) exportUSWs(r report) {
} }
func (u *unifiCollector) exportUSW(r report, d *unifi.USW) { func (u *unifiCollector) exportUSW(r report, d *unifi.USW) {
labels := []string{d.IP, d.Type, d.Version, d.SiteName, d.Mac, d.Model, d.Name, d.Serial} labels := []string{d.IP, d.Version, d.Model, d.Serial, d.Type, d.Mac, d.SiteName, d.Name}
if d.HasTemperature.Val { if d.HasTemperature.Val {
r.send([]*metricExports{{u.Device.Temperature, prometheus.GaugeValue, d.GeneralTemperature, labels}}) r.send([]*metricExports{{u.Device.Temperature, prometheus.GaugeValue, d.GeneralTemperature, labels}})
} }
@ -137,23 +138,24 @@ func (u *unifiCollector) exportUSW(r report, d *unifi.USW) {
} }
func (u *unifiCollector) exportUSWstats(r report, labels []string, sw *unifi.Sw) { func (u *unifiCollector) exportUSWstats(r report, labels []string, sw *unifi.Sw) {
labelS := labels[6:]
r.send([]*metricExports{ r.send([]*metricExports{
{u.USW.SwRxPackets, prometheus.CounterValue, sw.RxPackets, labels}, {u.USW.SwRxPackets, prometheus.CounterValue, sw.RxPackets, labelS},
{u.USW.SwRxBytes, prometheus.CounterValue, sw.RxBytes, labels}, {u.USW.SwRxBytes, prometheus.CounterValue, sw.RxBytes, labelS},
{u.USW.SwRxErrors, prometheus.CounterValue, sw.RxErrors, labels}, {u.USW.SwRxErrors, prometheus.CounterValue, sw.RxErrors, labelS},
{u.USW.SwRxDropped, prometheus.CounterValue, sw.RxDropped, labels}, {u.USW.SwRxDropped, prometheus.CounterValue, sw.RxDropped, labelS},
{u.USW.SwRxCrypts, prometheus.CounterValue, sw.RxCrypts, labels}, {u.USW.SwRxCrypts, prometheus.CounterValue, sw.RxCrypts, labelS},
{u.USW.SwRxFrags, prometheus.CounterValue, sw.RxFrags, labels}, {u.USW.SwRxFrags, prometheus.CounterValue, sw.RxFrags, labelS},
{u.USW.SwTxPackets, prometheus.CounterValue, sw.TxPackets, labels}, {u.USW.SwTxPackets, prometheus.CounterValue, sw.TxPackets, labelS},
{u.USW.SwTxBytes, prometheus.CounterValue, sw.TxBytes, labels}, {u.USW.SwTxBytes, prometheus.CounterValue, sw.TxBytes, labelS},
{u.USW.SwTxErrors, prometheus.CounterValue, sw.TxErrors, labels}, {u.USW.SwTxErrors, prometheus.CounterValue, sw.TxErrors, labelS},
{u.USW.SwTxDropped, prometheus.CounterValue, sw.TxDropped, labels}, {u.USW.SwTxDropped, prometheus.CounterValue, sw.TxDropped, labelS},
{u.USW.SwTxRetries, prometheus.CounterValue, sw.TxRetries, labels}, {u.USW.SwTxRetries, prometheus.CounterValue, sw.TxRetries, labelS},
{u.USW.SwRxMulticast, prometheus.CounterValue, sw.RxMulticast, labels}, {u.USW.SwRxMulticast, prometheus.CounterValue, sw.RxMulticast, labelS},
{u.USW.SwRxBroadcast, prometheus.CounterValue, sw.RxBroadcast, labels}, {u.USW.SwRxBroadcast, prometheus.CounterValue, sw.RxBroadcast, labelS},
{u.USW.SwTxMulticast, prometheus.CounterValue, sw.TxMulticast, labels}, {u.USW.SwTxMulticast, prometheus.CounterValue, sw.TxMulticast, labelS},
{u.USW.SwTxBroadcast, prometheus.CounterValue, sw.TxBroadcast, labels}, {u.USW.SwTxBroadcast, prometheus.CounterValue, sw.TxBroadcast, labelS},
{u.USW.SwBytes, prometheus.CounterValue, sw.Bytes, labels}, {u.USW.SwBytes, prometheus.CounterValue, sw.Bytes, labelS},
}) })
} }
@ -164,7 +166,7 @@ func (u *unifiCollector) exportPortTable(r report, labels []string, pt []unifi.P
continue continue
} }
// Copy labels, and add four new ones. // Copy labels, and add four new ones.
l := append([]string{p.PortIdx.Txt, p.Name, p.Mac, p.IP}, labels[4:]...) l := append([]string{p.PortIdx.Txt, p.Name, p.Mac, p.IP}, labels[6:]...)
if p.PoeEnable.Val && p.PortPoe.Val { if p.PoeEnable.Val && p.PortPoe.Val {
r.send([]*metricExports{ r.send([]*metricExports{
{u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, l}, {u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, l},