Skip to content

Commit

Permalink
Add a new and improved snmp plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
phemmer authored and sparrc committed Jul 28, 2016
1 parent c991b57 commit f305522
Show file tree
Hide file tree
Showing 6 changed files with 1,251 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ should now look like:
- [#1434](https://github.com/influxdata/telegraf/pull/1434): Add measurement name arg to logparser plugin.
- [#1479](https://github.com/influxdata/telegraf/pull/1479): logparser: change resp_code from a field to a tag.
- [#1411](https://github.com/influxdata/telegraf/pull/1411): Implement support for fetching hddtemp data
- [#1466](https://github.com/influxdata/telegraf/pull/1466): MongoDB input plugin: adding per DB stats from db.stats()
- [#1389](https://github.com/influxdata/telegraf/pull/1389): Add a new and improved SNMP plugin (snmp2).

### Bugfixes

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Currently implemented sources:
* [riak](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/riak)
* [sensors ](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sensors) (only available if built from source)
* [snmp](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/snmp)
* [snmp2](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/snmp2)
* [sql server](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sqlserver) (microsoft)
* [twemproxy](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/twemproxy)
* [varnish](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/varnish)
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
_ "github.com/influxdata/telegraf/plugins/inputs/riak"
_ "github.com/influxdata/telegraf/plugins/inputs/sensors"
_ "github.com/influxdata/telegraf/plugins/inputs/snmp"
_ "github.com/influxdata/telegraf/plugins/inputs/snmp2"
_ "github.com/influxdata/telegraf/plugins/inputs/sqlserver"
_ "github.com/influxdata/telegraf/plugins/inputs/statsd"
_ "github.com/influxdata/telegraf/plugins/inputs/sysstat"
Expand Down
130 changes: 130 additions & 0 deletions plugins/inputs/snmp2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# SNMP2 Plugin

The SNMP2 input plugin gathers metrics from SNMP agents.
It is an alternative to the SNMP plugin with significantly different configuration & behavior.

## Configuration:

### Example:

SNMP data:
```
.1.2.3.0.0.1.0 octet_str "foo"
.1.2.3.0.0.1.1 octet_str "bar"
.1.2.3.0.0.102 octet_str "bad"
.1.2.3.0.0.2.0 integer 1
.1.2.3.0.0.2.1 integer 2
.1.2.3.0.0.3.0 octet_str "0.123"
.1.2.3.0.0.3.1 octet_str "0.456"
.1.2.3.0.0.3.2 octet_str "9.999"
.1.2.3.0.1 octet_str "baz"
.1.2.3.0.2 uinteger 54321
.1.2.3.0.3 uinteger 234
```

Telegraf config:
```toml
[[inputs.snmp2]]
agents = [ "127.0.0.1:161" ]
version = 2
community = "public"

name = "system"
[[inputs.snmp2.field]]
name = "hostname"
oid = ".1.2.3.0.1"
is_tag = true
[[inputs.snmp2.field]]
name = "uptime"
oid = ".1.2.3.0.2"
[[inputs.snmp2.field]]
name = "loadavg"
oid = ".1.2.3.0.3"
conversion = "float(2)"

[[inputs.snmp2.table]]
name = "remote_servers"
inherit_tags = [ "hostname" ]
[[inputs.snmp2.table.field]]
name = "server"
oid = ".1.2.3.0.0.1"
is_tag = true
[[inputs.snmp2.table.field]]
name = "connections"
oid = ".1.2.3.0.0.2"
[[inputs.snmp2.table.field]]
name = "latency"
oid = ".1.2.3.0.0.3"
conversion = "float"
```

Resulting output:
```
* Plugin: snmp2, Collection 1
> system,agent_host=127.0.0.1,host=mylocalhost,hostname=baz loadavg=2.34,uptime=54321i 1468953135000000000
> remote_servers,agent_host=127.0.0.1,host=mylocalhost,hostname=baz,server=foo connections=1i,latency=0.123 1468953135000000000
> remote_servers,agent_host=127.0.0.1,host=mylocalhost,hostname=baz,server=bar connections=2i,latency=0.456 1468953135000000000
```

### Config parameters

* `agents`: Default: `[]`
List of SNMP agents to connect to in the form of `IP[:PORT]`. If `:PORT` is unspecified, it defaults to `161`.

* `version`: Default: `2`
SNMP protocol version to use.

* `community`: Default: `"public"`
SNMP community to use.

* `max_repetitions`: Default: `50`
Maximum number of iterations for repeating variables.

* `sec_name`:
Security name for authenticated SNMPv3 requests.

* `auth_protocol`: Values: `"MD5"`,`"SHA"`,`""`. Default: `""`
Authentication protocol for authenticated SNMPv3 requests.

* `auth_password`:
Authentication password for authenticated SNMPv3 requests.

* `sec_level`: Values: `"noAuthNoPriv"`,`"authNoPriv"`,`"authPriv"`. Default: `"noAuthNoPriv"`
Security level used for SNMPv3 messages.

* `context_name`:
Context name used for SNMPv3 requests.

* `priv_protocol`: Values: `"DES"`,`"AES"`,`""`. Default: `""`
Privacy protocol used for encrypted SNMPv3 messages.

* `priv_password`:
Privacy password used for encrypted SNMPv3 messages.


* `name`:
Output measurement name.

#### Field parameters:
* `name`:
Output field/tag name.

* `oid`:
OID to get. Must be in dotted notation, not textual.

* `is_tag`:
Output this field as a tag.

* `conversion`: Values: `"float(X)"`,`"float"`,`"int"`,`""`. Default: `""`
Converts the value according to the given specification.

- `float(X)`: Converts the input value into a float and divides by the Xth power of 10. Efficively just moves the decimal left X places. For example a value of `123` with `float(2)` will result in `1.23`.
- `float`: Converts the value into a float with no adjustment. Same as `float(0)`.
- `int`: Convertes the value into an integer.

#### Table parameters:
* `name`:
Output measurement name.

* `inherit_tags`:
Which tags to inherit from the top-level config and to use in the output of this table's measurement.
Loading

0 comments on commit f305522

Please sign in to comment.