diff --git a/config.go b/config.go index 99aa9d880..e930c9505 100644 --- a/config.go +++ b/config.go @@ -349,25 +349,21 @@ var header = `# Telegraf configuration # Tags can also be specified via a normal map, but only one form at a time: [tags] - # dc = "us-east-1" + # dc = "us-east-1" # Configuration for telegraf agent [agent] - # Default data collection interval for all plugins - interval = "10s" - - # If utc = false, uses local time (utc is highly recommended) - utc = true - - # Precision of writes, valid values are n, u, ms, s, m, and h - # note: using second precision greatly helps InfluxDB compression - precision = "s" - - # run telegraf in debug mode - debug = false - - # Override default hostname, if empty use os.Hostname() - hostname = "" + # Default data collection interval for all plugins + interval = "10s" + # If utc = false, uses local time (utc is highly recommended) + utc = true + # Precision of writes, valid values are n, u, ms, s, m, and h + # note: using second precision greatly helps InfluxDB compression + precision = "s" + # run telegraf in debug mode + debug = false + # Override default hostname, if empty use os.Hostname() + hostname = "" ############################################################################### @@ -413,7 +409,7 @@ func PrintSampleConfig(pluginFilters []string, outputFilters []string) { config := output.SampleConfig() if config == "" { - fmt.Printf("\n # no configuration\n") + fmt.Printf("\n # no configuration\n") } else { fmt.Printf(config) } @@ -455,7 +451,7 @@ func printConfig(name string, plugin plugins.Plugin) { fmt.Printf("\n# %s\n[%s]", plugin.Description(), name) config := plugin.SampleConfig() if config == "" { - fmt.Printf("\n # no configuration\n") + fmt.Printf("\n # no configuration\n") } else { fmt.Printf(config) } diff --git a/etc/config.sample.toml b/etc/config.sample.toml index 43e88e8fc..c66ea50f4 100644 --- a/etc/config.sample.toml +++ b/etc/config.sample.toml @@ -21,25 +21,25 @@ # Tags can also be specified via a normal map, but only one form at a time: [tags] - # dc = "us-east-1" + # dc = "us-east-1" # Configuration for telegraf agent [agent] - # Default data collection interval for all plugins - interval = "10s" + # Default data collection interval for all plugins + interval = "10s" - # If utc = false, uses local time (utc is highly recommended) - utc = true + # If utc = false, uses local time (utc is highly recommended) + utc = true - # Precision of writes, valid values are n, u, ms, s, m, and h - # note: using second precision greatly helps InfluxDB compression - precision = "s" + # Precision of writes, valid values are n, u, ms, s, m, and h + # note: using second precision greatly helps InfluxDB compression + precision = "s" - # run telegraf in debug mode - debug = false + # run telegraf in debug mode + debug = false - # Override default hostname, if empty use os.Hostname() - hostname = "" + # Override default hostname, if empty use os.Hostname() + hostname = "" ############################################################################### @@ -50,24 +50,24 @@ # Configuration for influxdb server to send metrics to [outputs.influxdb] - # The full HTTP endpoint URL for your InfluxDB instance - # Multiple urls can be specified for InfluxDB cluster support. Server to - # write to will be randomly chosen each interval. - urls = ["http://localhost:8086"] # required. + # The full HTTP endpoint URL for your InfluxDB instance + # Multiple urls can be specified for InfluxDB cluster support. Server to + # write to will be randomly chosen each interval. + urls = ["http://localhost:8086"] # required. - # The target database for metrics. This database must already exist - database = "telegraf" # required. + # The target database for metrics. This database must already exist + database = "telegraf" # required. - # Connection timeout (for the connection with InfluxDB), formatted as a string. - # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". - # If not provided, will default to 0 (no timeout) - # timeout = "5s" + # Connection timeout (for the connection with InfluxDB), formatted as a string. + # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". + # If not provided, will default to 0 (no timeout) + # timeout = "5s" - # username = "telegraf" - # password = "metricsmetricsmetricsmetrics" + # username = "telegraf" + # password = "metricsmetricsmetricsmetrics" - # Set the user agent for the POSTs (can be useful for log differentiation) - # user_agent = "telegraf" + # Set the user agent for the POSTs (can be useful for log differentiation) + # user_agent = "telegraf" ############################################################################### @@ -76,29 +76,29 @@ # Read metrics about cpu usage [cpu] - # Whether to report per-cpu stats or not - percpu = true - # Whether to report total system cpu stats or not - totalcpu = true - # Comment this line if you want the raw CPU time metrics - drop = ["cpu_time"] + # Whether to report per-cpu stats or not + percpu = true + # Whether to report total system cpu stats or not + totalcpu = true + # Comment this line if you want the raw CPU time metrics + drop = ["cpu_time"] # Read metrics about disk usage by mount point [disk] - # no configuration + # no configuration # Read metrics about disk IO by device [io] - # no configuration + # no configuration # Read metrics about memory usage [mem] - # no configuration + # no configuration # Read metrics about swap memory usage [swap] - # no configuration + # no configuration # Read metrics about system load & uptime [system] - # no configuration + # no configuration diff --git a/outputs/amqp/amqp.go b/outputs/amqp/amqp.go index 1bfc2327b..ec7e7332d 100644 --- a/outputs/amqp/amqp.go +++ b/outputs/amqp/amqp.go @@ -24,13 +24,13 @@ type AMQP struct { } var sampleConfig = ` - # AMQP url - url = "amqp://localhost:5672/influxdb" - # AMQP exchange - exchange = "telegraf" - # Telegraf tag to use as a routing key - # ie, if this tag exists, it's value will be used as the routing key - routing_tag = "host" + # AMQP url + url = "amqp://localhost:5672/influxdb" + # AMQP exchange + exchange = "telegraf" + # Telegraf tag to use as a routing key + # ie, if this tag exists, it's value will be used as the routing key + routing_tag = "host" ` func (q *AMQP) Connect() error { diff --git a/outputs/datadog/datadog.go b/outputs/datadog/datadog.go index 627ba125e..2190ea4b3 100644 --- a/outputs/datadog/datadog.go +++ b/outputs/datadog/datadog.go @@ -22,11 +22,11 @@ type Datadog struct { } var sampleConfig = ` - # Datadog API key - apikey = "my-secret-key" # required. + # Datadog API key + apikey = "my-secret-key" # required. - # Connection timeout. - # timeout = "5s" + # Connection timeout. + # timeout = "5s" ` type TimeSeries struct { diff --git a/outputs/influxdb/influxdb.go b/outputs/influxdb/influxdb.go index 044288498..f49b58c45 100644 --- a/outputs/influxdb/influxdb.go +++ b/outputs/influxdb/influxdb.go @@ -27,20 +27,20 @@ type InfluxDB struct { } var sampleConfig = ` - # The full HTTP endpoint URL for your InfluxDB instance - # Multiple urls can be specified for InfluxDB cluster support. - urls = ["http://localhost:8086"] # required - # The target database for metrics (telegraf will create it if not exists) - database = "telegraf" # required + # The full HTTP endpoint URL for your InfluxDB instance + # Multiple urls can be specified for InfluxDB cluster support. + urls = ["http://localhost:8086"] # required + # The target database for metrics (telegraf will create it if not exists) + database = "telegraf" # required - # # Connection timeout (for the connection with InfluxDB), formatted as a string. - # # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". - # # If not provided, will default to 0 (no timeout) - # timeout = "5s" - # username = "telegraf" - # password = "metricsmetricsmetricsmetrics" - # # Set the user agent for the POSTs (can be useful for log differentiation) - # user_agent = "telegraf" + # Connection timeout (for the connection with InfluxDB), formatted as a string. + # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". + # If not provided, will default to 0 (no timeout) + # timeout = "5s" + # username = "telegraf" + # password = "metricsmetricsmetricsmetrics" + # Set the user agent for the POSTs (can be useful for log differentiation) + # user_agent = "telegraf" ` func (i *InfluxDB) Connect() error { diff --git a/outputs/kafka/kafka.go b/outputs/kafka/kafka.go index ce9946ba3..d0b98c42d 100644 --- a/outputs/kafka/kafka.go +++ b/outputs/kafka/kafka.go @@ -22,13 +22,13 @@ type Kafka struct { } var sampleConfig = ` - # URLs of kafka brokers - brokers = ["localhost:9092"] - # Kafka topic for producer messages - topic = "telegraf" - # Telegraf tag to use as a routing key - # ie, if this tag exists, it's value will be used as the routing key - routing_tag = "host" + # URLs of kafka brokers + brokers = ["localhost:9092"] + # Kafka topic for producer messages + topic = "telegraf" + # Telegraf tag to use as a routing key + # ie, if this tag exists, it's value will be used as the routing key + routing_tag = "host" ` func (k *Kafka) Connect() error { diff --git a/outputs/mqtt/mqtt.go b/outputs/mqtt/mqtt.go index dd91883c0..6d00cab68 100644 --- a/outputs/mqtt/mqtt.go +++ b/outputs/mqtt/mqtt.go @@ -33,16 +33,16 @@ type MQTT struct { } var sampleConfig = ` - servers = ["localhost:1883"] # required. + servers = ["localhost:1883"] # required. - # MQTT outputs send metrics to this topic format - # "/host///" - # ex: prefix/host/web01.example.com/mem/available - # topic_prefix = "prefix" + # MQTT outputs send metrics to this topic format + # "/host///" + # ex: prefix/host/web01.example.com/mem/available + # topic_prefix = "prefix" - # username and password to connect MQTT server. - # username = "telegraf" - # password = "metricsmetricsmetricsmetrics" + # username and password to connect MQTT server. + # username = "telegraf" + # password = "metricsmetricsmetricsmetrics" ` func (m *MQTT) Connect() error { diff --git a/outputs/opentsdb/opentsdb.go b/outputs/opentsdb/opentsdb.go index 04fda33c4..a05fd2623 100644 --- a/outputs/opentsdb/opentsdb.go +++ b/outputs/opentsdb/opentsdb.go @@ -22,18 +22,18 @@ type OpenTSDB struct { } var sampleConfig = ` - # prefix for metrics keys - prefix = "my.specific.prefix." + # prefix for metrics keys + prefix = "my.specific.prefix." - ## Telnet Mode ## - # DNS name of the OpenTSDB server in telnet mode - host = "opentsdb.example.com" + ## Telnet Mode ## + # DNS name of the OpenTSDB server in telnet mode + host = "opentsdb.example.com" - # Port of the OpenTSDB server in telnet mode - port = 4242 + # Port of the OpenTSDB server in telnet mode + port = 4242 - # Debug true - Prints OpenTSDB communication - debug = false + # Debug true - Prints OpenTSDB communication + debug = false ` type MetricLine struct { diff --git a/plugins/apache/apache.go b/plugins/apache/apache.go index e90567826..86f9cda2d 100644 --- a/plugins/apache/apache.go +++ b/plugins/apache/apache.go @@ -19,8 +19,8 @@ type Apache struct { } var sampleConfig = ` - # An array of Apache status URI to gather stats. - urls = ["http://localhost/server-status?auto"] + # An array of Apache status URI to gather stats. + urls = ["http://localhost/server-status?auto"] ` func (n *Apache) SampleConfig() string { @@ -68,82 +68,93 @@ func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error { if resp.StatusCode != http.StatusOK { return fmt.Errorf("%s returned HTTP status %s", addr.String(), resp.Status) } - + tags := getTags(addr) - + sc := bufio.NewScanner(resp.Body) for sc.Scan() { - line := sc.Text() - if strings.Contains(line, ":") { - - parts := strings.SplitN(line, ":", 2) - key, part := strings.Replace(parts[0], " ", "", -1), strings.TrimSpace(parts[1]) - - switch key { - - case "Scoreboard": - n.gatherScores(part, acc, tags) - default: - value, err := strconv.ParseFloat(part, 32) - if err != nil { - continue - } - acc.Add(key, value, tags) - } - } + line := sc.Text() + if strings.Contains(line, ":") { + + parts := strings.SplitN(line, ":", 2) + key, part := strings.Replace(parts[0], " ", "", -1), strings.TrimSpace(parts[1]) + + switch key { + + case "Scoreboard": + n.gatherScores(part, acc, tags) + default: + value, err := strconv.ParseFloat(part, 32) + if err != nil { + continue + } + acc.Add(key, value, tags) + } + } } return nil } func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[string]string) { - - var waiting, open int = 0, 0 - var S, R, W, K, D, C, L, G, I int = 0, 0, 0, 0, 0, 0, 0, 0, 0 - - for _, s := range strings.Split(data, "") { - - switch s { - case "_": waiting++ - case "S": S++ - case "R": R++ - case "W": W++ - case "K": K++ - case "D": D++ - case "C": C++ - case "L": L++ - case "G": G++ - case "I": I++ - case ".": open++ - } - } - - acc.Add("scboard_waiting", float64(waiting), tags); - acc.Add("scboard_starting", float64(S), tags); - acc.Add("scboard_reading", float64(R), tags); - acc.Add("scboard_sending", float64(W), tags); - acc.Add("scboard_keepalive", float64(K), tags); - acc.Add("scboard_dnslookup", float64(D), tags); - acc.Add("scboard_closing", float64(C), tags); - acc.Add("scboard_logging", float64(L), tags); - acc.Add("scboard_finishing", float64(G), tags); - acc.Add("scboard_idle_cleanup", float64(I), tags); - acc.Add("scboard_open", float64(open), tags); + + var waiting, open int = 0, 0 + var S, R, W, K, D, C, L, G, I int = 0, 0, 0, 0, 0, 0, 0, 0, 0 + + for _, s := range strings.Split(data, "") { + + switch s { + case "_": + waiting++ + case "S": + S++ + case "R": + R++ + case "W": + W++ + case "K": + K++ + case "D": + D++ + case "C": + C++ + case "L": + L++ + case "G": + G++ + case "I": + I++ + case ".": + open++ + } + } + + acc.Add("scboard_waiting", float64(waiting), tags) + acc.Add("scboard_starting", float64(S), tags) + acc.Add("scboard_reading", float64(R), tags) + acc.Add("scboard_sending", float64(W), tags) + acc.Add("scboard_keepalive", float64(K), tags) + acc.Add("scboard_dnslookup", float64(D), tags) + acc.Add("scboard_closing", float64(C), tags) + acc.Add("scboard_logging", float64(L), tags) + acc.Add("scboard_finishing", float64(G), tags) + acc.Add("scboard_idle_cleanup", float64(I), tags) + acc.Add("scboard_open", float64(open), tags) } // Get tag(s) for the apache plugin func getTags(addr *url.URL) map[string]string { h := addr.Host host, port, err := net.SplitHostPort(h) - if err != nil { - host = addr.Host - if addr.Scheme == "http" { - port = "80" - } else if addr.Scheme == "https" { - port = "443" - } else { - port = "" - } + if err != nil { + host = addr.Host + if addr.Scheme == "http" { + port = "80" + } else if addr.Scheme == "https" { + port = "443" + } else { + port = "" + } } return map[string]string{"server": host, "port": port} } diff --git a/plugins/disque/disque.go b/plugins/disque/disque.go index 4e4e3b47f..004aa3c0f 100644 --- a/plugins/disque/disque.go +++ b/plugins/disque/disque.go @@ -21,12 +21,12 @@ type Disque struct { } var sampleConfig = ` - # 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, - # 10.0.0.1:10000, etc. - # - # If no servers are specified, then localhost is used as the host. - servers = ["localhost"] + # 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, + # 10.0.0.1:10000, etc. + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] ` func (r *Disque) SampleConfig() string { diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index 2127e93b7..e5236f42b 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -28,12 +28,12 @@ type node struct { } const sampleConfig = ` - # specify a list of one or more Elasticsearch servers - servers = ["http://localhost:9200"] + # specify a list of one or more Elasticsearch servers + servers = ["http://localhost:9200"] - # set local to false when you want to read the indices stats from all nodes - # within the cluster - local = true + # set local to false when you want to read the indices stats from all nodes + # within the cluster + local = true ` // Elasticsearch is a plugin to read stats from one or many Elasticsearch diff --git a/plugins/exec/exec.go b/plugins/exec/exec.go index d37f36c72..ece9543dd 100644 --- a/plugins/exec/exec.go +++ b/plugins/exec/exec.go @@ -13,17 +13,17 @@ import ( ) const sampleConfig = ` - # specify commands via an array of tables - [[exec.commands]] - # the command to run - command = "/usr/bin/mycollector --foo=bar" + # specify commands via an array of tables + [[exec.commands]] + # the command to run + command = "/usr/bin/mycollector --foo=bar" - # name of the command (used as a prefix for measurements) - name = "mycollector" + # name of the command (used as a prefix for measurements) + name = "mycollector" - # Only run this command if it has been at least this many - # seconds since it last ran - interval = 10 + # Only run this command if it has been at least this many + # seconds since it last ran + interval = 10 ` type Exec struct { diff --git a/plugins/haproxy/haproxy.go b/plugins/haproxy/haproxy.go index 351b4a8e7..a1d14a32a 100644 --- a/plugins/haproxy/haproxy.go +++ b/plugins/haproxy/haproxy.go @@ -84,13 +84,13 @@ type haproxy struct { } var sampleConfig = ` - # An array of address to gather stats about. Specify an ip on hostname - # with optional port. ie localhost, 10.10.3.33:1936, etc. - # - # If no servers are specified, then default to 127.0.0.1:1936 - servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"] - # Or you can also use local socket(not work yet) - # servers = ["socket:/run/haproxy/admin.sock"] + # An array of address to gather stats about. Specify an ip on hostname + # with optional port. ie localhost, 10.10.3.33:1936, etc. + # + # If no servers are specified, then default to 127.0.0.1:1936 + servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"] + # Or you can also use local socket(not work yet) + # servers = ["socket:/run/haproxy/admin.sock"] ` func (r *haproxy) SampleConfig() string { diff --git a/plugins/httpjson/httpjson.go b/plugins/httpjson/httpjson.go index 665622d46..c9717d558 100644 --- a/plugins/httpjson/httpjson.go +++ b/plugins/httpjson/httpjson.go @@ -46,25 +46,25 @@ func (c RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { } var sampleConfig = ` - # Specify services via an array of tables - [[httpjson.services]] + # Specify services via an array of tables + [[httpjson.services]] - # a name for the service being polled - name = "webserver_stats" + # a name for the service being polled + name = "webserver_stats" - # URL of each server in the service's cluster - servers = [ - "http://localhost:9999/stats/", - "http://localhost:9998/stats/", - ] + # URL of each server in the service's cluster + servers = [ + "http://localhost:9999/stats/", + "http://localhost:9998/stats/", + ] - # HTTP method to use (case-sensitive) - method = "GET" + # HTTP method to use (case-sensitive) + method = "GET" - # HTTP parameters (all values must be strings) - [httpjson.services.parameters] - event_type = "cpu_spike" - threshold = "0.75" + # HTTP parameters (all values must be strings) + [httpjson.services.parameters] + event_type = "cpu_spike" + threshold = "0.75" ` func (h *HttpJson) SampleConfig() string { diff --git a/plugins/kafka_consumer/kafka_consumer.go b/plugins/kafka_consumer/kafka_consumer.go index 74c995097..c49235259 100644 --- a/plugins/kafka_consumer/kafka_consumer.go +++ b/plugins/kafka_consumer/kafka_consumer.go @@ -20,17 +20,17 @@ type Kafka struct { } var sampleConfig = ` - # topic to consume - topic = "topic_with_metrics" + # topic to consume + topic = "topic_with_metrics" - # the name of the consumer group - consumerGroupName = "telegraf_metrics_consumers" + # the name of the consumer group + consumerGroupName = "telegraf_metrics_consumers" - # an array of Zookeeper connection strings - zookeeperPeers = ["localhost:2181"] + # an array of Zookeeper connection strings + zookeeperPeers = ["localhost:2181"] - # Batch size of points sent to InfluxDB - batchSize = 1000 + # Batch size of points sent to InfluxDB + batchSize = 1000 ` func (k *Kafka) SampleConfig() string { diff --git a/plugins/leofs/leofs.go b/plugins/leofs/leofs.go index ce6bd37ac..32e5ee99a 100644 --- a/plugins/leofs/leofs.go +++ b/plugins/leofs/leofs.go @@ -131,11 +131,11 @@ var serverTypeMapping = map[string]ServerType{ } var sampleConfig = ` - # An array of URI to gather stats about LeoFS. - # 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. - servers = ["127.0.0.1:4021"] + # An array of URI to gather stats about LeoFS. + # 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. + servers = ["127.0.0.1:4021"] ` func (l *LeoFS) SampleConfig() string { diff --git a/plugins/lustre2/lustre2.go b/plugins/lustre2/lustre2.go index e18b09c24..fab8f07bb 100644 --- a/plugins/lustre2/lustre2.go +++ b/plugins/lustre2/lustre2.go @@ -25,11 +25,11 @@ type Lustre2 struct { } var sampleConfig = ` - # An array of /proc globs to search for Lustre stats - # 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"] - # mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"] + # An array of /proc globs to search for Lustre stats + # 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"] + # mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"] ` /* The wanted fields would be a []string if not for the diff --git a/plugins/memcached/memcached.go b/plugins/memcached/memcached.go index cbab91e85..3efa9f151 100644 --- a/plugins/memcached/memcached.go +++ b/plugins/memcached/memcached.go @@ -17,11 +17,11 @@ type Memcached struct { } var sampleConfig = ` - # An array of address to gather stats about. Specify an ip on hostname - # with optional port. ie localhost, 10.0.0.1:11211, etc. - # - # If no servers are specified, then localhost is used as the host. - servers = ["localhost"] + # An array of address to gather stats about. Specify an ip on hostname + # with optional port. ie localhost, 10.0.0.1:11211, etc. + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] ` var defaultTimeout = 5 * time.Second diff --git a/plugins/mongodb/mongodb.go b/plugins/mongodb/mongodb.go index b26da7a4e..87882a341 100644 --- a/plugins/mongodb/mongodb.go +++ b/plugins/mongodb/mongodb.go @@ -25,12 +25,12 @@ type Ssl struct { } var sampleConfig = ` - # 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, - # 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. - servers = ["127.0.0.1:27017"] + # 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, + # 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. + servers = ["127.0.0.1:27017"] ` func (m *MongoDB) SampleConfig() string { diff --git a/plugins/mysql/mysql.go b/plugins/mysql/mysql.go index 1825248d8..a4ae7a6da 100644 --- a/plugins/mysql/mysql.go +++ b/plugins/mysql/mysql.go @@ -14,14 +14,14 @@ type Mysql struct { } var sampleConfig = ` - # specify servers via a url matching: - # [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]] - # e.g. - # root:root@http://10.0.0.18/?tls=false - # root:passwd@tcp(127.0.0.1:3036)/ - # - # If no servers are specified, then localhost is used as the host. - servers = ["localhost"] + # specify servers via a url matching: + # [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]] + # e.g. + # root:root@http://10.0.0.18/?tls=false + # root:passwd@tcp(127.0.0.1:3036)/ + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] ` func (m *Mysql) SampleConfig() string { diff --git a/plugins/nginx/nginx.go b/plugins/nginx/nginx.go index 36caf7a63..2c30ea671 100644 --- a/plugins/nginx/nginx.go +++ b/plugins/nginx/nginx.go @@ -19,8 +19,8 @@ type Nginx struct { } var sampleConfig = ` - # An array of Nginx stub_status URI to gather stats. - urls = ["http://localhost/status"] + # An array of Nginx stub_status URI to gather stats. + urls = ["http://localhost/status"] ` func (n *Nginx) SampleConfig() string { @@ -141,22 +141,21 @@ func (n *Nginx) gatherUrl(addr *url.URL, acc plugins.Accumulator) error { // Get tag(s) for the nginx plugin func getTags(addr *url.URL) map[string]string { - h := addr.Host - host, port, err := net.SplitHostPort(h) - if err != nil { - host = addr.Host - if addr.Scheme == "http" { - port = "80" - } else if addr.Scheme == "https" { - port = "443" - } else { - port = "" - } - } - return map[string]string{"server": host, "port": port} + h := addr.Host + host, port, err := net.SplitHostPort(h) + if err != nil { + host = addr.Host + if addr.Scheme == "http" { + port = "80" + } else if addr.Scheme == "https" { + port = "443" + } else { + port = "" + } + } + return map[string]string{"server": host, "port": port} } - func init() { plugins.Add("nginx", func() plugins.Plugin { return &Nginx{} diff --git a/plugins/phpfpm/phpfpm.go b/plugins/phpfpm/phpfpm.go index 2dde9f1b5..f3873716f 100644 --- a/plugins/phpfpm/phpfpm.go +++ b/plugins/phpfpm/phpfpm.go @@ -39,19 +39,19 @@ type phpfpm struct { } var sampleConfig = ` - # An array of addresses to gather stats about. Specify an ip or hostname - # with optional port and path. - # - # Plugin can be configured in two modes (both can be used): - # - http: the URL must start with http:// or https://, ex: - # "http://localhost/status" - # "http://192.168.130.1/status?full" - # - unixsocket: path to fpm socket, ex: - # "/var/run/php5-fpm.sock" - # "192.168.10.10:/var/run/php5-fpm-www2.sock" - # - # If no servers are specified, then default to 127.0.0.1/server-status - urls = ["http://localhost/status"] + # An array of addresses to gather stats about. Specify an ip or hostname + # with optional port and path. + # + # Plugin can be configured in two modes (both can be used): + # - http: the URL must start with http:// or https://, ex: + # "http://localhost/status" + # "http://192.168.130.1/status?full" + # - unixsocket: path to fpm socket, ex: + # "/var/run/php5-fpm.sock" + # "192.168.10.10:/var/run/php5-fpm-www2.sock" + # + # If no servers are specified, then default to 127.0.0.1/server-status + urls = ["http://localhost/status"] ` func (r *phpfpm) SampleConfig() string { diff --git a/plugins/ping/ping.go b/plugins/ping/ping.go index fd26b8a8b..e894fe297 100644 --- a/plugins/ping/ping.go +++ b/plugins/ping/ping.go @@ -40,16 +40,16 @@ func (_ *Ping) Description() string { } var sampleConfig = ` - # urls to ping - urls = ["www.google.com"] # required - # number of pings to send (ping -c ) - count = 1 # required - # interval, in s, at which to ping. 0 == default (ping -i ) - ping_interval = 0.0 - # ping timeout, in s. 0 == no timeout (ping -t ) - timeout = 0.0 - # interface to send ping from (ping -I ) - interface = "" + # urls to ping + urls = ["www.google.com"] # required + # number of pings to send (ping -c ) + count = 1 # required + # interval, in s, at which to ping. 0 == default (ping -i ) + ping_interval = 0.0 + # ping timeout, in s. 0 == no timeout (ping -t ) + timeout = 0.0 + # interface to send ping from (ping -I ) + interface = "" ` func (_ *Ping) SampleConfig() string { diff --git a/plugins/postgresql/postgresql.go b/plugins/postgresql/postgresql.go index e72ada85f..2a550b5a3 100644 --- a/plugins/postgresql/postgresql.go +++ b/plugins/postgresql/postgresql.go @@ -24,33 +24,33 @@ type Postgresql struct { var ignoredColumns = map[string]bool{"datid": true, "datname": true, "stats_reset": true} var sampleConfig = ` - # specify servers via an array of tables - [[postgresql.servers]] + # specify servers via an array of tables + [[postgresql.servers]] - # specify address via a url matching: - # postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full] - # or a simple string: - # host=localhost user=pqotest password=... sslmode=... dbname=app_production - # - # All connection parameters are optional. By default, the host is localhost - # and the user is the currently running user. For localhost, we default - # to sslmode=disable as well. - # - # Without the dbname parameter, the driver will default to a database - # with the same name as the user. This dbname is just for instantiating a - # connection with the server and doesn't restrict the databases we are trying - # to grab metrics for. - # + # specify address via a url matching: + # postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full] + # or a simple string: + # host=localhost user=pqotest password=... sslmode=... dbname=app_production + # + # All connection parameters are optional. By default, the host is localhost + # and the user is the currently running user. For localhost, we default + # to sslmode=disable as well. + # + # Without the dbname parameter, the driver will default to a database + # with the same name as the user. This dbname is just for instantiating a + # connection with the server and doesn't restrict the databases we are trying + # to grab metrics for. + # - address = "sslmode=disable" + address = "sslmode=disable" - # A list of databases to pull metrics about. If not specified, metrics for all - # databases are gathered. + # A list of databases to pull metrics about. If not specified, metrics for all + # databases are gathered. - # databases = ["app_production", "blah_testing"] + # databases = ["app_production", "blah_testing"] - # [[postgresql.servers]] - # address = "influx@remoteserver" + # [[postgresql.servers]] + # address = "influx@remoteserver" ` func (p *Postgresql) SampleConfig() string { diff --git a/plugins/procstat/procstat.go b/plugins/procstat/procstat.go index 8368f8db7..660033985 100644 --- a/plugins/procstat/procstat.go +++ b/plugins/procstat/procstat.go @@ -29,12 +29,12 @@ func NewProcstat() *Procstat { } var sampleConfig = ` - [[procstat.specifications]] - prefix = "" # optional string to prefix measurements - # Use one of pid_file or exe to find process - pid_file = "/var/run/nginx.pid" - # executable name (used by pgrep) - # exe = "nginx" + [[procstat.specifications]] + prefix = "" # optional string to prefix measurements + # Use one of pid_file or exe to find process + pid_file = "/var/run/nginx.pid" + # executable name (used by pgrep) + # exe = "nginx" ` func (_ *Procstat) SampleConfig() string { diff --git a/plugins/prometheus/prometheus.go b/plugins/prometheus/prometheus.go index 9e8b964e7..8c88e73d3 100644 --- a/plugins/prometheus/prometheus.go +++ b/plugins/prometheus/prometheus.go @@ -17,8 +17,8 @@ type Prometheus struct { } var sampleConfig = ` - # An array of urls to scrape metrics from. - urls = ["http://localhost:9100/metrics"] + # An array of urls to scrape metrics from. + urls = ["http://localhost:9100/metrics"] ` func (r *Prometheus) SampleConfig() string { diff --git a/plugins/rabbitmq/rabbitmq.go b/plugins/rabbitmq/rabbitmq.go index 45f1cac5f..4fad0aa2e 100644 --- a/plugins/rabbitmq/rabbitmq.go +++ b/plugins/rabbitmq/rabbitmq.go @@ -69,16 +69,16 @@ type Node struct { } var sampleConfig = ` - # Specify servers via an array of tables - [[rabbitmq.servers]] - # name = "rmq-server-1" # optional tag - # url = "http://localhost:15672" - # username = "guest" - # password = "guest" + # Specify servers via an array of tables + [[rabbitmq.servers]] + # name = "rmq-server-1" # optional tag + # url = "http://localhost:15672" + # username = "guest" + # password = "guest" - # A list of nodes to pull metrics about. If not specified, metrics for - # all nodes are gathered. - # nodes = ["rabbit@node1", "rabbit@node2"] + # A list of nodes to pull metrics about. If not specified, metrics for + # all nodes are gathered. + # nodes = ["rabbit@node1", "rabbit@node2"] ` func (r *RabbitMQ) SampleConfig() string { diff --git a/plugins/redis/redis.go b/plugins/redis/redis.go index a04729af3..f142e6ef7 100644 --- a/plugins/redis/redis.go +++ b/plugins/redis/redis.go @@ -18,15 +18,15 @@ type Redis struct { } var sampleConfig = ` - # specify servers via a url matching: - # [protocol://][:password]@address[:port] - # e.g. - # tcp://localhost:6379 - # tcp://:password@192.168.99.100 - # - # If no servers are specified, then localhost is used as the host. - # If no port is specified, 6379 is used - servers = ["tcp://localhost:6379"] + # specify servers via a url matching: + # [protocol://][:password]@address[:port] + # e.g. + # tcp://localhost:6379 + # tcp://:password@192.168.99.100 + # + # If no servers are specified, then localhost is used as the host. + # If no port is specified, 6379 is used + servers = ["tcp://localhost:6379"] ` func (r *Redis) SampleConfig() string { diff --git a/plugins/rethinkdb/rethinkdb.go b/plugins/rethinkdb/rethinkdb.go index 412145e1a..8af890661 100644 --- a/plugins/rethinkdb/rethinkdb.go +++ b/plugins/rethinkdb/rethinkdb.go @@ -15,12 +15,12 @@ type RethinkDB struct { } var sampleConfig = ` - # 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, - # 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. - servers = ["127.0.0.1:28015"] + # 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, + # 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. + servers = ["127.0.0.1:28015"] ` func (r *RethinkDB) SampleConfig() string { diff --git a/plugins/statsd/statsd.go b/plugins/statsd/statsd.go index 25fabf91a..50e6b891e 100644 --- a/plugins/statsd/statsd.go +++ b/plugins/statsd/statsd.go @@ -104,35 +104,35 @@ type cachedtimings struct { } func (_ *Statsd) Description() string { - return "Statsd listener" + return "Statsd Server" } const sampleConfig = ` - # Address and port to host UDP listener on - service_address = ":8125" - # Delete gauges every interval (default=false) - delete_gauges = false - # Delete counters every interval (default=false) - delete_counters = false - # Delete sets every interval (default=false) - delete_sets = false - # Delete timings & histograms every interval (default=true) - delete_timings = true - # Percentiles to calculate for timing & histogram stats - percentiles = [90] + # Address and port to host UDP listener on + service_address = ":8125" + # Delete gauges every interval (default=false) + delete_gauges = false + # Delete counters every interval (default=false) + delete_counters = false + # Delete sets every interval (default=false) + delete_sets = false + # Delete timings & histograms every interval (default=true) + delete_timings = true + # Percentiles to calculate for timing & histogram stats + percentiles = [90] - # templates = [ - # "cpu.* measurement*" - # ] + # templates = [ + # "cpu.* measurement*" + # ] - # Number of UDP messages allowed to queue up, once filled, - # the statsd server will start dropping packets - allowed_pending_messages = 10000 + # Number of UDP messages allowed to queue up, once filled, + # the statsd server will start dropping packets + allowed_pending_messages = 10000 - # Number of timing/histogram values to track per-measurement in the - # calculation of percentiles. Raising this limit increases the accuracy - # of percentiles but also increases the memory usage and cpu time. - percentile_limit = 1000 + # Number of timing/histogram values to track per-measurement in the + # calculation of percentiles. Raising this limit increases the accuracy + # of percentiles but also increases the memory usage and cpu time. + percentile_limit = 1000 ` func (_ *Statsd) SampleConfig() string { diff --git a/plugins/system/cpu.go b/plugins/system/cpu.go index 7595b693a..2655a1ed6 100644 --- a/plugins/system/cpu.go +++ b/plugins/system/cpu.go @@ -26,12 +26,12 @@ func (_ *CPUStats) Description() string { } var sampleConfig = ` - # Whether to report per-cpu stats or not - percpu = true - # Whether to report total system cpu stats or not - totalcpu = true - # Comment this line if you want the raw CPU time metrics - drop = ["cpu_time"] + # Whether to report per-cpu stats or not + percpu = true + # Whether to report total system cpu stats or not + totalcpu = true + # Comment this line if you want the raw CPU time metrics + drop = ["cpu_time"] ` func (_ *CPUStats) SampleConfig() string { diff --git a/plugins/system/disk.go b/plugins/system/disk.go index 6d65139c5..718d79949 100644 --- a/plugins/system/disk.go +++ b/plugins/system/disk.go @@ -17,10 +17,10 @@ func (_ *DiskStats) Description() string { } var diskSampleConfig = ` - # By default, telegraf gather stats for all mountpoints. - # Setting mountpoints will restrict the stats to the specified ones. - # mountpoints. - # Mountpoints=["/"] + # By default, telegraf gather stats for all mountpoints. + # Setting mountpoints will restrict the stats to the specified ones. + # mountpoints. + # Mountpoints=["/"] ` func (_ *DiskStats) SampleConfig() string { diff --git a/plugins/system/net.go b/plugins/system/net.go index 8a8847968..7b4df5247 100644 --- a/plugins/system/net.go +++ b/plugins/system/net.go @@ -19,11 +19,11 @@ func (_ *NetIOStats) Description() string { } var netSampleConfig = ` - # By default, telegraf gathers stats from any up interface (excluding loopback) - # Setting interfaces will tell it to gather these explicit interfaces, - # regardless of status. - # - # interfaces = ["eth0", ... ] + # By default, telegraf gathers stats from any up interface (excluding loopback) + # Setting interfaces will tell it to gather these explicit interfaces, + # regardless of status. + # + # interfaces = ["eth0", ... ] ` func (_ *NetIOStats) SampleConfig() string { diff --git a/plugins/zookeeper/zookeeper.go b/plugins/zookeeper/zookeeper.go index 8619bc976..395bd3fdd 100644 --- a/plugins/zookeeper/zookeeper.go +++ b/plugins/zookeeper/zookeeper.go @@ -19,12 +19,12 @@ type Zookeeper struct { } var sampleConfig = ` - # An array of address to gather stats about. Specify an ip or hostname - # with port. ie localhost:2181, 10.0.0.1:2181, etc. + # An array of address to gather stats about. Specify an ip or hostname + # with port. ie localhost:2181, 10.0.0.1:2181, etc. - # If no servers are specified, then localhost is used as the host. - # If no port is specified, 2181 is used - servers = [":2181"] + # If no servers are specified, then localhost is used as the host. + # If no port is specified, 2181 is used + servers = [":2181"] ` var defaultTimeout = time.Second * time.Duration(5)