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