SNMP plugin fixes

fixes #873
This commit is contained in:
Thibault Cohen
2016-03-21 20:10:17 -04:00
committed by Cameron Sparr
parent 51d7724255
commit a95710ed0c
3 changed files with 9 additions and 10 deletions

View File

@@ -4,7 +4,6 @@ import (
"io/ioutil"
"log"
"net"
"regexp"
"strconv"
"strings"
"time"
@@ -308,11 +307,10 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error {
return err
} else {
for _, line := range strings.Split(string(data), "\n") {
oidsRegEx := regexp.MustCompile(`([^\t]*)\t*([^\t]*)`)
oids := oidsRegEx.FindStringSubmatch(string(line))
if oids[2] != "" {
oid_name := oids[1]
oid := oids[2]
oids := strings.Fields(string(line))
if len(oids) == 2 && oids[1] != "" {
oid_name := oids[0]
oid := oids[1]
fillnode(s.initNode, oid_name, strings.Split(string(oid), "."))
s.nameToOid[oid_name] = oid
}