Indent the toml config for readability

This commit is contained in:
Cameron Sparr 2015-08-26 09:21:39 -06:00
parent a00510a73c
commit 434267898b
21 changed files with 143 additions and 135 deletions

View File

@ -6,6 +6,7 @@
- [#137](https://github.com/influxdb/telegraf/issues/137): Memcached: fix when a value contains a space - [#137](https://github.com/influxdb/telegraf/issues/137): Memcached: fix when a value contains a space
- [#138](https://github.com/influxdb/telegraf/issues/138): MySQL server address tag. - [#138](https://github.com/influxdb/telegraf/issues/138): MySQL server address tag.
- [#142](https://github.com/influxdb/telegraf/pull/142): Add Description and SampleConfig funcs to output interface - [#142](https://github.com/influxdb/telegraf/pull/142): Add Description and SampleConfig funcs to output interface
- Indent the toml config file for readability
### Bugfixes ### Bugfixes
- [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing. - [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing.

View File

@ -387,11 +387,11 @@ func PrintSampleConfig() {
creator := outputs.Outputs[oname] creator := outputs.Outputs[oname]
output := creator() output := creator()
fmt.Printf("\n# %s\n[outputs.%s]\n", output.Description(), oname) fmt.Printf("\n# %s\n[outputs.%s]", output.Description(), oname)
config := output.SampleConfig() config := output.SampleConfig()
if config == "" { if config == "" {
fmt.Printf(" # no configuration\n\n") fmt.Printf("\n # no configuration\n")
} else { } else {
fmt.Printf(config) fmt.Printf(config)
} }
@ -411,17 +411,13 @@ func PrintSampleConfig() {
creator := plugins.Plugins[pname] creator := plugins.Plugins[pname]
plugin := creator() plugin := creator()
fmt.Printf("# %s\n[%s]\n", plugin.Description(), pname) fmt.Printf("\n# %s\n[%s]", plugin.Description(), pname)
config := plugin.SampleConfig() config := plugin.SampleConfig()
if config == "" { if config == "" {
fmt.Printf(" # no configuration\n\n") fmt.Printf("\n # no configuration\n")
} else { } else {
lines := strings.Split(config, "\n") fmt.Printf(config)
for _, line := range lines {
fmt.Printf("%s\n", line)
}
fmt.Printf("\n")
} }
} }
} }

View File

@ -21,12 +21,13 @@ type Disque struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of URI to gather stats about. Specify an ip or hostname # An array of URI to gather stats about. Specify an ip or hostname
# with optional port and password. ie disque://localhost, disque://10.10.3.33:18832, # with optional port and password. ie disque://localhost, disque://10.10.3.33:18832,
# 10.0.0.1:10000, etc. # 10.0.0.1:10000, etc.
# #
# If no servers are specified, then localhost is used as the host. # If no servers are specified, then localhost is used as the host.
servers = ["localhost"]` servers = ["localhost"]
`
func (r *Disque) SampleConfig() string { func (r *Disque) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -28,12 +28,12 @@ type node struct {
} }
const sampleConfig = ` const sampleConfig = `
# specify a list of one or more Elasticsearch servers # specify a list of one or more Elasticsearch servers
servers = ["http://localhost:9200"] servers = ["http://localhost:9200"]
# set local to false when you want to read the indices stats from all nodes # set local to false when you want to read the indices stats from all nodes
# within the cluster # within the cluster
local = true local = true
` `
// Elasticsearch is a plugin to read stats from one or many Elasticsearch // Elasticsearch is a plugin to read stats from one or many Elasticsearch

View File

@ -11,13 +11,13 @@ import (
) )
const sampleConfig = ` const sampleConfig = `
# specify commands via an array of tables # specify commands via an array of tables
[[exec.commands]] [[exec.commands]]
# the command to run # the command to run
command = "/usr/bin/mycollector --foo=bar" command = "/usr/bin/mycollector --foo=bar"
# name of the command (used as a prefix for measurements) # name of the command (used as a prefix for measurements)
name = "mycollector" name = "mycollector"
` `
type Command struct { type Command struct {

View File

@ -84,13 +84,13 @@ type haproxy struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of address to gather stats about. Specify an ip on hostname # An array of address to gather stats about. Specify an ip on hostname
# with optional port. ie localhost, 10.10.3.33:1936, etc. # with optional port. ie localhost, 10.10.3.33:1936, etc.
# #
# If no servers are specified, then default to 127.0.0.1:1936 # If no servers are specified, then default to 127.0.0.1:1936
servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"] servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"]
# Or you can also use local socket(not work yet) # Or you can also use local socket(not work yet)
# servers = ["socket:/run/haproxy/admin.sock"] # servers = ["socket:/run/haproxy/admin.sock"]
` `
func (r *haproxy) SampleConfig() string { func (r *haproxy) SampleConfig() string {

View File

@ -46,8 +46,8 @@ func (c RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) {
} }
var sampleConfig = ` var sampleConfig = `
# Specify services via an array of tables # Specify services via an array of tables
[[httpjson.services]] [[httpjson.services]]
# a name for the service being polled # a name for the service being polled
name = "webserver_stats" name = "webserver_stats"

View File

@ -20,17 +20,18 @@ type Kafka struct {
} }
var sampleConfig = ` var sampleConfig = `
# topic to consume # topic to consume
topic = "topic_with_metrics" topic = "topic_with_metrics"
# the name of the consumer group # the name of the consumer group
consumerGroupName = "telegraf_metrics_consumers" consumerGroupName = "telegraf_metrics_consumers"
# an array of Zookeeper connection strings # an array of Zookeeper connection strings
zookeeperPeers = ["localhost:2181"] zookeeperPeers = ["localhost:2181"]
# Batch size of points sent to InfluxDB # Batch size of points sent to InfluxDB
batchSize = 1000` batchSize = 1000
`
func (k *Kafka) SampleConfig() string { func (k *Kafka) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -131,11 +131,11 @@ var serverTypeMapping = map[string]ServerType{
} }
var sampleConfig = ` var sampleConfig = `
# An array of URI to gather stats about LeoFS. # An array of URI to gather stats about LeoFS.
# Specify an ip or hostname with port. ie 127.0.0.1:4020 # Specify an ip or hostname with port. ie 127.0.0.1:4020
# #
# If no servers are specified, then 127.0.0.1 is used as the host and 4020 as the port. # If no servers are specified, then 127.0.0.1 is used as the host and 4020 as the port.
servers = ["127.0.0.1:4021"] servers = ["127.0.0.1:4021"]
` `
func (l *LeoFS) SampleConfig() string { func (l *LeoFS) SampleConfig() string {

View File

@ -25,11 +25,12 @@ type Lustre2 struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of /proc globs to search for Lustre stats # An array of /proc globs to search for Lustre stats
# If not specified, the default will work on Lustre 2.5.x # If not specified, the default will work on Lustre 2.5.x
# #
# ost_procfiles = ["/proc/fs/lustre/obdfilter/*/stats", "/proc/fs/lustre/osd-ldiskfs/*/stats"] # ost_procfiles = ["/proc/fs/lustre/obdfilter/*/stats", "/proc/fs/lustre/osd-ldiskfs/*/stats"]
# mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"]` # mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"]
`
/* The wanted fields would be a []string if not for the /* The wanted fields would be a []string if not for the
lines that start with read_bytes/write_bytes and contain lines that start with read_bytes/write_bytes and contain

View File

@ -17,11 +17,12 @@ type Memcached struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of address to gather stats about. Specify an ip on hostname # An array of address to gather stats about. Specify an ip on hostname
# with optional port. ie localhost, 10.0.0.1:11211, etc. # with optional port. ie localhost, 10.0.0.1:11211, etc.
# #
# If no servers are specified, then localhost is used as the host. # If no servers are specified, then localhost is used as the host.
servers = ["localhost"]` servers = ["localhost"]
`
var defaultTimeout = 5 * time.Second var defaultTimeout = 5 * time.Second

View File

@ -25,12 +25,13 @@ type Ssl struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of URI to gather stats about. Specify an ip or hostname # An array of URI to gather stats about. Specify an ip or hostname
# with optional port add password. ie mongodb://user:auth_key@10.10.3.30:27017, # with optional port add password. ie mongodb://user:auth_key@10.10.3.30:27017,
# mongodb://10.10.3.33:18832, 10.0.0.1:10000, etc. # mongodb://10.10.3.33:18832, 10.0.0.1:10000, etc.
# #
# If no servers are specified, then 127.0.0.1 is used as the host and 27107 as the port. # If no servers are specified, then 127.0.0.1 is used as the host and 27107 as the port.
servers = ["127.0.0.1:27017"]` servers = ["127.0.0.1:27017"]
`
func (m *MongoDB) SampleConfig() string { func (m *MongoDB) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -14,14 +14,15 @@ type Mysql struct {
} }
var sampleConfig = ` var sampleConfig = `
# specify servers via a url matching: # specify servers via a url matching:
# [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]] # [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]]
# e.g. # e.g.
# root:root@http://10.0.0.18/?tls=false # root:root@http://10.0.0.18/?tls=false
# root:passwd@tcp(127.0.0.1:3036)/ # root:passwd@tcp(127.0.0.1:3036)/
# #
# If no servers are specified, then localhost is used as the host. # If no servers are specified, then localhost is used as the host.
servers = ["localhost"]` servers = ["localhost"]
`
func (m *Mysql) SampleConfig() string { func (m *Mysql) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -19,8 +19,9 @@ type Nginx struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of Nginx stub_status URI to gather stats. # An array of Nginx stub_status URI to gather stats.
urls = ["http://localhost/status"]` urls = ["http://localhost/status"]
`
func (n *Nginx) SampleConfig() string { func (n *Nginx) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -18,28 +18,28 @@ type Postgresql struct {
} }
var sampleConfig = ` var sampleConfig = `
# specify servers via an array of tables # specify servers via an array of tables
[[postgresql.servers]] [[postgresql.servers]]
# specify address via a url matching: # specify address via a url matching:
# postgres://[pqgotest[:password]]@localhost?sslmode=[disable|verify-ca|verify-full] # postgres://[pqgotest[:password]]@localhost?sslmode=[disable|verify-ca|verify-full]
# or a simple string: # or a simple string:
# host=localhost user=pqotest password=... sslmode=... # host=localhost user=pqotest password=... sslmode=...
# #
# All connection parameters are optional. By default, the host is localhost # All connection parameters are optional. By default, the host is localhost
# and the user is the currently running user. For localhost, we default # and the user is the currently running user. For localhost, we default
# to sslmode=disable as well. # to sslmode=disable as well.
# #
address = "sslmode=disable" address = "sslmode=disable"
# A list of databases to pull metrics about. If not specified, metrics for all # A list of databases to pull metrics about. If not specified, metrics for all
# databases are gathered. # databases are gathered.
# databases = ["app_production", "blah_testing"] # databases = ["app_production", "blah_testing"]
# [[postgresql.servers]] # [[postgresql.servers]]
# address = "influx@remoteserver" # address = "influx@remoteserver"
` `
func (p *Postgresql) SampleConfig() string { func (p *Postgresql) SampleConfig() string {

View File

@ -17,8 +17,9 @@ type Prometheus struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of urls to scrape metrics from. # An array of urls to scrape metrics from.
urls = ["http://localhost:9100/metrics"]` urls = ["http://localhost:9100/metrics"]
`
func (r *Prometheus) SampleConfig() string { func (r *Prometheus) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -68,15 +68,15 @@ type Node struct {
} }
var sampleConfig = ` var sampleConfig = `
# Specify servers via an array of tables # Specify servers via an array of tables
[[rabbitmq.servers]] [[rabbitmq.servers]]
# url = "http://localhost:15672" # url = "http://localhost:15672"
# username = "guest" # username = "guest"
# password = "guest" # password = "guest"
# A list of nodes to pull metrics about. If not specified, metrics for # A list of nodes to pull metrics about. If not specified, metrics for
# all nodes are gathered. # all nodes are gathered.
# nodes = ["rabbit@node1", "rabbit@node2"] # nodes = ["rabbit@node1", "rabbit@node2"]
` `
func (r *RabbitMQ) SampleConfig() string { func (r *RabbitMQ) SampleConfig() string {

View File

@ -21,12 +21,13 @@ type Redis struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of URI to gather stats about. Specify an ip or hostname # An array of URI to gather stats about. Specify an ip or hostname
# with optional port add password. ie redis://localhost, redis://10.10.3.33:18832, # with optional port add password. ie redis://localhost, redis://10.10.3.33:18832,
# 10.0.0.1:10000, etc. # 10.0.0.1:10000, etc.
# #
# If no servers are specified, then localhost is used as the host. # If no servers are specified, then localhost is used as the host.
servers = ["localhost"]` servers = ["localhost"]
`
func (r *Redis) SampleConfig() string { func (r *Redis) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -15,12 +15,13 @@ type RethinkDB struct {
} }
var sampleConfig = ` var sampleConfig = `
# An array of URI to gather stats about. Specify an ip or hostname # An array of URI to gather stats about. Specify an ip or hostname
# with optional port add password. ie rethinkdb://user:auth_key@10.10.3.30:28105, # with optional port add password. ie rethinkdb://user:auth_key@10.10.3.30:28105,
# rethinkdb://10.10.3.33:18832, 10.0.0.1:10000, etc. # rethinkdb://10.10.3.33:18832, 10.0.0.1:10000, etc.
# #
# If no servers are specified, then 127.0.0.1 is used as the host and 28015 as the port. # If no servers are specified, then 127.0.0.1 is used as the host and 28015 as the port.
servers = ["127.0.0.1:28015"]` servers = ["127.0.0.1:28015"]
`
func (r *RethinkDB) SampleConfig() string { func (r *RethinkDB) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -26,10 +26,11 @@ func (_ *CPUStats) Description() string {
} }
var sampleConfig = ` var sampleConfig = `
# Whether to report per-cpu stats or not # Whether to report per-cpu stats or not
percpu = true percpu = true
# Whether to report total system cpu stats or not # Whether to report total system cpu stats or not
totalcpu = true` totalcpu = true
`
func (_ *CPUStats) SampleConfig() string { func (_ *CPUStats) SampleConfig() string {
return sampleConfig return sampleConfig

View File

@ -19,11 +19,11 @@ func (_ *NetIOStats) Description() string {
} }
var netSampleConfig = ` var netSampleConfig = `
# By default, telegraf gathers stats from any up interface (excluding loopback) # By default, telegraf gathers stats from any up interface (excluding loopback)
# Setting interfaces will tell it to gather these explicit interfaces, # Setting interfaces will tell it to gather these explicit interfaces,
# regardless of status. # regardless of status.
# #
# interfaces = ["eth0", ... ] # interfaces = ["eth0", ... ]
` `
func (_ *NetIOStats) SampleConfig() string { func (_ *NetIOStats) SampleConfig() string {