Add support for SNMP over TCP (#5870)

This commit is contained in:
Felix Maurer
2019-11-07 20:56:51 +02:00
committed by Daniel Nelson
parent b4a712969e
commit 378c570c06
5 changed files with 51 additions and 5 deletions

View File

@@ -623,6 +623,10 @@ func (s *Snmp) getConnection(idx int) (snmpConnection, error) {
gs := gosnmpWrapper{&gosnmp.GoSNMP{}}
s.connectionCache[idx] = gs
if strings.HasPrefix(agent, "tcp://") {
agent = strings.TrimPrefix(agent, "tcp://")
gs.Transport = "tcp"
}
host, portStr, err := net.SplitHostPort(agent)
if err != nil {
if err, ok := err.(*net.AddrError); !ok || err.Err != "missing port in address" {