Skip to content

Commit 086ff40

Browse files
authored
Skip duplicate interfaces (#20)
1 parent d6cc3ec commit 086ff40

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

exporter/exporter.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,21 @@ func (e *Exporter) collectImpl(out chan<- prom.Metric) error {
195195
out <- prom.MustNewConstMetric(e.metrics["device_last_backup"], prom.GaugeValue, timeToGauge(*device.LatestBackup.Timestamp), deviceLabels...)
196196
}
197197

198+
seenInterfaces := make(map[string]struct{})
199+
198200
var wanIF *models.DeviceInterfaceSchema
199201
for _, intf := range device.Interfaces {
200202
if intf.Identification == nil {
201203
continue
202204
}
203205

206+
// sometimes UNMS duplicates an interface in the list.
207+
// skip it so we don't send duplicate metrics.
208+
if _, ok := seenInterfaces[intf.Identification.Name]; ok {
209+
continue
210+
}
211+
seenInterfaces[intf.Identification.Name] = struct{}{}
212+
204213
if intf.Identification.Name == device.Identification.WanInterfaceID {
205214
wanIF = intf
206215
}

0 commit comments

Comments
 (0)