From 1a47277298100547cddcd9fad736edf7c403d221 Mon Sep 17 00:00:00 2001 From: Mya Date: Fri, 8 Jul 2022 13:40:32 -0600 Subject: [PATCH] fix(inputs.snmp): snmp UseUnconnectedUDPSocket when using udp (#10331) --- internal/snmp/config.go | 3 ++- internal/snmp/wrapper.go | 2 ++ plugins/inputs/snmp/README.md | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/snmp/config.go b/internal/snmp/config.go index 8475c084a..807d1e77d 100644 --- a/internal/snmp/config.go +++ b/internal/snmp/config.go @@ -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 diff --git a/internal/snmp/wrapper.go b/internal/snmp/wrapper.go index 22649d549..88fa3d65f 100644 --- a/internal/snmp/wrapper.go +++ b/internal/snmp/wrapper.go @@ -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 diff --git a/plugins/inputs/snmp/README.md b/plugins/inputs/snmp/README.md index b85d6e26d..0b71052e2 100644 --- a/plugins/inputs/snmp/README.md +++ b/plugins/inputs/snmp/README.md @@ -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