FlexInt adaptation
This commit is contained in:
parent
fa3ad41a70
commit
2e8fb0b2ec
|
|
@ -1,6 +1,8 @@
|
|||
package datadogunifi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/unpoller/unifi"
|
||||
)
|
||||
|
||||
|
|
@ -88,8 +90,8 @@ func (u *DatadogUnifi) batchClientDPI(r report, v any, appTotal, catTotal totals
|
|||
}
|
||||
|
||||
for _, dpi := range s.ByApp {
|
||||
category := unifi.DPICats.Get(dpi.Cat)
|
||||
application := unifi.DPIApps.GetApp(dpi.Cat, dpi.App)
|
||||
category := unifi.DPICats.Get(int(dpi.Cat.Val))
|
||||
application := unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val))
|
||||
fillDPIMapTotals(appTotal, application, s.SourceName, s.SiteName, dpi)
|
||||
fillDPIMapTotals(catTotal, category, s.SourceName, s.SiteName, dpi)
|
||||
|
||||
|
|
@ -103,10 +105,10 @@ func (u *DatadogUnifi) batchClientDPI(r report, v any, appTotal, catTotal totals
|
|||
}
|
||||
|
||||
data := map[string]float64{
|
||||
"tx_packets": float64(dpi.TxPackets),
|
||||
"rx_packets": float64(dpi.RxPackets),
|
||||
"tx_bytes": float64(dpi.TxBytes),
|
||||
"rx_bytes": float64(dpi.RxBytes),
|
||||
"tx_packets": dpi.TxPackets.Val,
|
||||
"rx_packets": dpi.RxPackets.Val,
|
||||
"tx_bytes": dpi.TxBytes.Val,
|
||||
"rx_bytes": dpi.RxBytes.Val,
|
||||
}
|
||||
|
||||
metricName := metricNamespace("client_dpi")
|
||||
|
|
@ -127,10 +129,14 @@ func fillDPIMapTotals(m totalsDPImap, name, controller, site string, dpi unifi.D
|
|||
}
|
||||
|
||||
existing := m[controller][site][name]
|
||||
existing.TxPackets += dpi.TxPackets
|
||||
existing.RxPackets += dpi.RxPackets
|
||||
existing.TxBytes += dpi.TxBytes
|
||||
existing.RxBytes += dpi.RxBytes
|
||||
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)
|
||||
m[controller][site][name] = existing
|
||||
}
|
||||
|
||||
|
|
@ -173,10 +179,10 @@ func reportClientDPItotals(r report, appTotal, catTotal totalsDPImap) {
|
|||
tags[k.kind] = name
|
||||
|
||||
data := map[string]float64{
|
||||
"tx_packets": float64(m.TxPackets),
|
||||
"rx_packets": float64(m.RxPackets),
|
||||
"tx_bytes": float64(m.TxBytes),
|
||||
"rx_bytes": float64(m.RxBytes),
|
||||
"tx_packets": m.TxPackets.Val,
|
||||
"rx_packets": m.RxPackets.Val,
|
||||
"tx_bytes": m.TxBytes.Val,
|
||||
"rx_bytes": m.RxBytes.Val,
|
||||
}
|
||||
|
||||
metricName := metricNamespace("client_dpi")
|
||||
|
|
|
|||
|
|
@ -66,15 +66,15 @@ func (u *DatadogUnifi) reportSiteDPI(r report, s *unifi.DPITable) {
|
|||
metricName := metricNamespace("sitedpi")
|
||||
|
||||
tags := []string{
|
||||
tag("category", unifi.DPICats.Get(dpi.Cat)),
|
||||
tag("application", unifi.DPIApps.GetApp(dpi.Cat, dpi.App)),
|
||||
tag("category", unifi.DPICats.Get(int(dpi.Cat.Val))),
|
||||
tag("application", unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val))),
|
||||
tag("site_name", s.SiteName),
|
||||
tag("source", s.SourceName),
|
||||
}
|
||||
|
||||
_ = r.reportCount(metricName("tx_packets"), dpi.TxPackets, tags)
|
||||
_ = r.reportCount(metricName("rx_packets"), dpi.RxPackets, tags)
|
||||
_ = r.reportCount(metricName("tx_bytes"), dpi.TxBytes, tags)
|
||||
_ = r.reportCount(metricName("rx_bytes"), dpi.RxBytes, tags)
|
||||
_ = r.reportCount(metricName("tx_packets"), int64(dpi.TxPackets.Val), tags)
|
||||
_ = r.reportCount(metricName("rx_packets"), int64(dpi.RxPackets.Val), tags)
|
||||
_ = r.reportCount(metricName("tx_bytes"), int64(dpi.TxBytes.Val), tags)
|
||||
_ = r.reportCount(metricName("rx_bytes"), int64(dpi.RxBytes.Val), tags)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package influxunifi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/unpoller/unifi"
|
||||
)
|
||||
|
||||
|
|
@ -84,8 +86,8 @@ func (u *InfluxUnifi) batchClientDPI(r report, v any, appTotal, catTotal totalsD
|
|||
}
|
||||
|
||||
for _, dpi := range s.ByApp {
|
||||
category := unifi.DPICats.Get(dpi.Cat)
|
||||
application := unifi.DPIApps.GetApp(dpi.Cat, dpi.App)
|
||||
category := unifi.DPICats.Get(int(dpi.Cat.Val))
|
||||
application := unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val))
|
||||
fillDPIMapTotals(appTotal, application, s.SourceName, s.SiteName, dpi)
|
||||
fillDPIMapTotals(catTotal, category, s.SourceName, s.SiteName, dpi)
|
||||
|
||||
|
|
@ -121,10 +123,14 @@ func fillDPIMapTotals(m totalsDPImap, name, controller, site string, dpi unifi.D
|
|||
}
|
||||
|
||||
existing := m[controller][site][name]
|
||||
existing.TxPackets += dpi.TxPackets
|
||||
existing.RxPackets += dpi.RxPackets
|
||||
existing.TxBytes += dpi.TxBytes
|
||||
existing.RxBytes += dpi.RxBytes
|
||||
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)
|
||||
m[controller][site][name] = existing
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(dpi.Cat),
|
||||
"application": unifi.DPIApps.GetApp(dpi.Cat, dpi.App),
|
||||
"category": unifi.DPICats.Get(int(dpi.Cat.Val)),
|
||||
"application": unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val)),
|
||||
"site_name": s.SiteName,
|
||||
"source": s.SourceName,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package promunifi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/unpoller/unifi"
|
||||
)
|
||||
|
|
@ -84,7 +86,7 @@ func (u *promUnifi) exportClientDPI(r report, v any, appTotal, catTotal totalsDP
|
|||
for _, dpi := range s.ByApp {
|
||||
labelDPI := []string{
|
||||
s.Name, s.MAC, s.SiteName, s.SourceName,
|
||||
unifi.DPICats.Get(dpi.Cat), unifi.DPIApps.GetApp(dpi.Cat, dpi.App),
|
||||
unifi.DPICats.Get(int(dpi.Cat.Val)), unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val)),
|
||||
}
|
||||
|
||||
fillDPIMapTotals(appTotal, labelDPI[5], s.SourceName, s.SiteName, dpi)
|
||||
|
|
@ -170,10 +172,14 @@ func fillDPIMapTotals(m totalsDPImap, name, controller, site string, dpi unifi.D
|
|||
}
|
||||
|
||||
oldDPI := m[controller][site][name]
|
||||
oldDPI.TxPackets += dpi.TxPackets
|
||||
oldDPI.RxPackets += dpi.RxPackets
|
||||
oldDPI.TxBytes += dpi.TxBytes
|
||||
oldDPI.RxBytes += dpi.RxBytes
|
||||
oldDPI.TxPackets.Val += dpi.TxPackets.Val
|
||||
oldDPI.TxPackets.Txt = fmt.Sprintf("%f", oldDPI.TxPackets.Val)
|
||||
oldDPI.RxPackets.Val += dpi.RxPackets.Val
|
||||
oldDPI.RxPackets.Txt = fmt.Sprintf("%f", oldDPI.RxPackets.Val)
|
||||
oldDPI.TxBytes.Val += dpi.TxBytes.Val
|
||||
oldDPI.TxBytes.Txt = fmt.Sprintf("%f", oldDPI.TxBytes.Val)
|
||||
oldDPI.RxBytes.Val += dpi.RxBytes.Val
|
||||
oldDPI.RxBytes.Txt = fmt.Sprintf("%f", oldDPI.RxBytes.Val)
|
||||
m[controller][site][name] = oldDPI
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func (u *promUnifi) exportSiteDPI(r report, v any) {
|
|||
}
|
||||
|
||||
for _, dpi := range s.ByApp {
|
||||
labelDPI := []string{unifi.DPICats.Get(dpi.Cat), unifi.DPIApps.GetApp(dpi.Cat, dpi.App), s.SiteName, s.SourceName}
|
||||
labelDPI := []string{unifi.DPICats.Get(int(dpi.Cat.Val)), unifi.DPIApps.GetApp(int(dpi.Cat.Val), int(dpi.App.Val)), s.SiteName, s.SourceName}
|
||||
|
||||
// log.Println(labelsDPI, dpi.Cat, dpi.App, dpi.TxBytes, dpi.RxBytes, dpi.TxPackets, dpi.RxPackets)
|
||||
r.send([]*metric{
|
||||
|
|
|
|||
Loading…
Reference in New Issue