nstat plugin cleanups and formatting

closes #1104
closes #1138
This commit is contained in:
Cameron Sparr 2016-05-17 17:00:46 +01:00
parent 7557056a31
commit dc89f029ad
4 changed files with 36 additions and 21 deletions

View File

@ -186,6 +186,7 @@ Currently implemented sources:
* [net_response](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/net_response)
* [nginx](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nginx)
* [nsq](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nsq)
* [nstat](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nstat)
* [ntpq](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/ntpq)
* [phpfpm](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/phpfpm)
* [phusion passenger](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/passenger)

View File

@ -940,6 +940,18 @@
# endpoints = ["http://localhost:4151"]
# # Collect kernel snmp counters and network interface statistics
# [[inputs.nstat]]
# ## file paths for proc files. If empty default paths will be used:
# ## /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6
# ## These can also be overridden with env variables, see README.
# proc_net_netstat = ""
# proc_net_snmp = ""
# proc_net_snmp6 = ""
# ## dump metrics with 0 values too
# dump_zeros = true
# # Get standard NTP query metrics, requires ntpq executable.
# [[inputs.ntpq]]
# ## If false, set the -n ntpq flag. Can reduce metric gather time.

View File

@ -1,27 +1,28 @@
## Nstat input plugin
Plugin collects network metrics from ```/proc/net/netstat```, ```/proc/net/snmp``` and ```/proc/net/snmp6``` files
Plugin collects network metrics from `/proc/net/netstat`, `/proc/net/snmp` and `/proc/net/snmp6` files
### Configuration
The plugin firstly tries to read file paths from config values
if it is empty, then it reads from env variables.
* ```PROC_NET_NETSTAT```
* ```PROC_NET_SNMP```
* ```PROC_NET_SNMP6```
* `PROC_NET_NETSTAT`
* `PROC_NET_SNMP`
* `PROC_NET_SNMP6`
If these variables are also not set,
then it tries to read the proc root from env - ```PROC_ROOT```,
and sets ```/proc``` as a root path if ```PROC_ROOT``` is also empty.
then it tries to read the proc root from env - `PROC_ROOT`,
and sets `/proc` as a root path if `PROC_ROOT` is also empty.
Then appends default file paths:
* ```/net/netstat```
* ```/net/snmp```
* ```/net/snmp6```
* `/net/netstat`
* `/net/snmp`
* `/net/snmp6`
So if nothing is given, no paths in config and in env vars, the plugin takes the default paths.
* ```/proc/net/netstat```
* ```/proc/net/snmp```
* ```/proc/net/snmp6```
* `/proc/net/netstat`
* `/proc/net/snmp`
* `/proc/net/snmp6`
The sample config file
```toml

View File

@ -40,17 +40,18 @@ type Nstat struct {
}
var sampleConfig = `
# file paths
# e.g: /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6
## file paths for proc files. If empty default paths will be used:
## /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6
## These can also be overridden with env variables, see README.
proc_net_netstat = ""
proc_net_snmp = ""
proc_net_snmp6 = ""
# dump metrics with 0 values too
## dump metrics with 0 values too
dump_zeros = true
`
func (ns *Nstat) Description() string {
return "Collect network metrics from '/proc/net/netstat', '/proc/net/snmp' & '/proc/net/snmp6' files"
return "Collect kernel snmp counters and network interface statistics"
}
func (ns *Nstat) SampleConfig() string {