Move the definitions above the loop

This commit is contained in:
davidnewhall2 2020-01-31 03:44:12 -08:00
parent 89c12ca4bd
commit b7497f6672
2 changed files with 8 additions and 8 deletions

View File

@ -72,10 +72,7 @@ func descClient(ns string) *uclient {
} }
} }
func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable) { func (u *promUnifi) exportClientDPI(r report, s *unifi.DPITable, appTotal, catTotal totalsDPImap) {
appTotal := make(totalsDPImap)
catTotal := make(totalsDPImap)
for _, dpi := range s.ByApp { for _, dpi := range s.ByApp {
labelDPI := []string{s.Name, s.MAC, s.SiteName, s.SourceName, 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(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.Client.DPIRxBytes, counter, dpi.RxBytes, labelDPI},
}) })
} }
u.reportClientDPItotals(r, appTotal, catTotal)
} }
func (u *promUnifi) exportClient(r report, c *unifi.Client) { 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 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 { type all []struct {
kind string kind string
val totalsDPImap val totalsDPImap

View File

@ -307,9 +307,14 @@ func (u *promUnifi) loopExports(r report) {
go func() { go func() {
defer r.done() defer r.done()
appTotal := make(totalsDPImap)
catTotal := make(totalsDPImap)
for _, c := range m.ClientsDPI { for _, c := range m.ClientsDPI {
u.exportClientDPI(r, c) u.exportClientDPI(r, c, appTotal, catTotal)
} }
u.exportClientDPItotals(r, appTotal, catTotal)
}() }()
go func() { go func() {