diff --git a/collector/collector.go b/collector/collector.go index 123ef5c2..e5dae381 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -439,9 +439,18 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("snmp_error", "Error during initialisation of the Worker", nil, nil), err) return } + // Set UseUnconnectedSocket option if at least one module has it set + useUnconnectedUDPSocket := false + for _, m := range c.modules { + if m.WalkParams.UseUnconnectedUDPSocket { + useUnconnectedUDPSocket = true + break + } + } // Set the options. client.SetOptions(func(g *gosnmp.GoSNMP) { g.Context = ctx + g.UseUnconnectedUDPSocket = useUnconnectedUDPSocket c.auth.ConfigureSNMP(g, c.snmpContext) }) if err = client.Connect(); err != nil {