Skip to content

Commit

Permalink
SNMP plugin fixes
Browse files Browse the repository at this point in the history
fixes #873
  • Loading branch information
titilambert authored and sparrc committed Mar 23, 2016
1 parent 51d7724 commit a95710e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [#656](https://github.com/influxdata/telegraf/issues/656): No longer run `lsof` on linux to get netstat data, fixes permissions issue.
- [#907](https://github.com/influxdata/telegraf/issues/907): Fix prometheus invalid label/measurement name key.
- [#841](https://github.com/influxdata/telegraf/issues/841): Fix memcached unix socket panic.
- [#873](https://github.com/influxdata/telegraf/issues/873): Fix SNMP plugin sometimes not returning metrics. Thanks @titiliambert!

## v0.11.1 [2016-03-17]

Expand Down
8 changes: 4 additions & 4 deletions plugins/inputs/snmp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,23 +492,23 @@ Note: the plugin will add instance name as tag *instance*
# oid attribute is useless

# SNMP SUBTABLES
[[plugins.snmp.subtable]]
[[inputs.snmp.subtable]]
name = "bytes_recv"
oid = ".1.3.6.1.2.1.31.1.1.1.6"
unit = "octets"

[[plugins.snmp.subtable]]
[[inputs.snmp.subtable]]
name = "bytes_send"
oid = ".1.3.6.1.2.1.31.1.1.1.10"
unit = "octets"
```

#### Configuration notes

- In **plugins.snmp.table** section, the `oid` attribute is useless if
- In **inputs.snmp.table** section, the `oid` attribute is useless if
the `sub_tables` attributes is defined

- In **plugins.snmp.subtable** section, you can put a name from `snmptranslate_file`
- In **inputs.snmp.subtable** section, you can put a name from `snmptranslate_file`
as `oid` attribute instead of a valid OID

### Measurements & Fields:
Expand Down
10 changes: 4 additions & 6 deletions plugins/inputs/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io/ioutil"
"log"
"net"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a95710e

Please sign in to comment.