Skip to content

Commit

Permalink
Set UseUnconnectedUDPSocket option if one of the modules has if set
Browse files Browse the repository at this point in the history
Signed-off-by: Urmas Närep <[email protected]>
  • Loading branch information
unarep committed Sep 21, 2024
1 parent af7d9a2 commit efa792c
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 @@ -440,9 +440,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 efa792c

Please sign in to comment.