Skip to content

Commit

Permalink
chore: move udp socket setting to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
MyaLongmire committed Mar 2, 2022
1 parent ccddf3b commit a1db1d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 4 additions & 1 deletion internal/snmp/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ func (gs *GosnmpWrapper) SetAgent(agent string) error {
// gosnmp does not handle these errors well, which is why
// they can result in cryptic errors by net.Dial.
switch u.Scheme {
case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6":
case "tcp", "tcp4", "tcp6":
gs.Transport = u.Scheme
case "udp", "udp4", "udp6":
gs.Transport = u.Scheme
gs.UseUnconnectedUDPSocket = true
default:
return fmt.Errorf("unsupported scheme: %v", u.Scheme)
}
Expand Down
3 changes: 0 additions & 3 deletions plugins/inputs/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,6 @@ func (s *Snmp) getConnection(idx int) (snmpConnection, error) {
var err error
var gs snmp.GosnmpWrapper
gs, err = snmp.NewWrapper(s.ClientConfig)
if strings.ContainsAny(agent, "udp") {
gs.UseUnconnectedUDPSocket = true
}
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion plugins/inputs/snmp_trap/snmp_trap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type SnmpTrap struct {

acc telegraf.Accumulator
listener *gosnmp.TrapListener
udp *gosnmp.GoSNMP
timeFunc func() time.Time
lookupFunc func(string) (snmp.MibEntry, error)
errCh chan error
Expand Down

0 comments on commit a1db1d8

Please sign in to comment.