diff --git a/integrations/promunifi/clients.go b/integrations/promunifi/clients.go index 958ec33d..6c41ab75 100644 --- a/integrations/promunifi/clients.go +++ b/integrations/promunifi/clients.go @@ -72,10 +72,7 @@ func descClient(ns string) *uclient { } } -func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable) { - appTotal := make(totalsDPImap) - catTotal := make(totalsDPImap) - +func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable, appTotal, catTotal totalsDPImap) { 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)} @@ -90,8 +87,6 @@ func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable) { {u.Client.DPIRxBytes, counter, dpi.RxBytes, labelDPI}, }) } - - u.reportClientDPItotals(r, appTotal, catTotal) } func (u *promUnifi) exportClient(r report, c *unifi.Client) { @@ -169,7 +164,7 @@ func fillDPIMapTotals(m totalsDPImap, name, controller, site string, dpi unifi.D m[controller][site][name] = oldDPI } -func (u *promUnifi) reportClientDPItotals(r report, appTotal, catTotal totalsDPImap) { +func (u *promUnifi) exportClientDPItotals(r report, appTotal, catTotal totalsDPImap) { type all []struct { kind string val totalsDPImap diff --git a/integrations/promunifi/collector.go b/integrations/promunifi/collector.go index 8daa81ec..e4a239df 100644 --- a/integrations/promunifi/collector.go +++ b/integrations/promunifi/collector.go @@ -307,9 +307,14 @@ func (u *promUnifi) loopExports(r report) { go func() { defer r.done() + appTotal := make(totalsDPImap) + catTotal := make(totalsDPImap) + for _, c := range m.ClientsDPI { - u.exportClientDPI(r, c) + u.exportClientDPI(r, c, appTotal, catTotal) } + + u.exportClientDPItotals(r, appTotal, catTotal) }() go func() {