From dc89f029ad2cd944bae233aade714da75f7ee89b Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 17 May 2016 17:00:46 +0100 Subject: [PATCH] nstat plugin cleanups and formatting closes #1104 closes #1138 --- README.md | 1 + etc/telegraf.conf | 12 ++++++++++++ plugins/inputs/nstat/README.md | 27 ++++++++++++++------------- plugins/inputs/nstat/nstat.go | 17 +++++++++-------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index fcb1c5c87..927c1a007 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/etc/telegraf.conf b/etc/telegraf.conf index 64eace970..465f33859 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -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. diff --git a/plugins/inputs/nstat/README.md b/plugins/inputs/nstat/README.md index da2dbe608..c80f893b9 100644 --- a/plugins/inputs/nstat/README.md +++ b/plugins/inputs/nstat/README.md @@ -1,27 +1,28 @@ -## Nstat input plugin +## 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 diff --git a/plugins/inputs/nstat/nstat.go b/plugins/inputs/nstat/nstat.go index 407128d97..d32ef004c 100644 --- a/plugins/inputs/nstat/nstat.go +++ b/plugins/inputs/nstat/nstat.go @@ -40,17 +40,18 @@ type Nstat struct { } var sampleConfig = ` - # file paths - # e.g: /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6 - proc_net_netstat = "" - proc_net_snmp = "" - proc_net_snmp6 = "" - # dump metrics with 0 values too - dump_zeros = true + ## 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 ` 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 {