Merge pull request #918 from unpoller/issue-417

Populate num_user field for VPN subsystem metrics
This commit is contained in:
Cody Lee
2026-01-25 12:10:53 -06:00
committed by GitHub
3 changed files with 22 additions and 2 deletions

View File

@@ -22,8 +22,14 @@ func (u *DatadogUnifi) reportSite(r report, s *unifi.Site) {
tag("lan_ip", h.LanIP),
}
// For VPN subsystem, use RemoteUserNumActive for num_user if NumUser is not set
numUser := h.NumUser.Val
if h.Subsystem == "vpn" && numUser == 0 && h.RemoteUserNumActive.Val > 0 {
numUser = h.RemoteUserNumActive.Val
}
data := map[string]float64{
"num_user": h.NumUser.Val,
"num_user": numUser,
"num_guest": h.NumGuest.Val,
"num_iot": h.NumIot.Val,
"tx_bytes_r": h.TxBytesR.Val,

View File

@@ -19,8 +19,15 @@ func (u *InfluxUnifi) batchSite(r report, s *unifi.Site) {
"gw_name": h.GwName,
"lan_ip": h.LanIP,
}
// For VPN subsystem, use RemoteUserNumActive for num_user if NumUser is not set
numUser := h.NumUser.Val
if h.Subsystem == "vpn" && numUser == 0 && h.RemoteUserNumActive.Val > 0 {
numUser = h.RemoteUserNumActive.Val
}
fields := map[string]any{
"num_user": h.NumUser.Val,
"num_user": numUser,
"num_guest": h.NumGuest.Val,
"num_iot": h.NumIot.Val,
"tx_bytes-r": h.TxBytesR.Int64(),

View File

@@ -146,7 +146,14 @@ func (u *promUnifi) exportSite(r report, s *unifi.Site) {
{u.Site.NumSw, gauge, h.NumSw, labels},
})
case "vpn":
// For VPN subsystem, use RemoteUserNumActive for NumUser if NumUser is not set
numUser := h.NumUser.Val
if numUser == 0 && h.RemoteUserNumActive.Val > 0 {
numUser = h.RemoteUserNumActive.Val
}
r.send([]*metric{
{u.Site.NumUser, gauge, numUser, labels},
{u.Site.RemoteUserNumActive, gauge, h.RemoteUserNumActive, labels},
{u.Site.RemoteUserNumInactive, gauge, h.RemoteUserNumInactive, labels},
{u.Site.RemoteUserRxBytes, counter, h.RemoteUserRxBytes, labels},