Update uap.go

add band label to per-VAP and per-radio metrics
This commit is contained in:
Kevin
2026-09-23 13:30:25 +02:00
committed by GitHub
parent d46146bdd0
commit 2152c020f9
+19
View File
@@ -125,6 +125,23 @@ func (u *InfluxUnifi) processUAPstats(ap *unifi.Ap) map[string]any {
} }
} }
// radioBand maps a UniFi radio identifier to its frequency band in GHz.
// UniFi reports the radio as ng (2.4 GHz), na (5 GHz) or 6e (6 GHz); the band
// is not carried as its own field on the radio/VAP structs, so it is derived
// here. Unknown identifiers yield an empty band label.
func radioBand(radio string) string {
switch radio {
case "ng":
return "2.4"
case "na":
return "5"
case "6e":
return "6"
default:
return ""
}
}
// processVAPTable creates points for Wifi Radios. This works with several types of UAP-capable devices. // processVAPTable creates points for Wifi Radios. This works with several types of UAP-capable devices.
func (u *InfluxUnifi) processVAPTable(r report, t map[string]string, vt unifi.VapTable) { // nolint: funlen func (u *InfluxUnifi) processVAPTable(r report, t map[string]string, vt unifi.VapTable) { // nolint: funlen
for _, s := range vt { for _, s := range vt {
@@ -138,6 +155,7 @@ func (u *InfluxUnifi) processVAPTable(r report, t map[string]string, vt unifi.Va
"name": s.Name, "name": s.Name,
"radio_name": s.RadioName, "radio_name": s.RadioName,
"radio": s.Radio, "radio": s.Radio,
"band": radioBand(s.Radio),
"essid": s.Essid, "essid": s.Essid,
"site_id": s.SiteID, "site_id": s.SiteID,
"usage": s.Usage, "usage": s.Usage,
@@ -198,6 +216,7 @@ func (u *InfluxUnifi) processRadTable(r report, t map[string]string, rt unifi.Ra
"source": t["source"], "source": t["source"],
"channel": p.Channel.Txt, "channel": p.Channel.Txt,
"radio": p.Radio, "radio": p.Radio,
"band": radioBand(p.Radio),
} }
fields := map[string]any{ fields := map[string]any{
"current_antenna_gain": p.CurrentAntennaGain.Val, "current_antenna_gain": p.CurrentAntennaGain.Val,