From 746ab856e005f31b1f57eb7676431342353b1780 Mon Sep 17 00:00:00 2001 From: Austin Browder <30290145+austinbrowder@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:39:22 -0600 Subject: [PATCH 1/2] Added source interface identifier to exportUSGstats function --- pkg/promunifi/usg.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/promunifi/usg.go b/pkg/promunifi/usg.go index 947ac164f..bfccae371 100644 --- a/pkg/promunifi/usg.go +++ b/pkg/promunifi/usg.go @@ -114,7 +114,13 @@ func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st u } labelLan := []string{"lan", labels[1], labels[2], labels[3]} - labelWan := []string{"all", labels[1], labels[2], labels[3]} + var sourceInterface string + if st.SourceInterface != "" { + sourceInterface = st.SourceInterface + } else { + sourceInterface = "all" + } + labelWan := []string{sourceInterface, labels[1], labels[2], labels[3]} r.send([]*metric{ {u.USG.LanRxPackets, counter, gw.LanRxPackets, labelLan}, From 8974cce072ddc98cb7fe3cdd108aa570999359fb Mon Sep 17 00:00:00 2001 From: Austin Browder <30290145+austinbrowder@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:25:02 -0700 Subject: [PATCH 2/2] Fixed PR lint failure --- pkg/promunifi/usg.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/promunifi/usg.go b/pkg/promunifi/usg.go index bfccae371..a60f09159 100644 --- a/pkg/promunifi/usg.go +++ b/pkg/promunifi/usg.go @@ -109,17 +109,19 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) { // Gateway Stats. func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st unifi.SpeedtestStatus, ul unifi.Uplink) { - if gw == nil { - return - } - - labelLan := []string{"lan", labels[1], labels[2], labels[3]} var sourceInterface string + if st.SourceInterface != "" { sourceInterface = st.SourceInterface } else { sourceInterface = "all" } + + if gw == nil { + return + } + + labelLan := []string{"lan", labels[1], labels[2], labels[3]} labelWan := []string{sourceInterface, labels[1], labels[2], labels[3]} r.send([]*metric{