From 3602d8cc8fde1f3460adcaec1ff88c5a89b52b1c Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Thu, 2 Jan 2025 08:57:47 -0600 Subject: [PATCH] adds in UBB & UCI support --- go.mod | 4 ++-- go.sum | 4 ++-- pkg/datadogunifi/ubb.go | 2 +- pkg/datadogunifi/uci.go | 3 ++- pkg/influxunifi/ubb.go | 2 ++ pkg/influxunifi/uci.go | 1 + pkg/promunifi/ubb.go | 1 + pkg/promunifi/uci.go | 2 ++ 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 5a84e229..fee506c8 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/prometheus/common v0.61.0 github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c github.com/stretchr/testify v1.10.0 - github.com/unpoller/unifi/v5 v5.0.5 + github.com/unpoller/unifi/v5 v5.0.6 golang.org/x/crypto v0.31.0 golang.org/x/net v0.33.0 golang.org/x/term v0.27.0 @@ -48,4 +48,4 @@ require ( ) // for local iterative development only -replace github.com/unpoller/unifi/v5 => ../unifi +// replace github.com/unpoller/unifi/v5 => ../unifi diff --git a/go.sum b/go.sum index dcb5c902..8f6e3923 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/unpoller/unifi/v5 v5.0.5 h1:4u3Dd3CrEH9t0BMCy/jjBMFN2xk67Zm3UKOT//Oq/ZQ= -github.com/unpoller/unifi/v5 v5.0.5/go.mod h1:G45KRuSH9PFrIUFmDTzWEEM/E/e7GuyXp36AVOfhm7I= +github.com/unpoller/unifi/v5 v5.0.6 h1:nokn8k5HOnxcOhLt5d0xzotJ0tvhbKoExAesrWenLhQ= +github.com/unpoller/unifi/v5 v5.0.6/go.mod h1:G45KRuSH9PFrIUFmDTzWEEM/E/e7GuyXp36AVOfhm7I= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/pkg/datadogunifi/ubb.go b/pkg/datadogunifi/ubb.go index 05e167e8..4bb720c7 100644 --- a/pkg/datadogunifi/ubb.go +++ b/pkg/datadogunifi/ubb.go @@ -36,6 +36,7 @@ func (u *DatadogUnifi) batchUBB(r report, s *unifi.UBB) { // nolint: funlen if s.SysStats != nil { sysStats = *s.SysStats } + systemStats := unifi.SystemStats{} if s.SystemStats != nil { systemStats = *s.SystemStats @@ -82,7 +83,6 @@ func (u *DatadogUnifi) batchUBB(r report, s *unifi.UBB) { // nolint: funlen metricName = metricNamespace("usw") reportGaugeForFloat64Map(r, metricName, data, tags) - } func (u *DatadogUnifi) batchUBBstat(sw *unifi.Bb) map[string]float64 { diff --git a/pkg/datadogunifi/uci.go b/pkg/datadogunifi/uci.go index 02ac89ab..74d520d8 100644 --- a/pkg/datadogunifi/uci.go +++ b/pkg/datadogunifi/uci.go @@ -36,6 +36,7 @@ func (u *DatadogUnifi) batchUCI(r report, s *unifi.UCI) { // nolint: funlen if s.SysStats != nil { sysStats = *s.SysStats } + systemStats := unifi.SystemStats{} if s.SystemStats != nil { systemStats = *s.SystemStats @@ -53,7 +54,7 @@ func (u *DatadogUnifi) batchUCI(r report, s *unifi.UCI) { // nolint: funlen }, ) - r.addCount(uxgT) + r.addCount(uciT) metricName := metricNamespace("usg") reportGaugeForFloat64Map(r, metricName, data, tags) diff --git a/pkg/influxunifi/ubb.go b/pkg/influxunifi/ubb.go index 57333b0a..48527773 100644 --- a/pkg/influxunifi/ubb.go +++ b/pkg/influxunifi/ubb.go @@ -24,6 +24,7 @@ func (u *InfluxUnifi) batchUBB(r report, s *unifi.UBB) { // nolint: funlen "serial": s.Serial, "type": s.Type, } + var sw *unifi.Bb if s.Stat != nil { sw = s.Stat.Bb @@ -33,6 +34,7 @@ func (u *InfluxUnifi) batchUBB(r report, s *unifi.UBB) { // nolint: funlen if s.SysStats != nil { sysStats = *s.SysStats } + systemStats := unifi.SystemStats{} if s.SystemStats != nil { systemStats = *s.SystemStats diff --git a/pkg/influxunifi/uci.go b/pkg/influxunifi/uci.go index 5ccf8442..04a17bb4 100644 --- a/pkg/influxunifi/uci.go +++ b/pkg/influxunifi/uci.go @@ -34,6 +34,7 @@ func (u *InfluxUnifi) batchUCI(r report, s *unifi.UCI) { // nolint: funlen if s.SysStats != nil { sysStats = *s.SysStats } + systemStats := unifi.SystemStats{} if s.SystemStats != nil { systemStats = *s.SystemStats diff --git a/pkg/promunifi/ubb.go b/pkg/promunifi/ubb.go index f7857d21..037d2a3d 100644 --- a/pkg/promunifi/ubb.go +++ b/pkg/promunifi/ubb.go @@ -20,6 +20,7 @@ func (u *promUnifi) exportUBB(r report, d *unifi.UBB) { infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID} // Shared data (all devices do this). u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) + if d.SysStats != nil && d.SystemStats != nil { u.exportSYSstats(r, labels, *d.SysStats, *d.SystemStats) } diff --git a/pkg/promunifi/uci.go b/pkg/promunifi/uci.go index bfc51caa..d6d7d6c2 100644 --- a/pkg/promunifi/uci.go +++ b/pkg/promunifi/uci.go @@ -19,9 +19,11 @@ func (u *promUnifi) exportUCI(r report, d *unifi.UCI) { infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID} // Shared data (all devices do this). u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) + if d.SysStats != nil && d.SystemStats != nil { u.exportSYSstats(r, labels, *d.SysStats, *d.SystemStats) } + // Switch Data u.exportUSWstats(r, labels, sw) // Dream Machine System Data.