fix(inputs.snmp): snmp UseUnconnectedUDPSocket when using udp (#10331)

This commit is contained in:
Mya 2022-07-08 13:40:32 -06:00 committed by GitHub
parent a9e71eee8c
commit 1a47277298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -9,7 +9,8 @@ type ClientConfig struct {
Timeout config.Duration `toml:"timeout"`
Retries int `toml:"retries"`
// Values: 1, 2, 3
Version uint8 `toml:"version"`
Version uint8 `toml:"version"`
UnconnectedUDPSocket bool `toml:"unconnected_udp_socket"`
// Path to mib files
Path []string `toml:"path"`
// Translator implementation

View File

@ -36,6 +36,8 @@ func NewWrapper(s ClientConfig) (GosnmpWrapper, error) {
gs.Retries = s.Retries
gs.UseUnconnectedUDPSocket = s.UnconnectedUDPSocket
switch s.Version {
case 3:
gs.Version = gosnmp.Version3

View File

@ -30,6 +30,12 @@ path onto the global path variable
## SNMP version; can be 1, 2, or 3.
# version = 2
## Unconnected UDP socket
## When true, SNMP reponses are accepted from any address not just
## the requested address. This can be useful when gathering from
## redundant/failover systems.
# unconnected_udp_socket = false
## Path to mib files
## Used by the gosmi translator.
## To add paths when translating with netsnmp, use the MIBDIRS environment variable
@ -349,6 +355,10 @@ needed:
sudo tcpdump -s 0 -i eth0 -w telegraf-snmp.pcap host 127.0.0.1 and port 161
```
## Metrics
The field and tags will depend on the table and fields configured.
## Example Output
```shell