Files
Cody Lee 54bb3bfe8e feat(devices): add UDB (UniFi Device Bridge) support (#968)
Adds metrics export for UDB devices (UDB-Switch, UDB-Pro, UDB-Pro-Sector)
to all output backends. UDB-Switch is a hybrid device combining PoE switch
ports with WiFi 7 wireless bridge capability (5GHz + 6GHz radios).

- pkg/promunifi/udb.go: Prometheus metrics exporter for UDB
- pkg/influxunifi/udb.go: InfluxDB batch exporter for UDB
- pkg/datadogunifi/udb.go: Datadog batch exporter for UDB
- Wire UDB into switchExport in all three output plugins
- Add UDB to inputunifi device collection and site name override
- Update integration test expectations for InfluxDB and Datadog
- Fix addUBB() bug: was incorrectly incrementing UCI counter

Resolves #947

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 15:00:18 -05:00

66 lines
2.0 KiB
Go

package influxunifi
import "github.com/unpoller/unifi/v5"
// udbT is used as a name for printed/logged counters.
const udbT = item("UDB")
// batchUDB generates datapoints for UDB (UniFi Device Bridge) devices.
// UDB-Switch is a hybrid device combining switch ports with WiFi 7
// wireless bridge capability.
func (u *InfluxUnifi) batchUDB(r report, s *unifi.UDB) {
if !s.Adopted.Val || s.Locating.Val {
return
}
tags := map[string]string{
"mac": s.Mac,
"site_name": s.SiteName,
"source": s.SourceName,
"name": s.Name,
"version": s.Version,
"model": s.Model,
"serial": s.Serial,
"type": s.Type,
}
fields := Combine(
u.batchUSWstat(s.Stat.Sw),
u.batchSysStats(s.SysStats, s.SystemStats),
map[string]any{
"guest-num_sta": s.GuestNumSta.Val,
"ip": s.IP,
"bytes": s.Bytes.Val,
"fan_level": s.FanLevel.Val,
"general_temperature": s.GeneralTemperature.Val,
"last_seen": s.LastSeen.Val,
"rx_bytes": s.RxBytes.Val,
"tx_bytes": s.TxBytes.Val,
"uptime": s.Uptime.Val,
"state": s.State.Val,
"user-num_sta": s.UserNumSta.Val,
"num_sta": s.NumSta.Val,
"upgradeable": s.Upgradable.Val,
"guest-wlan-num_sta": s.GuestWlanNumSta.Val,
"user-wlan-num_sta": s.UserWlanNumSta.Val,
"satisfaction": s.Satisfaction.Val,
"total_max_power": s.TotalMaxPower.Val,
"uplink_speed": s.Uplink.Speed.Val,
"uplink_max_speed": s.Uplink.MaxSpeed.Val,
"uplink_latency": s.Uplink.Latency.Val,
"uplink_uptime": s.Uplink.Uptime.Val,
})
r.addCount(udbT)
r.send(&metric{Table: "udb", Tags: tags, Fields: fields})
// Port table (reuse USW function)
u.batchPortTable(r, tags, s.PortTable)
// Radio table (reuse UAP functions)
u.processRadTable(r, tags, s.RadioTable, s.RadioTableStats)
// VAP table (reuse UAP function)
u.processVAPTable(r, tags, s.VapTable)
}