Skip to content

Commit

Permalink
Merge pull request #1247 from unarep/use-unconnected-UDP-socket
Browse files Browse the repository at this point in the history
Set UseUnconnectedUDPSocket option if one of the modules has if set
  • Loading branch information
bastischubert authored Oct 17, 2024
2 parents e7309c4 + efa792c commit acb8d71
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit acb8d71

Please sign in to comment.