From 75cb9362ffef916baf46c7038e465f30e503b4fa Mon Sep 17 00:00:00 2001 From: kongfei Date: Thu, 12 Oct 2023 16:06:00 +0800 Subject: [PATCH] snmp up synchronize with other oid --- inputs/snmp/instances.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/inputs/snmp/instances.go b/inputs/snmp/instances.go index 07a37fff..a6bc9adc 100644 --- a/inputs/snmp/instances.go +++ b/inputs/snmp/instances.go @@ -121,7 +121,7 @@ func (ins *Instance) up(slist *types.SampleList, i int) { func (ins *Instance) Gather(slist *types.SampleList) { var wg sync.WaitGroup for i, agent := range ins.Agents { - wg.Add(2) + wg.Add(1) go func(i int, agent string) { defer wg.Done() // First is the top-level fields. We treat the fields as table prefixes with an empty index. @@ -137,10 +137,7 @@ func (ins *Instance) Gather(slist *types.SampleList) { if m, ok := ins.Mappings[agent]; ok { extraTags = m } - go func() { - defer wg.Done() - ins.up(slist, i) - }() + ins.up(slist, i) gs, err := ins.getConnection(i) if err != nil {