From 1294cd8ccf8b3c760c31d0911703451084ae470f Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sun, 1 Dec 2019 18:29:08 +0100 Subject: [PATCH 1/5] Update channel utilization metrics * Unit is percent. * Drop "total" as it is the sum of transmit and receive. Signed-off-by: Ben Kochie --- pkg/promunifi/uap.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/promunifi/uap.go b/pkg/promunifi/uap.go index ed8507df..acdf2637 100644 --- a/pkg/promunifi/uap.go +++ b/pkg/promunifi/uap.go @@ -72,7 +72,6 @@ type uap struct { RadioChannel *prometheus.Desc RadioCuSelfRx *prometheus.Desc RadioCuSelfTx *prometheus.Desc - RadioCuTotal *prometheus.Desc RadioExtchannel *prometheus.Desc RadioGain *prometheus.Desc RadioGuestNumSta *prometheus.Desc @@ -152,9 +151,8 @@ func descUAP(ns string) *uap { RadioTxPower: prometheus.NewDesc(ns+"radio_transmit_power", "Radio Transmit Power", labelR, nil), RadioAstBeXmit: prometheus.NewDesc(ns+"radio_ast_be_xmit", "Radio AstBe Transmit", labelR, nil), RadioChannel: prometheus.NewDesc(ns+"radio_channel", "Radio Channel", labelR, nil), - RadioCuSelfRx: prometheus.NewDesc(ns+"radio_channel_utilization_receive", "Radio Channel Utilization Receive", labelR, nil), - RadioCuSelfTx: prometheus.NewDesc(ns+"radio_channel_utilization_transmit", "Radio Channel Utilization Transmit", labelR, nil), - RadioCuTotal: prometheus.NewDesc(ns+"radio_channel_utilization_total", "Radio Channel Utilization", labelR, nil), + RadioCuSelfRx: prometheus.NewDesc(ns+"radio_channel_utilization_receive_percent", "Radio Channel Utilization Receive", labelR, nil), + RadioCuSelfTx: prometheus.NewDesc(ns+"radio_channel_utilization_transmit_percent", "Radio Channel Utilization Transmit", labelR, nil), RadioExtchannel: prometheus.NewDesc(ns+"radio_ext_channel", "Radio Ext Channel", labelR, nil), RadioGain: prometheus.NewDesc(ns+"radio_gain", "Radio Gain", labelR, nil), RadioGuestNumSta: prometheus.NewDesc(ns+"radio_guest_stations", "Radio Guest Station Count", labelR, nil), @@ -323,7 +321,6 @@ func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTabl {u.UAP.RadioChannel, prometheus.GaugeValue, t.Channel, labelR}, {u.UAP.RadioCuSelfRx, prometheus.GaugeValue, t.CuSelfRx, labelR}, {u.UAP.RadioCuSelfTx, prometheus.GaugeValue, t.CuSelfTx, labelR}, - {u.UAP.RadioCuTotal, prometheus.GaugeValue, t.CuTotal, labelR}, {u.UAP.RadioExtchannel, prometheus.GaugeValue, t.Extchannel, labelR}, {u.UAP.RadioGain, prometheus.GaugeValue, t.Gain, labelR}, {u.UAP.RadioGuestNumSta, prometheus.GaugeValue, t.GuestNumSta, labelR}, From 3b515b854e788135983986fc4919ee05b463fb30 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sun, 1 Dec 2019 19:26:20 +0100 Subject: [PATCH 2/5] Fix radio_transmit metric type The metrics radio_transmit_{packets,retries} appear to gauges, not counters. Signed-off-by: Ben Kochie --- pkg/promunifi/uap.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/promunifi/uap.go b/pkg/promunifi/uap.go index acdf2637..9ece7e80 100644 --- a/pkg/promunifi/uap.go +++ b/pkg/promunifi/uap.go @@ -158,8 +158,8 @@ func descUAP(ns string) *uap { RadioGuestNumSta: prometheus.NewDesc(ns+"radio_guest_stations", "Radio Guest Station Count", labelR, nil), RadioNumSta: prometheus.NewDesc(ns+"radio_stations", "Radio Total Station Count", labelR, nil), RadioUserNumSta: prometheus.NewDesc(ns+"radio_user_stations", "Radio User Station Count", labelR, nil), - RadioTxPackets: prometheus.NewDesc(ns+"radio_transmit_packets_total", "Radio Transmitted Packets", labelR, nil), - RadioTxRetries: prometheus.NewDesc(ns+"radio_transmit_retries_total", "Radio Transmit Retries", labelR, nil), + RadioTxPackets: prometheus.NewDesc(ns+"radio_transmit_packets", "Radio Transmitted Packets", labelR, nil), + RadioTxRetries: prometheus.NewDesc(ns+"radio_transmit_retries", "Radio Transmit Retries", labelR, nil), } } @@ -326,8 +326,8 @@ func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTabl {u.UAP.RadioGuestNumSta, prometheus.GaugeValue, t.GuestNumSta, labelR}, {u.UAP.RadioNumSta, prometheus.GaugeValue, t.NumSta, labelR}, {u.UAP.RadioUserNumSta, prometheus.GaugeValue, t.UserNumSta, labelR}, - {u.UAP.RadioTxPackets, prometheus.CounterValue, t.TxPackets, labelR}, - {u.UAP.RadioTxRetries, prometheus.CounterValue, t.TxRetries, labelR}, + {u.UAP.RadioTxPackets, prometheus.GaugeValue, t.TxPackets, labelR}, + {u.UAP.RadioTxRetries, prometheus.GaugeValue, t.TxRetries, labelR}, }) } } From 1df763e684e52da6c30aeca5fed474c4cfddcbb9 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sun, 1 Dec 2019 19:48:59 +0100 Subject: [PATCH 3/5] Convert Prometheus percents to ratio Typically we like to use ratio in Prometheus rather than percent as it is easier to do math with. Signed-off-by: Ben Kochie --- pkg/promunifi/clients.go | 8 ++++---- pkg/promunifi/uap.go | 16 ++++++++-------- pkg/promunifi/udm.go | 8 ++++---- pkg/promunifi/usw.go | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/promunifi/clients.go b/pkg/promunifi/clients.go index ac12bdf8..ed0d1f11 100644 --- a/pkg/promunifi/clients.go +++ b/pkg/promunifi/clients.go @@ -46,8 +46,8 @@ func descClient(ns string) *uclient { return &uclient{ Anomalies: prometheus.NewDesc(ns+"anomalies", "Client Anomalies", labelW, nil), BytesR: prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelW, nil), - CCQ: prometheus.NewDesc(ns+"ccq_percent", "Client Connection Quality", labelW, nil), - Satisfaction: prometheus.NewDesc(ns+"satisfaction_percent", "Client Satisfaction", labelW, nil), + CCQ: prometheus.NewDesc(ns+"ccq_ratio", "Client Connection Quality", labelW, nil), + Satisfaction: prometheus.NewDesc(ns+"satisfaction_ratoi", "Client Satisfaction", labelW, nil), Noise: prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelW, nil), RoamCount: prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelW, nil), RSSI: prometheus.NewDesc(ns+"rssi_db", "Client RSSI", labelW, nil), @@ -95,8 +95,8 @@ func (u *promUnifi) exportClient(r report, c *unifi.Client) { labelW[len(labelW)-1] = "false" r.send([]*metric{ {u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labelW}, - {u.Client.CCQ, prometheus.GaugeValue, c.Ccq / 10, labelW}, - {u.Client.Satisfaction, prometheus.GaugeValue, c.Satisfaction, labelW}, + {u.Client.CCQ, prometheus.GaugeValue, c.Ccq / 1000, labelW}, + {u.Client.Satisfaction, prometheus.GaugeValue, c.Satisfaction.Val / 100.0, labelW}, {u.Client.Noise, prometheus.GaugeValue, c.Noise, labelW}, {u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labelW}, {u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labelW}, diff --git a/pkg/promunifi/uap.go b/pkg/promunifi/uap.go index 9ece7e80..9142fb9d 100644 --- a/pkg/promunifi/uap.go +++ b/pkg/promunifi/uap.go @@ -107,8 +107,8 @@ func descUAP(ns string) *uap { VAPMacFilterRejections: prometheus.NewDesc(ns+"vap_mac_filter_rejects_total", "VAP MAC Filter Rejections", labelV, nil), VAPNumSatisfactionSta: prometheus.NewDesc(ns+"vap_satisfaction_stations", "VAP Number Satisifaction Stations", labelV, nil), VAPAvgClientSignal: prometheus.NewDesc(ns+"vap_average_client_signal", "VAP Average Client Signal", labelV, nil), - VAPSatisfaction: prometheus.NewDesc(ns+"vap_satisfaction_percent", "VAP Satisfaction", labelV, nil), - VAPSatisfactionNow: prometheus.NewDesc(ns+"vap_satisfaction_now_percent", "VAP Satisfaction Now", labelV, nil), + VAPSatisfaction: prometheus.NewDesc(ns+"vap_satisfaction_ratoi", "VAP Satisfaction", labelV, nil), + VAPSatisfactionNow: prometheus.NewDesc(ns+"vap_satisfaction_now_ratoi", "VAP Satisfaction Now", labelV, nil), VAPDNSAvgLatency: prometheus.NewDesc(ns+"vap_dns_latency_average_seconds", "VAP DNS Latency Average", labelV, nil), VAPRxBytes: prometheus.NewDesc(ns+"vap_receive_bytes_total", "VAP Bytes Received", labelV, nil), VAPRxCrypts: prometheus.NewDesc(ns+"vap_receive_crypts_total", "VAP Crypts Received", labelV, nil), @@ -151,8 +151,8 @@ func descUAP(ns string) *uap { RadioTxPower: prometheus.NewDesc(ns+"radio_transmit_power", "Radio Transmit Power", labelR, nil), RadioAstBeXmit: prometheus.NewDesc(ns+"radio_ast_be_xmit", "Radio AstBe Transmit", labelR, nil), RadioChannel: prometheus.NewDesc(ns+"radio_channel", "Radio Channel", labelR, nil), - RadioCuSelfRx: prometheus.NewDesc(ns+"radio_channel_utilization_receive_percent", "Radio Channel Utilization Receive", labelR, nil), - RadioCuSelfTx: prometheus.NewDesc(ns+"radio_channel_utilization_transmit_percent", "Radio Channel Utilization Transmit", labelR, nil), + RadioCuSelfRx: prometheus.NewDesc(ns+"radio_channel_utilization_receive_ratio", "Radio Channel Utilization Receive", labelR, nil), + RadioCuSelfTx: prometheus.NewDesc(ns+"radio_channel_utilization_transmit_ratio", "Radio Channel Utilization Transmit", labelR, nil), RadioExtchannel: prometheus.NewDesc(ns+"radio_ext_channel", "Radio Ext Channel", labelR, nil), RadioGain: prometheus.NewDesc(ns+"radio_gain", "Radio Gain", labelR, nil), RadioGuestNumSta: prometheus.NewDesc(ns+"radio_guest_stations", "Radio Guest Station Count", labelR, nil), @@ -260,8 +260,8 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable) {u.UAP.VAPMacFilterRejections, prometheus.CounterValue, v.MacFilterRejections, labelV}, {u.UAP.VAPNumSatisfactionSta, prometheus.GaugeValue, v.NumSatisfactionSta, labelV}, {u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal, labelV}, - {u.UAP.VAPSatisfaction, prometheus.GaugeValue, v.Satisfaction, labelV}, - {u.UAP.VAPSatisfactionNow, prometheus.GaugeValue, v.SatisfactionNow, labelV}, + {u.UAP.VAPSatisfaction, prometheus.GaugeValue, v.Satisfaction.Val / 100.0, labelV}, + {u.UAP.VAPSatisfactionNow, prometheus.GaugeValue, v.SatisfactionNow.Val / 100.0, labelV}, {u.UAP.VAPDNSAvgLatency, prometheus.GaugeValue, v.DNSAvgLatency.Val / 1000, labelV}, {u.UAP.VAPRxBytes, prometheus.CounterValue, v.RxBytes, labelV}, {u.UAP.VAPRxCrypts, prometheus.CounterValue, v.RxCrypts, labelV}, @@ -319,8 +319,8 @@ func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTabl {u.UAP.RadioTxPower, prometheus.GaugeValue, t.TxPower, labelR}, {u.UAP.RadioAstBeXmit, prometheus.GaugeValue, t.AstBeXmit, labelR}, {u.UAP.RadioChannel, prometheus.GaugeValue, t.Channel, labelR}, - {u.UAP.RadioCuSelfRx, prometheus.GaugeValue, t.CuSelfRx, labelR}, - {u.UAP.RadioCuSelfTx, prometheus.GaugeValue, t.CuSelfTx, labelR}, + {u.UAP.RadioCuSelfRx, prometheus.GaugeValue, t.CuSelfRx.Val / 100.0, labelR}, + {u.UAP.RadioCuSelfTx, prometheus.GaugeValue, t.CuSelfTx.Val / 100.0, labelR}, {u.UAP.RadioExtchannel, prometheus.GaugeValue, t.Extchannel, labelR}, {u.UAP.RadioGain, prometheus.GaugeValue, t.Gain, labelR}, {u.UAP.RadioGuestNumSta, prometheus.GaugeValue, t.GuestNumSta, labelR}, diff --git a/pkg/promunifi/udm.go b/pkg/promunifi/udm.go index 9a17b41b..ae539697 100644 --- a/pkg/promunifi/udm.go +++ b/pkg/promunifi/udm.go @@ -62,8 +62,8 @@ func descDevice(ns string) *unifiDevice { MemUsed: prometheus.NewDesc(ns+"memory_used_bytes", "System Memory Used", labels, nil), MemTotal: prometheus.NewDesc(ns+"memory_installed_bytes", "System Installed Memory", labels, nil), MemBuffer: prometheus.NewDesc(ns+"memory_buffer_bytes", "System Memory Buffer", labels, nil), - CPU: prometheus.NewDesc(ns+"cpu_utilization_percent", "System CPU % Utilized", labels, nil), - Mem: prometheus.NewDesc(ns+"memory_utilization_percent", "System Memory % Utilized", labels, nil), + CPU: prometheus.NewDesc(ns+"cpu_utilization_ratio", "System CPU % Utilized", labels, nil), + Mem: prometheus.NewDesc(ns+"memory_utilization_ratio", "System Memory % Utilized", labels, nil), } } @@ -88,8 +88,8 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { {u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels}, {u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels}, {u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels}, - {u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels}, - {u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels}, + {u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU.Val / 100.0, labels}, + {u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem.Val / 100.0, labels}, }) // Switch Data diff --git a/pkg/promunifi/usw.go b/pkg/promunifi/usw.go index 88f7e190..16e07ee7 100644 --- a/pkg/promunifi/usw.go +++ b/pkg/promunifi/usw.go @@ -78,7 +78,7 @@ func descUSW(ns string) *usw { RxErrors: prometheus.NewDesc(pns+"receive_errors_total", "Total Receive Errors", labelP, nil), RxMulticast: prometheus.NewDesc(pns+"receive_multicast_total", "Total Receive Multicast", labelP, nil), RxPackets: prometheus.NewDesc(pns+"receive_packets_total", "Total Receive Packets", labelP, nil), - Satisfaction: prometheus.NewDesc(pns+"satisfaction_percent", "Satisfaction", labelP, nil), + Satisfaction: prometheus.NewDesc(pns+"satisfaction_ratoi", "Satisfaction", labelP, nil), Speed: prometheus.NewDesc(pns+"port_speed_bps", "Speed", labelP, nil), TxBroadcast: prometheus.NewDesc(pns+"transmit_broadcast_total", "Total Transmit Broadcast", labelP, nil), TxBytes: prometheus.NewDesc(pns+"transmit_bytes_total", "Total Transmit Bytes", labelP, nil), @@ -168,7 +168,7 @@ func (u *promUnifi) exportPortTable(r report, labels []string, pt []unifi.Port) {u.USW.RxErrors, prometheus.CounterValue, p.RxErrors, labelP}, {u.USW.RxMulticast, prometheus.CounterValue, p.RxMulticast, labelP}, {u.USW.RxPackets, prometheus.CounterValue, p.RxPackets, labelP}, - {u.USW.Satisfaction, prometheus.GaugeValue, p.Satisfaction, labelP}, + {u.USW.Satisfaction, prometheus.GaugeValue, p.Satisfaction.Val / 100.0, labelP}, {u.USW.Speed, prometheus.GaugeValue, p.Speed.Val * 1000000, labelP}, {u.USW.TxBroadcast, prometheus.CounterValue, p.TxBroadcast, labelP}, {u.USW.TxBytes, prometheus.CounterValue, p.TxBytes, labelP}, From 356ce45eb64ddfdc0b1d5f8d71815379bc54a7d0 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 1 Dec 2019 17:24:35 -0800 Subject: [PATCH 4/5] Apply suggestions from code review --- pkg/promunifi/clients.go | 2 +- pkg/promunifi/uap.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/promunifi/clients.go b/pkg/promunifi/clients.go index ed0d1f11..3464614a 100644 --- a/pkg/promunifi/clients.go +++ b/pkg/promunifi/clients.go @@ -47,7 +47,7 @@ func descClient(ns string) *uclient { Anomalies: prometheus.NewDesc(ns+"anomalies", "Client Anomalies", labelW, nil), BytesR: prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelW, nil), CCQ: prometheus.NewDesc(ns+"ccq_ratio", "Client Connection Quality", labelW, nil), - Satisfaction: prometheus.NewDesc(ns+"satisfaction_ratoi", "Client Satisfaction", labelW, nil), + Satisfaction: prometheus.NewDesc(ns+"satisfaction_ratio", "Client Satisfaction", labelW, nil), Noise: prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelW, nil), RoamCount: prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelW, nil), RSSI: prometheus.NewDesc(ns+"rssi_db", "Client RSSI", labelW, nil), diff --git a/pkg/promunifi/uap.go b/pkg/promunifi/uap.go index 9142fb9d..c5a4f699 100644 --- a/pkg/promunifi/uap.go +++ b/pkg/promunifi/uap.go @@ -107,8 +107,8 @@ func descUAP(ns string) *uap { VAPMacFilterRejections: prometheus.NewDesc(ns+"vap_mac_filter_rejects_total", "VAP MAC Filter Rejections", labelV, nil), VAPNumSatisfactionSta: prometheus.NewDesc(ns+"vap_satisfaction_stations", "VAP Number Satisifaction Stations", labelV, nil), VAPAvgClientSignal: prometheus.NewDesc(ns+"vap_average_client_signal", "VAP Average Client Signal", labelV, nil), - VAPSatisfaction: prometheus.NewDesc(ns+"vap_satisfaction_ratoi", "VAP Satisfaction", labelV, nil), - VAPSatisfactionNow: prometheus.NewDesc(ns+"vap_satisfaction_now_ratoi", "VAP Satisfaction Now", labelV, nil), + VAPSatisfaction: prometheus.NewDesc(ns+"vap_satisfaction_ratio", "VAP Satisfaction", labelV, nil), + VAPSatisfactionNow: prometheus.NewDesc(ns+"vap_satisfaction_now_ratio", "VAP Satisfaction Now", labelV, nil), VAPDNSAvgLatency: prometheus.NewDesc(ns+"vap_dns_latency_average_seconds", "VAP DNS Latency Average", labelV, nil), VAPRxBytes: prometheus.NewDesc(ns+"vap_receive_bytes_total", "VAP Bytes Received", labelV, nil), VAPRxCrypts: prometheus.NewDesc(ns+"vap_receive_crypts_total", "VAP Crypts Received", labelV, nil), From 24d175f73be5a5c0aa963ec57107e78445e52f24 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 1 Dec 2019 17:25:49 -0800 Subject: [PATCH 5/5] Apply suggestions from code review --- pkg/promunifi/usw.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/promunifi/usw.go b/pkg/promunifi/usw.go index 9db9db7c..8d6a1bdf 100644 --- a/pkg/promunifi/usw.go +++ b/pkg/promunifi/usw.go @@ -78,7 +78,7 @@ func descUSW(ns string) *usw { RxErrors: prometheus.NewDesc(pns+"receive_errors_total", "Total Receive Errors", labelP, nil), RxMulticast: prometheus.NewDesc(pns+"receive_multicast_total", "Total Receive Multicast", labelP, nil), RxPackets: prometheus.NewDesc(pns+"receive_packets_total", "Total Receive Packets", labelP, nil), - Satisfaction: prometheus.NewDesc(pns+"satisfaction_ratoi", "Satisfaction", labelP, nil), + Satisfaction: prometheus.NewDesc(pns+"satisfaction_ratio", "Satisfaction", labelP, nil), Speed: prometheus.NewDesc(pns+"port_speed_bps", "Speed", labelP, nil), TxBroadcast: prometheus.NewDesc(pns+"transmit_broadcast_total", "Total Transmit Broadcast", labelP, nil), TxBytes: prometheus.NewDesc(pns+"transmit_bytes_total", "Total Transmit Bytes", labelP, nil),