Cody Lee
2023-01-06 21:12:24 -06:00
parent f243af7dd5
commit 1edb580084
8 changed files with 29 additions and 47 deletions

View File

@@ -1,8 +1,6 @@
package influxunifi
import (
"fmt"
"github.com/unpoller/unifi"
)
@@ -86,8 +84,8 @@ func (u *InfluxUnifi) batchClientDPI(r report, v any, appTotal, catTotal totalsD
}
for _, dpi := range s.ByApp {
category := unifi.DPICats.Get(int(dpi.Cat.Val))
application := unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val))
category := unifi.DPICats.Get(dpi.Cat.Int())
application := unifi.DPIApps.GetApp(dpi.Cat.Int(), dpi.App.Int())
fillDPIMapTotals(appTotal, application, s.SourceName, s.SiteName, dpi)
fillDPIMapTotals(catTotal, category, s.SourceName, s.SiteName, dpi)
@@ -123,14 +121,10 @@ func fillDPIMapTotals(m totalsDPImap, name, controller, site string, dpi unifi.D
}
existing := m[controller][site][name]
existing.TxPackets.Val += dpi.TxPackets.Val
existing.TxPackets.Txt = fmt.Sprintf("%f", existing.TxPackets.Val)
existing.RxPackets.Val += dpi.RxPackets.Val
existing.RxPackets.Txt = fmt.Sprintf("%f", existing.RxPackets.Val)
existing.TxBytes.Val += dpi.TxBytes.Val
existing.TxBytes.Txt = fmt.Sprintf("%f", existing.TxBytes.Val)
existing.RxBytes.Val += dpi.RxBytes.Val
existing.RxBytes.Txt = fmt.Sprintf("%f", existing.RxBytes.Val)
existing.TxPackets.Add(&dpi.TxPackets)
existing.RxPackets.Add(&dpi.RxPackets)
existing.TxBytes.Add(&dpi.TxBytes)
existing.RxBytes.Add(&dpi.RxBytes)
m[controller][site][name] = existing
}

View File

@@ -68,8 +68,8 @@ func (u *InfluxUnifi) batchSiteDPI(r report, v any) {
r.send(&metric{
Table: "sitedpi",
Tags: map[string]string{
"category": unifi.DPICats.Get(int(dpi.Cat.Val)),
"application": unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val)),
"category": unifi.DPICats.Get(dpi.Cat.Int()),
"application": unifi.DPIApps.GetApp(dpi.Cat.Int(), dpi.App.Int()),
"site_name": s.SiteName,
"source": s.SourceName,
},