2016-08-22 15:37:53 +00:00
# SNMP Plugin
The SNMP input plugin gathers metrics from SNMP agents.
## Configuration:
2016-08-24 11:10:41 +00:00
See additional SNMP plugin configuration examples [here ](./CONFIG-EXAMPLES.md ).
2016-08-22 15:37:53 +00:00
### Example:
SNMP data:
```
.1.0.0.0.1.1.0 octet_str "foo"
.1.0.0.0.1.1.1 octet_str "bar"
.1.0.0.0.1.102 octet_str "bad"
.1.0.0.0.1.2.0 integer 1
.1.0.0.0.1.2.1 integer 2
.1.0.0.0.1.3.0 octet_str "0.123"
.1.0.0.0.1.3.1 octet_str "0.456"
.1.0.0.0.1.3.2 octet_str "9.999"
.1.0.0.1.1 octet_str "baz"
.1.0.0.1.2 uinteger 54321
.1.0.0.1.3 uinteger 234
```
Telegraf config:
```toml
[[inputs.snmp]]
agents = [ "127.0.0.1:161" ]
version = 2
community = "public"
name = "system"
[[inputs.snmp.field]]
name = "hostname"
oid = ".1.0.0.1.1"
is_tag = true
[[inputs.snmp.field]]
name = "uptime"
oid = ".1.0.0.1.2"
[[inputs.snmp.field]]
name = "loadavg"
oid = ".1.0.0.1.3"
conversion = "float(2)"
[[inputs.snmp.table]]
name = "remote_servers"
inherit_tags = [ "hostname" ]
[[inputs.snmp.table.field]]
name = "server"
oid = ".1.0.0.0.1.1"
is_tag = true
[[inputs.snmp.table.field]]
name = "connections"
oid = ".1.0.0.0.1.2"
[[inputs.snmp.table.field]]
name = "latency"
oid = ".1.0.0.0.1.3"
conversion = "float"
```
Resulting output:
```
* Plugin: snmp, 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
```
#### Configuration via MIB:
2016-08-24 11:10:41 +00:00
This example uses the SNMP data above, but is configured via the MIB.
2016-08-22 15:37:53 +00:00
The example MIB file can be found in the `testdata` directory. See the [MIB lookups ](#mib-lookups ) section for more information.
Telegraf config:
```toml
[[inputs.snmp]]
agents = [ "127.0.0.1:161" ]
version = 2
community = "public"
[[inputs.snmp.field]]
oid = "TEST::hostname"
is_tag = true
[[inputs.snmp.table]]
oid = "TEST::testTable"
2018-03-05 23:29:26 +00:00
inherit_tags = [ "hostname" ]
2016-08-22 15:37:53 +00:00
```
Resulting output:
```
* Plugin: snmp, Collection 1
> testTable,agent_host=127.0.0.1,host=mylocalhost,hostname=baz,server=foo connections=1i,latency="0.123" 1468953135000000000
> testTable,agent_host=127.0.0.1,host=mylocalhost,hostname=baz,server=bar connections=2i,latency="0.456" 1468953135000000000
```
### Config parameters
2016-08-24 11:10:41 +00:00
* `agents` : Default: `[]`
2016-08-22 15:37:53 +00:00
List of SNMP agents to connect to in the form of `IP[:PORT]` . If `:PORT` is unspecified, it defaults to `161` .
2016-08-24 11:10:41 +00:00
* `version` : Default: `2`
2016-08-22 15:37:53 +00:00
SNMP protocol version to use.
2016-08-24 11:10:41 +00:00
* `community` : Default: `"public"`
2016-08-22 15:37:53 +00:00
SNMP community to use.
2016-08-24 11:10:41 +00:00
* `max_repetitions` : Default: `50`
2016-08-22 15:37:53 +00:00
Maximum number of iterations for repeating variables.
2016-08-24 11:10:41 +00:00
* `sec_name` :
2016-08-22 15:37:53 +00:00
Security name for authenticated SNMPv3 requests.
2016-08-24 11:10:41 +00:00
* `auth_protocol` : Values: `"MD5"` ,`"SHA"`,`""`. Default: `""`
2016-08-22 15:37:53 +00:00
Authentication protocol for authenticated SNMPv3 requests.
2016-08-24 11:10:41 +00:00
* `auth_password` :
2016-08-22 15:37:53 +00:00
Authentication password for authenticated SNMPv3 requests.
2016-08-24 11:10:41 +00:00
* `sec_level` : Values: `"noAuthNoPriv"` ,`"authNoPriv"`,`"authPriv"`. Default: `"noAuthNoPriv"`
2016-08-22 15:37:53 +00:00
Security level used for SNMPv3 messages.
2016-08-24 11:10:41 +00:00
* `context_name` :
2016-08-22 15:37:53 +00:00
Context name used for SNMPv3 requests.
2016-08-24 11:10:41 +00:00
* `priv_protocol` : Values: `"DES"` ,`"AES"`,`""`. Default: `""`
2016-08-22 15:37:53 +00:00
Privacy protocol used for encrypted SNMPv3 messages.
2016-08-24 11:10:41 +00:00
* `priv_password` :
2016-08-22 15:37:53 +00:00
Privacy password used for encrypted SNMPv3 messages.
2016-08-24 11:10:41 +00:00
* `name` :
2016-08-22 15:37:53 +00:00
Output measurement name.
#### Field parameters:
2016-08-24 11:10:41 +00:00
* `oid` :
2016-08-22 15:37:53 +00:00
OID to get. May be a numeric or textual OID.
2016-09-18 03:08:00 +00:00
* `oid_index_suffix` :
The OID sub-identifier to strip off so that the index can be matched against other fields in the table.
2018-04-18 00:34:39 +00:00
* `oid_index_length` :
Specifies the length of the index after the supplied table OID (in OID path segments). Truncates the index after this point to remove non-fixed value or length index suffixes.
2016-08-24 11:10:41 +00:00
* `name` :
2016-08-22 15:37:53 +00:00
Output field/tag name.
If not specified, it defaults to the value of `oid` . If `oid` is numeric, an attempt to translate the numeric OID into a texual OID will be made.
2016-08-24 11:10:41 +00:00
* `is_tag` :
2016-08-22 15:37:53 +00:00
Output this field as a tag.
2016-08-24 11:10:41 +00:00
* `conversion` : Values: `"float(X)"` ,`"float"`,`"int"`,`""`. Default: `""`
2016-08-22 15:37:53 +00:00
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.
2016-09-18 01:12:07 +00:00
- `hwaddr` : Converts the value to a MAC address.
- `ipaddr` : Converts the value to an IP address.
2016-08-22 15:37:53 +00:00
#### Table parameters:
2016-08-24 11:10:41 +00:00
* `oid` :
2016-08-22 15:37:53 +00:00
Automatically populates the table's fields using data from the MIB.
2016-08-24 11:10:41 +00:00
* `name` :
2016-08-22 15:37:53 +00:00
Output measurement name.
If not specified, it defaults to the value of `oid` . If `oid` is numeric, an attempt to translate the numeric OID into a texual OID will be made.
2016-08-24 11:10:41 +00:00
* `inherit_tags` :
2016-08-22 15:37:53 +00:00
Which tags to inherit from the top-level config and to use in the output of this table's measurement.
2017-03-24 19:06:52 +00:00
* `index_as_tag` :
Adds each row's index within the table as a tag.
2016-08-22 15:37:53 +00:00
### MIB lookups
If the plugin is configured such that it needs to perform lookups from the MIB, it will use the net-snmp utilities `snmptranslate` and `snmptable` .
When performing the lookups, the plugin will load all available MIBs. If your MIB files are in a custom path, you may add the path using the `MIBDIRS` environment variable. See [`man 1 snmpcmd` ](http://net-snmp.sourceforge.net/docs/man/snmpcmd.html#lbAK ) for more information on the variable.