From 0aa406a2dccc0c56ed9fc5504e82f1ae08262207 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Tue, 18 Jul 2023 13:48:57 -0500 Subject: [PATCH 1/2] cast back to int64 so existing timeseries continue to ingest, influxdb is very strict about int vs float storage --- pkg/influxunifi/clients.go | 60 +++++++++++++++++++------------------- pkg/influxunifi/site.go | 14 ++++----- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/pkg/influxunifi/clients.go b/pkg/influxunifi/clients.go index 1c08b59f..c2efed29 100644 --- a/pkg/influxunifi/clients.go +++ b/pkg/influxunifi/clients.go @@ -42,32 +42,32 @@ func (u *InfluxUnifi) batchClient(r report, s *unifi.Client) { // nolint: funlen "hostname": s.Name, "radio_desc": s.RadioDescription, "satisfaction": s.Satisfaction.Val, - "bytes_r": s.BytesR, - "ccq": s.Ccq, - "noise": s.Noise, + "bytes_r": s.BytesR.Int64(), + "ccq": s.Ccq.Int64(), + "noise": s.Noise.Int64(), "note": s.Note, "powersave_enabled": s.PowersaveEnabled, - "roam_count": s.RoamCount, - "rssi": s.Rssi, - "rx_bytes": s.RxBytes, - "rx_bytes_r": s.RxBytesR, - "rx_packets": s.RxPackets, - "rx_rate": s.RxRate, - "signal": s.Signal, - "tx_bytes": s.TxBytes, - "tx_bytes_r": s.TxBytesR, - "tx_packets": s.TxPackets, + "roam_count": s.RoamCount.Int64(), + "rssi": s.Rssi.Int64(), + "rx_bytes": s.RxBytes.Int64(), + "rx_bytes_r": s.RxBytesR.Int64(), + "rx_packets": s.RxPackets.Int64(), + "rx_rate": s.RxRate.Int64(), + "signal": s.Signal.Int64(), + "tx_bytes": s.TxBytes.Int64(), + "tx_bytes_r": s.TxBytesR.Int64(), + "tx_packets": s.TxPackets.Int64(), "tx_retries": s.TxRetries, - "tx_power": s.TxPower, - "tx_rate": s.TxRate, - "uptime": s.Uptime, + "tx_power": s.TxPower.Int64(), + "tx_rate": s.TxRate.Int64(), + "uptime": s.Uptime.Int64(), "wifi_tx_attempts": s.WifiTxAttempts, - "wired-rx_bytes": s.WiredRxBytes, - "wired-rx_bytes-r": s.WiredRxBytesR, - "wired-rx_packets": s.WiredRxPackets, - "wired-tx_bytes": s.WiredTxBytes, - "wired-tx_bytes-r": s.WiredTxBytesR, - "wired-tx_packets": s.WiredTxPackets, + "wired-rx_bytes": s.WiredRxBytes.Int64(), + "wired-rx_bytes-r": s.WiredRxBytesR.Int64(), + "wired-rx_packets": s.WiredRxPackets.Int64(), + "wired-tx_bytes": s.WiredTxBytes.Int64(), + "wired-tx_bytes-r": s.WiredTxBytesR.Int64(), + "wired-tx_packets": s.WiredTxPackets.Int64(), } r.send(&metric{Table: "clients", Tags: tags, Fields: fields}) @@ -100,10 +100,10 @@ func (u *InfluxUnifi) batchClientDPI(r report, v any, appTotal, catTotal totalsD "source": s.SourceName, }, Fields: map[string]any{ - "tx_packets": dpi.TxPackets.Val, - "rx_packets": dpi.RxPackets.Val, - "tx_bytes": dpi.TxBytes.Val, - "rx_bytes": dpi.RxBytes.Val, + "tx_packets": dpi.TxPackets.Int64(), + "rx_packets": dpi.RxPackets.Int64(), + "tx_bytes": dpi.TxBytes.Int64(), + "rx_bytes": dpi.RxBytes.Int64(), }, }) } @@ -167,10 +167,10 @@ func reportClientDPItotals(r report, appTotal, catTotal totalsDPImap) { "source": controller, }, Fields: map[string]any{ - "tx_packets": m.TxPackets.Val, - "rx_packets": m.RxPackets.Val, - "tx_bytes": m.TxBytes.Val, - "rx_bytes": m.RxBytes.Val, + "tx_packets": m.TxPackets.Int64(), + "rx_packets": m.RxPackets.Int64(), + "tx_bytes": m.TxBytes.Int64(), + "rx_bytes": m.RxBytes.Int64(), }, } newMetric.Tags[k.kind] = name diff --git a/pkg/influxunifi/site.go b/pkg/influxunifi/site.go index b6e044ac..36b1ad32 100644 --- a/pkg/influxunifi/site.go +++ b/pkg/influxunifi/site.go @@ -23,8 +23,8 @@ func (u *InfluxUnifi) batchSite(r report, s *unifi.Site) { "num_user": h.NumUser.Val, "num_guest": h.NumGuest.Val, "num_iot": h.NumIot.Val, - "tx_bytes-r": h.TxBytesR.Val, - "rx_bytes-r": h.RxBytesR.Val, + "tx_bytes-r": h.TxBytesR.Int64(), + "rx_bytes-r": h.RxBytesR.Int64(), "num_ap": h.NumAp.Val, "num_adopted": h.NumAdopted.Val, "num_disabled": h.NumDisabled.Val, @@ -37,7 +37,7 @@ func (u *InfluxUnifi) batchSite(r report, s *unifi.Site) { "gw_mem": h.GwSystemStats.Mem.Val, "gw_uptime": h.GwSystemStats.Uptime.Val, "latency": h.Latency.Val, - "uptime": h.Uptime.Val, + "uptime": h.Uptime.Int64(), "drops": h.Drops.Val, "xput_up": h.XputUp.Val, "xput_down": h.XputDown.Val, @@ -74,10 +74,10 @@ func (u *InfluxUnifi) batchSiteDPI(r report, v any) { "source": s.SourceName, }, Fields: map[string]any{ - "tx_packets": dpi.TxPackets.Val, - "rx_packets": dpi.RxPackets.Val, - "tx_bytes": dpi.TxBytes.Val, - "rx_bytes": dpi.RxBytes.Val, + "tx_packets": dpi.TxPackets.Int64(), + "rx_packets": dpi.RxPackets.Int64(), + "tx_bytes": dpi.TxBytes.Int64(), + "rx_bytes": dpi.RxBytes.Int64(), }, }) } From 2b186a9451557535c48887f570e570755df97d9f Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Tue, 18 Jul 2023 14:20:51 -0500 Subject: [PATCH 2/2] anomalies --- pkg/influxunifi/clients.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/influxunifi/clients.go b/pkg/influxunifi/clients.go index c2efed29..668b942e 100644 --- a/pkg/influxunifi/clients.go +++ b/pkg/influxunifi/clients.go @@ -34,7 +34,7 @@ func (u *InfluxUnifi) batchClient(r report, s *unifi.Client) { // nolint: funlen "vlan": s.Vlan.Txt, } fields := map[string]any{ - "anomalies": s.Anomalies, + "anomalies": s.Anomalies.Int64(), "ip": s.IP, "essid": s.Essid, "bssid": s.Bssid,