From 9c5db1057d700f65f5b97ede6dbac0c5217a34ec Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Thu, 7 Jan 2016 13:39:43 -0700 Subject: [PATCH] renaming plugins -> inputs --- CHANGELOG.md | 23 +-- CONFIGURATION.md | 32 ++-- CONTRIBUTING.md | 28 ++-- README.md | 6 +- accumulator.go | 26 ++-- agent.go | 92 ++++++------ agent_test.go | 24 +-- circle.yml | 2 - cmd/telegraf/telegraf.go | 73 +++++++-- etc/telegraf.conf | 20 +-- internal/config/config.go | 140 +++++++++--------- internal/config/config_test.go | 50 ++++--- internal/config/testdata/single_plugin.toml | 6 +- internal/config/testdata/subconfig/exec.conf | 6 +- .../config/testdata/subconfig/memcached.conf | 6 +- .../config/testdata/subconfig/procstat.conf | 2 +- internal/config/testdata/telegraf-agent.toml | 60 ++++---- outputs/all/all.go | 16 -- plugins/all/all.go | 37 ----- plugins/{ => inputs}/aerospike/README.md | 0 plugins/{ => inputs}/aerospike/aerospike.go | 10 +- .../{ => inputs}/aerospike/aerospike_test.go | 0 plugins/inputs/all/all.go | 37 +++++ plugins/{ => inputs}/apache/README.md | 0 plugins/{ => inputs}/apache/apache.go | 8 +- plugins/{ => inputs}/apache/apache_test.go | 0 plugins/{ => inputs}/bcache/README.md | 12 +- plugins/{ => inputs}/bcache/bcache.go | 8 +- plugins/{ => inputs}/bcache/bcache_test.go | 0 plugins/{ => inputs}/disque/disque.go | 8 +- plugins/{ => inputs}/disque/disque_test.go | 0 plugins/{ => inputs}/elasticsearch/README.md | 0 .../elasticsearch/elasticsearch.go | 10 +- .../elasticsearch/elasticsearch_test.go | 0 .../elasticsearch/testdata_test.go | 0 plugins/{ => inputs}/exec/README.md | 0 plugins/{ => inputs}/exec/exec.go | 19 +-- plugins/{ => inputs}/exec/exec_test.go | 5 +- plugins/{ => inputs}/haproxy/haproxy.go | 10 +- plugins/{ => inputs}/haproxy/haproxy_test.go | 0 plugins/{ => inputs}/httpjson/README.md | 0 plugins/{ => inputs}/httpjson/httpjson.go | 10 +- .../{ => inputs}/httpjson/httpjson_test.go | 0 plugins/{ => inputs}/influxdb/README.md | 2 +- plugins/{ => inputs}/influxdb/influxdb.go | 8 +- .../{ => inputs}/influxdb/influxdb_test.go | 2 +- plugins/{ => inputs}/jolokia/README.md | 0 plugins/{ => inputs}/jolokia/jolokia.go | 10 +- plugins/{ => inputs}/jolokia/jolokia_test.go | 0 plugins/{ => inputs}/kafka_consumer/README.md | 0 .../kafka_consumer/kafka_consumer.go | 6 +- .../kafka_consumer_integration_test.go | 0 .../kafka_consumer/kafka_consumer_test.go | 0 plugins/{ => inputs}/leofs/leofs.go | 8 +- plugins/{ => inputs}/leofs/leofs_test.go | 0 plugins/{ => inputs}/lustre2/lustre2.go | 8 +- plugins/{ => inputs}/lustre2/lustre2_test.go | 0 plugins/{ => inputs}/mailchimp/chimp_api.go | 0 plugins/{ => inputs}/mailchimp/mailchimp.go | 8 +- .../{ => inputs}/mailchimp/mailchimp_test.go | 0 plugins/{ => inputs}/memcached/memcached.go | 8 +- .../{ => inputs}/memcached/memcached_test.go | 0 plugins/{ => inputs}/mock_Plugin.go | 2 +- plugins/{ => inputs}/mongodb/mongodb.go | 8 +- plugins/{ => inputs}/mongodb/mongodb_data.go | 4 +- .../{ => inputs}/mongodb/mongodb_data_test.go | 0 .../{ => inputs}/mongodb/mongodb_server.go | 4 +- .../mongodb/mongodb_server_test.go | 0 plugins/{ => inputs}/mongodb/mongodb_test.go | 0 plugins/{ => inputs}/mongodb/mongostat.go | 0 plugins/{ => inputs}/mysql/mysql.go | 8 +- plugins/{ => inputs}/mysql/mysql_test.go | 0 plugins/{ => inputs}/mysql/parse_dsn.go | 0 plugins/{ => inputs}/nginx/nginx.go | 8 +- plugins/{ => inputs}/nginx/nginx_test.go | 0 plugins/{ => inputs}/phpfpm/README.md | 2 +- plugins/{ => inputs}/phpfpm/phpfpm.go | 10 +- plugins/{ => inputs}/phpfpm/phpfpm_fcgi.go | 0 plugins/{ => inputs}/phpfpm/phpfpm_test.go | 0 plugins/{ => inputs}/ping/ping.go | 8 +- plugins/{ => inputs}/ping/ping_test.go | 0 plugins/{ => inputs}/postgresql/README.md | 0 plugins/{ => inputs}/postgresql/postgresql.go | 8 +- .../postgresql/postgresql_test.go | 0 plugins/{ => inputs}/procstat/README.md | 0 plugins/{ => inputs}/procstat/procstat.go | 6 +- .../{ => inputs}/procstat/procstat_test.go | 0 .../{ => inputs}/procstat/spec_processor.go | 6 +- plugins/{ => inputs}/prometheus/prometheus.go | 8 +- .../prometheus/prometheus_test.go | 0 plugins/{ => inputs}/puppetagent/README.md | 0 .../puppetagent/last_run_summary.yaml | 0 .../{ => inputs}/puppetagent/puppetagent.go | 8 +- .../puppetagent/puppetagent_test.go | 0 plugins/{ => inputs}/rabbitmq/rabbitmq.go | 14 +- .../{ => inputs}/rabbitmq/rabbitmq_test.go | 0 plugins/{ => inputs}/redis/redis.go | 12 +- plugins/{ => inputs}/redis/redis_test.go | 0 plugins/{ => inputs}/registry.go | 26 ++-- plugins/{ => inputs}/rethinkdb/rethinkdb.go | 8 +- .../{ => inputs}/rethinkdb/rethinkdb_data.go | 6 +- .../rethinkdb/rethinkdb_data_test.go | 0 .../rethinkdb/rethinkdb_server.go | 10 +- .../rethinkdb/rethinkdb_server_test.go | 0 .../{ => inputs}/rethinkdb/rethinkdb_test.go | 0 plugins/{ => inputs}/statsd/README.md | 0 plugins/{ => inputs}/statsd/running_stats.go | 0 .../{ => inputs}/statsd/running_stats_test.go | 0 plugins/{ => inputs}/statsd/statsd.go | 6 +- plugins/{ => inputs}/statsd/statsd_test.go | 0 plugins/{ => inputs}/system/CPU_README.md | 0 plugins/{ => inputs}/system/MEM_README.md | 0 plugins/{ => inputs}/system/NETSTAT_README.md | 0 plugins/{ => inputs}/system/cpu.go | 6 +- plugins/{ => inputs}/system/cpu_test.go | 0 plugins/{ => inputs}/system/disk.go | 10 +- plugins/{ => inputs}/system/disk_test.go | 0 plugins/{ => inputs}/system/docker.go | 6 +- plugins/{ => inputs}/system/docker_test.go | 0 plugins/{ => inputs}/system/memory.go | 10 +- plugins/{ => inputs}/system/memory_test.go | 0 plugins/{ => inputs}/system/mock_PS.go | 0 plugins/{ => inputs}/system/net.go | 6 +- plugins/{ => inputs}/system/net_test.go | 0 plugins/{ => inputs}/system/netstat.go | 6 +- plugins/{ => inputs}/system/ps.go | 4 +- plugins/{ => inputs}/system/system.go | 6 +- plugins/{ => inputs}/trig/trig.go | 6 +- plugins/{ => inputs}/trig/trig_test.go | 0 plugins/{ => inputs}/twemproxy/twemproxy.go | 12 +- .../{ => inputs}/twemproxy/twemproxy_test.go | 0 plugins/{ => inputs}/zfs/README.md | 0 plugins/{ => inputs}/zfs/zfs.go | 8 +- plugins/{ => inputs}/zfs/zfs_test.go | 0 plugins/{ => inputs}/zookeeper/README.md | 0 plugins/{ => inputs}/zookeeper/zookeeper.go | 8 +- .../{ => inputs}/zookeeper/zookeeper_test.go | 0 plugins/outputs/all/all.go | 16 ++ {outputs => plugins/outputs}/amon/README.md | 0 {outputs => plugins/outputs}/amon/amon.go | 2 +- .../outputs}/amon/amon_test.go | 0 {outputs => plugins/outputs}/amqp/README.md | 0 {outputs => plugins/outputs}/amqp/amqp.go | 2 +- .../outputs}/amqp/amqp_test.go | 0 .../outputs}/datadog/README.md | 0 .../outputs}/datadog/datadog.go | 2 +- .../outputs}/datadog/datadog_test.go | 0 .../outputs}/influxdb/README.md | 0 .../outputs}/influxdb/influxdb.go | 2 +- .../outputs}/influxdb/influxdb_test.go | 0 {outputs => plugins/outputs}/kafka/kafka.go | 2 +- .../outputs}/kafka/kafka_test.go | 0 .../outputs}/kinesis/README.md | 0 .../outputs}/kinesis/kinesis.go | 2 +- .../outputs}/kinesis/kinesis_test.go | 0 .../outputs}/librato/README.md | 0 .../outputs}/librato/librato.go | 2 +- .../outputs}/librato/librato_test.go | 0 {outputs => plugins/outputs}/mqtt/mqtt.go | 2 +- .../outputs}/mqtt/mqtt_test.go | 0 {outputs => plugins/outputs}/nsq/README.md | 0 {outputs => plugins/outputs}/nsq/nsq.go | 2 +- {outputs => plugins/outputs}/nsq/nsq_test.go | 0 .../outputs}/opentsdb/README.md | 0 .../outputs}/opentsdb/opentsdb.go | 2 +- .../outputs}/opentsdb/opentsdb_test.go | 0 .../outputs}/prometheus_client/README.md | 0 .../prometheus_client/prometheus_client.go | 2 +- .../prometheus_client_test.go | 2 +- {outputs => plugins/outputs}/registry.go | 0 .../outputs}/riemann/riemann.go | 2 +- .../outputs}/riemann/riemann_test.go | 0 scripts/circle-test.sh | 2 +- scripts/init.sh | 4 +- scripts/telegraf.service | 2 +- 175 files changed, 595 insertions(+), 561 deletions(-) delete mode 100644 outputs/all/all.go delete mode 100644 plugins/all/all.go rename plugins/{ => inputs}/aerospike/README.md (100%) rename plugins/{ => inputs}/aerospike/aerospike.go (96%) rename plugins/{ => inputs}/aerospike/aerospike_test.go (100%) create mode 100644 plugins/inputs/all/all.go rename plugins/{ => inputs}/apache/README.md (100%) rename plugins/{ => inputs}/apache/apache.go (93%) rename plugins/{ => inputs}/apache/apache_test.go (100%) rename plugins/{ => inputs}/bcache/README.md (97%) rename plugins/{ => inputs}/bcache/bcache.go (92%) rename plugins/{ => inputs}/bcache/bcache_test.go (100%) rename plugins/{ => inputs}/disque/disque.go (94%) rename plugins/{ => inputs}/disque/disque_test.go (100%) rename plugins/{ => inputs}/elasticsearch/README.md (100%) rename plugins/{ => inputs}/elasticsearch/elasticsearch.go (95%) rename plugins/{ => inputs}/elasticsearch/elasticsearch_test.go (100%) rename plugins/{ => inputs}/elasticsearch/testdata_test.go (100%) rename plugins/{ => inputs}/exec/README.md (100%) rename plugins/{ => inputs}/exec/exec.go (78%) rename plugins/{ => inputs}/exec/exec_test.go (93%) rename plugins/{ => inputs}/haproxy/haproxy.go (97%) rename plugins/{ => inputs}/haproxy/haproxy_test.go (100%) rename plugins/{ => inputs}/httpjson/README.md (100%) rename plugins/{ => inputs}/httpjson/httpjson.go (95%) rename plugins/{ => inputs}/httpjson/httpjson_test.go (100%) rename plugins/{ => inputs}/influxdb/README.md (98%) rename plugins/{ => inputs}/influxdb/influxdb.go (94%) rename plugins/{ => inputs}/influxdb/influxdb_test.go (97%) rename plugins/{ => inputs}/jolokia/README.md (100%) rename plugins/{ => inputs}/jolokia/jolokia.go (94%) rename plugins/{ => inputs}/jolokia/jolokia_test.go (100%) rename plugins/{ => inputs}/kafka_consumer/README.md (100%) rename plugins/{ => inputs}/kafka_consumer/kafka_consumer.go (96%) rename plugins/{ => inputs}/kafka_consumer/kafka_consumer_integration_test.go (100%) rename plugins/{ => inputs}/kafka_consumer/kafka_consumer_test.go (100%) rename plugins/{ => inputs}/leofs/leofs.go (96%) rename plugins/{ => inputs}/leofs/leofs_test.go (100%) rename plugins/{ => inputs}/lustre2/lustre2.go (96%) rename plugins/{ => inputs}/lustre2/lustre2_test.go (100%) rename plugins/{ => inputs}/mailchimp/chimp_api.go (100%) rename plugins/{ => inputs}/mailchimp/mailchimp.go (93%) rename plugins/{ => inputs}/mailchimp/mailchimp_test.go (100%) rename plugins/{ => inputs}/memcached/memcached.go (95%) rename plugins/{ => inputs}/memcached/memcached_test.go (100%) rename plugins/{ => inputs}/mock_Plugin.go (92%) rename plugins/{ => inputs}/mongodb/mongodb.go (93%) rename plugins/{ => inputs}/mongodb/mongodb_data.go (96%) rename plugins/{ => inputs}/mongodb/mongodb_data_test.go (100%) rename plugins/{ => inputs}/mongodb/mongodb_server.go (90%) rename plugins/{ => inputs}/mongodb/mongodb_server_test.go (100%) rename plugins/{ => inputs}/mongodb/mongodb_test.go (100%) rename plugins/{ => inputs}/mongodb/mongostat.go (100%) rename plugins/{ => inputs}/mysql/mysql.go (94%) rename plugins/{ => inputs}/mysql/mysql_test.go (100%) rename plugins/{ => inputs}/mysql/parse_dsn.go (100%) rename plugins/{ => inputs}/nginx/nginx.go (93%) rename plugins/{ => inputs}/nginx/nginx_test.go (100%) rename plugins/{ => inputs}/phpfpm/README.md (98%) rename plugins/{ => inputs}/phpfpm/phpfpm.go (94%) rename plugins/{ => inputs}/phpfpm/phpfpm_fcgi.go (100%) rename plugins/{ => inputs}/phpfpm/phpfpm_test.go (100%) rename plugins/{ => inputs}/ping/ping.go (96%) rename plugins/{ => inputs}/ping/ping_test.go (100%) rename plugins/{ => inputs}/postgresql/README.md (100%) rename plugins/{ => inputs}/postgresql/postgresql.go (93%) rename plugins/{ => inputs}/postgresql/postgresql_test.go (100%) rename plugins/{ => inputs}/procstat/README.md (100%) rename plugins/{ => inputs}/procstat/procstat.go (95%) rename plugins/{ => inputs}/procstat/procstat_test.go (100%) rename plugins/{ => inputs}/procstat/spec_processor.go (96%) rename plugins/{ => inputs}/prometheus/prometheus.go (89%) rename plugins/{ => inputs}/prometheus/prometheus_test.go (100%) rename plugins/{ => inputs}/puppetagent/README.md (100%) rename plugins/{ => inputs}/puppetagent/last_run_summary.yaml (100%) rename plugins/{ => inputs}/puppetagent/puppetagent.go (92%) rename plugins/{ => inputs}/puppetagent/puppetagent_test.go (100%) rename plugins/{ => inputs}/rabbitmq/rabbitmq.go (94%) rename plugins/{ => inputs}/rabbitmq/rabbitmq_test.go (100%) rename plugins/{ => inputs}/redis/redis.go (95%) rename plugins/{ => inputs}/redis/redis_test.go (100%) rename plugins/{ => inputs}/registry.go (64%) rename plugins/{ => inputs}/rethinkdb/rethinkdb.go (89%) rename plugins/{ => inputs}/rethinkdb/rethinkdb_data.go (95%) rename plugins/{ => inputs}/rethinkdb/rethinkdb_data_test.go (100%) rename plugins/{ => inputs}/rethinkdb/rethinkdb_server.go (94%) rename plugins/{ => inputs}/rethinkdb/rethinkdb_server_test.go (100%) rename plugins/{ => inputs}/rethinkdb/rethinkdb_test.go (100%) rename plugins/{ => inputs}/statsd/README.md (100%) rename plugins/{ => inputs}/statsd/running_stats.go (100%) rename plugins/{ => inputs}/statsd/running_stats_test.go (100%) rename plugins/{ => inputs}/statsd/statsd.go (98%) rename plugins/{ => inputs}/statsd/statsd_test.go (100%) rename plugins/{ => inputs}/system/CPU_README.md (100%) rename plugins/{ => inputs}/system/MEM_README.md (100%) rename plugins/{ => inputs}/system/NETSTAT_README.md (100%) rename plugins/{ => inputs}/system/cpu.go (95%) rename plugins/{ => inputs}/system/cpu_test.go (100%) rename plugins/{ => inputs}/system/disk.go (91%) rename plugins/{ => inputs}/system/disk_test.go (100%) rename plugins/{ => inputs}/system/docker.go (94%) rename plugins/{ => inputs}/system/docker_test.go (100%) rename plugins/{ => inputs}/system/memory.go (85%) rename plugins/{ => inputs}/system/memory_test.go (100%) rename plugins/{ => inputs}/system/mock_PS.go (100%) rename plugins/{ => inputs}/system/net.go (93%) rename plugins/{ => inputs}/system/net_test.go (100%) rename plugins/{ => inputs}/system/netstat.go (90%) rename plugins/{ => inputs}/system/ps.go (97%) rename plugins/{ => inputs}/system/system.go (88%) rename plugins/{ => inputs}/trig/trig.go (79%) rename plugins/{ => inputs}/trig/trig_test.go (100%) rename plugins/{ => inputs}/twemproxy/twemproxy.go (93%) rename plugins/{ => inputs}/twemproxy/twemproxy_test.go (100%) rename plugins/{ => inputs}/zfs/README.md (100%) rename plugins/{ => inputs}/zfs/zfs.go (93%) rename plugins/{ => inputs}/zfs/zfs_test.go (100%) rename plugins/{ => inputs}/zookeeper/README.md (100%) rename plugins/{ => inputs}/zookeeper/zookeeper.go (90%) rename plugins/{ => inputs}/zookeeper/zookeeper_test.go (100%) create mode 100644 plugins/outputs/all/all.go rename {outputs => plugins/outputs}/amon/README.md (100%) rename {outputs => plugins/outputs}/amon/amon.go (98%) rename {outputs => plugins/outputs}/amon/amon_test.go (100%) rename {outputs => plugins/outputs}/amqp/README.md (100%) rename {outputs => plugins/outputs}/amqp/amqp.go (98%) rename {outputs => plugins/outputs}/amqp/amqp_test.go (100%) rename {outputs => plugins/outputs}/datadog/README.md (100%) rename {outputs => plugins/outputs}/datadog/datadog.go (98%) rename {outputs => plugins/outputs}/datadog/datadog_test.go (100%) rename {outputs => plugins/outputs}/influxdb/README.md (100%) rename {outputs => plugins/outputs}/influxdb/influxdb.go (98%) rename {outputs => plugins/outputs}/influxdb/influxdb_test.go (100%) rename {outputs => plugins/outputs}/kafka/kafka.go (97%) rename {outputs => plugins/outputs}/kafka/kafka_test.go (100%) rename {outputs => plugins/outputs}/kinesis/README.md (100%) rename {outputs => plugins/outputs}/kinesis/kinesis.go (98%) rename {outputs => plugins/outputs}/kinesis/kinesis_test.go (100%) rename {outputs => plugins/outputs}/librato/README.md (100%) rename {outputs => plugins/outputs}/librato/librato.go (98%) rename {outputs => plugins/outputs}/librato/librato_test.go (100%) rename {outputs => plugins/outputs}/mqtt/mqtt.go (98%) rename {outputs => plugins/outputs}/mqtt/mqtt_test.go (100%) rename {outputs => plugins/outputs}/nsq/README.md (100%) rename {outputs => plugins/outputs}/nsq/nsq.go (96%) rename {outputs => plugins/outputs}/nsq/nsq_test.go (100%) rename {outputs => plugins/outputs}/opentsdb/README.md (100%) rename {outputs => plugins/outputs}/opentsdb/opentsdb.go (98%) rename {outputs => plugins/outputs}/opentsdb/opentsdb_test.go (100%) rename {outputs => plugins/outputs}/prometheus_client/README.md (100%) rename {outputs => plugins/outputs}/prometheus_client/prometheus_client.go (98%) rename {outputs => plugins/outputs}/prometheus_client/prometheus_client_test.go (97%) rename {outputs => plugins/outputs}/registry.go (100%) rename {outputs => plugins/outputs}/riemann/riemann.go (97%) rename {outputs => plugins/outputs}/riemann/riemann_test.go (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6d4383193a5d..d9856b5cfd5fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,17 @@ ## v0.3.0 [unreleased] ### Release Notes +- **breaking change** `plugins` have been renamed to `inputs`. This was done because +`plugins` is too generic, as there are now also "output plugins", and will likely +be "aggregator plugins" and "filter plugins" in the future. Additionally, +`inputs/` and `outputs/` directories have been placed in the root-level `plugins/` +directory. - **breaking change** the `io` plugin has been renamed `diskio` - **breaking change** Plugin measurements aggregated into a single measurement. - **breaking change** `jolokia` plugin: must use global tag/drop/pass parameters for configuration. -- **breaking change** `procstat` plugin has `*cpu*` fields renamed to -`*cpu_time*` -- `twemproxy` plugin: `prefix` option removed. -- `procstat` cpu measurements are now prepended with `cpu_time_` instead of +- **breaking change** `twemproxy` plugin: `prefix` option removed. +- **breaking change** `procstat` cpu measurements are now prepended with `cpu_time_` instead of only `cpu_` - The prometheus plugin schema has not been changed (measurements have not been aggregated). @@ -18,7 +21,7 @@ aggregated). - Added ability to specify per-plugin tags - Added ability to specify per-plugin measurement suffix and prefix. (`name_prefix` and `name_suffix`) -- Added ability to override base plugin name. (`name_override`) +- Added ability to override base plugin measurement name. (`name_override`) ### Bugfixes @@ -62,11 +65,11 @@ functional. same type can be specified, like this: ``` -[[plugins.cpu]] +[[inputs.cpu]] percpu = false totalcpu = true -[[plugins.cpu]] +[[inputs.cpu]] percpu = true totalcpu = false drop = ["cpu_time"] @@ -93,7 +96,7 @@ same type can be specified, like this: lists of servers/URLs. 0.2.2 is being released solely to fix that bug ### Bugfixes -- [#377](https://github.com/influxdb/telegraf/pull/377): Fix for duplicate slices in plugins. +- [#377](https://github.com/influxdb/telegraf/pull/377): Fix for duplicate slices in inputs. ## v0.2.1 [2015-11-16] @@ -154,7 +157,7 @@ be controlled via the `round_interval` and `flush_jitter` config options. - [#241](https://github.com/influxdb/telegraf/pull/241): MQTT Output. Thanks @shirou! - Memory plugin: cached and buffered measurements re-added - Logging: additional logging for each collection interval, track the number -of metrics collected and from how many plugins. +of metrics collected and from how many inputs. - [#240](https://github.com/influxdb/telegraf/pull/240): procstat plugin, thanks @ranjib! - [#244](https://github.com/influxdb/telegraf/pull/244): netstat plugin, thanks @shirou! - [#262](https://github.com/influxdb/telegraf/pull/262): zookeeper plugin, thanks @jrxFive! @@ -187,7 +190,7 @@ will still be backwards compatible if only `url` is specified. - The -test flag will now output two metric collections - Support for filtering telegraf outputs on the CLI -- Telegraf will now allow filtering of output sinks on the command-line using the `-outputfilter` -flag, much like how the `-filter` flag works for plugins. +flag, much like how the `-filter` flag works for inputs. - Support for filtering on config-file creation -- Telegraf now supports filtering to -sample-config command. You can now run `telegraf -sample-config -filter cpu -outputfilter influxdb` to get a config diff --git a/CONFIGURATION.md b/CONFIGURATION.md index c7b785edcc72f..fc822d4617b94 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -5,9 +5,9 @@ A default Telegraf config file can be generated using the `-sample-config` flag, like this: `telegraf -sample-config` -To generate a file with specific collectors and outputs, you can use the -`-filter` and `-outputfilter` flags, like this: -`telegraf -sample-config -filter cpu:mem:net:swap -outputfilter influxdb:kafka` +To generate a file with specific inputs and outputs, you can use the +`-input-filter` and `-output-filter` flags, like this: +`telegraf -sample-config -input-filter cpu:mem:net:swap -output-filter influxdb:kafka` ## Plugin Configuration @@ -59,7 +59,7 @@ fields which begin with `time_`. # PLUGINS [plugins] -[[plugins.cpu]] +[[inputs.cpu]] percpu = true totalcpu = false # filter all fields beginning with 'time_' @@ -70,16 +70,16 @@ fields which begin with `time_`. ```toml [plugins] -[[plugins.cpu]] +[[inputs.cpu]] percpu = true totalcpu = false drop = ["cpu_time"] # Don't collect CPU data for cpu6 & cpu7 - [plugins.cpu.tagdrop] + [inputs.cpu.tagdrop] cpu = [ "cpu6", "cpu7" ] -[[plugins.disk]] - [plugins.disk.tagpass] +[[inputs.disk]] + [inputs.disk.tagpass] # tagpass conditions are OR, not AND. # If the (filesystem is ext4 or xfs) OR (the path is /opt or /home) # then the metric passes @@ -92,13 +92,13 @@ fields which begin with `time_`. ```toml # Drop all metrics for guest & steal CPU usage -[[plugins.cpu]] +[[inputs.cpu]] percpu = false totalcpu = true drop = ["usage_guest", "usage_steal"] # Only store inode related metrics for disks -[[plugins.disk]] +[[inputs.disk]] pass = ["inodes*"] ``` @@ -107,7 +107,7 @@ fields which begin with `time_`. This plugin will emit measurements with the name `cpu_total` ```toml -[[plugins.cpu]] +[[inputs.cpu]] name_suffix = "_total" percpu = false totalcpu = true @@ -116,7 +116,7 @@ This plugin will emit measurements with the name `cpu_total` This will emit measurements with the name `foobar` ```toml -[[plugins.cpu]] +[[inputs.cpu]] name_override = "foobar" percpu = false totalcpu = true @@ -128,10 +128,10 @@ This plugin will emit measurements with two additional tags: `tag1=foo` and `tag2=bar` ```toml -[[plugins.cpu]] +[[inputs.cpu]] percpu = false totalcpu = true - [plugins.cpu.tags] + [inputs.cpu.tags] tag1 = "foo" tag2 = "bar" ``` @@ -142,11 +142,11 @@ Additional plugins (or outputs) of the same type can be specified, just define more instances in the config file: ```toml -[[plugins.cpu]] +[[inputs.cpu]] percpu = false totalcpu = true -[[plugins.cpu]] +[[inputs.cpu]] percpu = true totalcpu = false drop = ["cpu_time*"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7723f06050348..12dcad1d09bc9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,23 +5,23 @@ which can be found [on our website](http://influxdb.com/community/cla.html) ## Plugins -This section is for developers who want to create new collection plugins. +This section is for developers who want to create new collection inputs. Telegraf is entirely plugin driven. This interface allows for operators to pick and chose what is gathered as well as makes it easy for developers to create new ways of generating metrics. Plugin authorship is kept as simple as possible to promote people to develop -and submit new plugins. +and submit new inputs. ### Plugin Guidelines -* A plugin must conform to the `plugins.Plugin` interface. +* A plugin must conform to the `inputs.Input` interface. * Each generated metric automatically has the name of the plugin that generated it prepended. This is to keep plugins honest. -* Plugins should call `plugins.Add` in their `init` function to register themselves. +* Plugins should call `inputs.Add` in their `init` function to register themselves. See below for a quick example. * To be available within Telegraf itself, plugins must add themselves to the -`github.com/influxdb/telegraf/plugins/all/all.go` file. +`github.com/influxdb/telegraf/plugins/inputs/all/all.go` file. * The `SampleConfig` function should return valid toml that describes how the plugin can be configured. This is include in `telegraf -sample-config`. * The `Description` function should say in one line what this plugin does. @@ -78,7 +78,7 @@ type Process struct { PID int } -func Gather(acc plugins.Accumulator) error { +func Gather(acc inputs.Accumulator) error { for _, process := range system.Processes() { tags := map[string]string { "pid": fmt.Sprintf("%d", process.Pid), @@ -97,7 +97,7 @@ package simple // simple.go -import "github.com/influxdb/telegraf/plugins" +import "github.com/influxdb/telegraf/plugins/inputs" type Simple struct { Ok bool @@ -111,7 +111,7 @@ func (s *Simple) SampleConfig() string { return "ok = true # indicate if everything is fine" } -func (s *Simple) Gather(acc plugins.Accumulator) error { +func (s *Simple) Gather(acc inputs.Accumulator) error { if s.Ok { acc.Add("state", "pretty good", nil) } else { @@ -122,14 +122,14 @@ func (s *Simple) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("simple", func() plugins.Plugin { return &Simple{} }) + inputs.Add("simple", func() inputs.Input { return &Simple{} }) } ``` ## Service Plugins This section is for developers who want to create new "service" collection -plugins. A service plugin differs from a regular plugin in that it operates +inputs. A service plugin differs from a regular plugin in that it operates a background service while Telegraf is running. One example would be the `statsd` plugin, which operates a statsd server. @@ -143,7 +143,7 @@ and `Stop()` methods. ### Service Plugin Guidelines * Same as the `Plugin` guidelines, except that they must conform to the -`plugins.ServicePlugin` interface. +`inputs.ServiceInput` interface. ### Service Plugin interface @@ -169,7 +169,7 @@ similar constructs. * Outputs should call `outputs.Add` in their `init` function to register themselves. See below for a quick example. * To be available within Telegraf itself, plugins must add themselves to the -`github.com/influxdb/telegraf/outputs/all/all.go` file. +`github.com/influxdb/telegraf/plugins/outputs/all/all.go` file. * The `SampleConfig` function should return valid toml that describes how the output can be configured. This is include in `telegraf -sample-config`. * The `Description` function should say in one line what this output does. @@ -193,7 +193,7 @@ package simpleoutput // simpleoutput.go -import "github.com/influxdb/telegraf/outputs" +import "github.com/influxdb/telegraf/plugins/outputs" type Simple struct { Ok bool @@ -243,7 +243,7 @@ and `Stop()` methods. ### Service Output Guidelines * Same as the `Output` guidelines, except that they must conform to the -`plugins.ServiceOutput` interface. +`inputs.ServiceOutput` interface. ### Service Output interface diff --git a/README.md b/README.md index aefcece44a37a..46f865951cb44 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ APIs (like Mailchimp, AWS CloudWatch, or Google Analytics). We'll eagerly accept pull requests for new plugins and will manage the set of plugins that Telegraf supports. See the [contributing guide](CONTRIBUTING.md) for instructions on -writing new plugins. +writing new inputs. ## Installation: @@ -92,7 +92,7 @@ if you don't have it already. You also must build with golang version 1.4+. ### How to use it: * Run `telegraf -sample-config > telegraf.conf` to create an initial configuration. -* Or run `telegraf -sample-config -filter cpu:mem -outputfilter influxdb > telegraf.conf`. +* Or run `telegraf -sample-config -input-filter cpu:mem -output-filter influxdb > telegraf.conf`. to create a config file with only CPU and memory plugins defined, and InfluxDB output defined. * Edit the configuration to match your needs. @@ -100,7 +100,7 @@ output defined. sample to STDOUT. NOTE: you may want to run as the telegraf user if you are using the linux packages `sudo -u telegraf telegraf -config telegraf.conf -test` * Run `telegraf -config telegraf.conf` to gather and send metrics to configured outputs. -* Run `telegraf -config telegraf.conf -filter system:swap`. +* Run `telegraf -config telegraf.conf -input-filter system:swap`. to run telegraf with only the system & swap plugins defined in the config. ## Telegraf Options diff --git a/accumulator.go b/accumulator.go index f14df63f74030..429f3a42cf8f6 100644 --- a/accumulator.go +++ b/accumulator.go @@ -29,12 +29,12 @@ type Accumulator interface { } func NewAccumulator( - pluginConfig *config.PluginConfig, + inputConfig *config.InputConfig, points chan *client.Point, ) Accumulator { acc := accumulator{} acc.points = points - acc.pluginConfig = pluginConfig + acc.inputConfig = inputConfig return &acc } @@ -47,7 +47,7 @@ type accumulator struct { debug bool - pluginConfig *config.PluginConfig + inputConfig *config.InputConfig prefix string } @@ -73,27 +73,27 @@ func (ac *accumulator) AddFields( return } - if !ac.pluginConfig.Filter.ShouldTagsPass(tags) { + if !ac.inputConfig.Filter.ShouldTagsPass(tags) { return } // Override measurement name if set - if len(ac.pluginConfig.NameOverride) != 0 { - measurement = ac.pluginConfig.NameOverride + if len(ac.inputConfig.NameOverride) != 0 { + measurement = ac.inputConfig.NameOverride } // Apply measurement prefix and suffix if set - if len(ac.pluginConfig.MeasurementPrefix) != 0 { - measurement = ac.pluginConfig.MeasurementPrefix + measurement + if len(ac.inputConfig.MeasurementPrefix) != 0 { + measurement = ac.inputConfig.MeasurementPrefix + measurement } - if len(ac.pluginConfig.MeasurementSuffix) != 0 { - measurement = measurement + ac.pluginConfig.MeasurementSuffix + if len(ac.inputConfig.MeasurementSuffix) != 0 { + measurement = measurement + ac.inputConfig.MeasurementSuffix } if tags == nil { tags = make(map[string]string) } // Apply plugin-wide tags if set - for k, v := range ac.pluginConfig.Tags { + for k, v := range ac.inputConfig.Tags { if _, ok := tags[k]; !ok { tags[k] = v } @@ -108,8 +108,8 @@ func (ac *accumulator) AddFields( result := make(map[string]interface{}) for k, v := range fields { // Filter out any filtered fields - if ac.pluginConfig != nil { - if !ac.pluginConfig.Filter.ShouldPass(k) { + if ac.inputConfig != nil { + if !ac.inputConfig.Filter.ShouldPass(k) { continue } } diff --git a/agent.go b/agent.go index 1658027a72e58..1af2a1f7cc9c7 100644 --- a/agent.go +++ b/agent.go @@ -10,8 +10,8 @@ import ( "time" "github.com/influxdb/telegraf/internal/config" - "github.com/influxdb/telegraf/outputs" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" + "github.com/influxdb/telegraf/plugins/outputs" "github.com/influxdb/influxdb/client/v2" ) @@ -85,33 +85,33 @@ func (a *Agent) Close() error { return err } -// gatherParallel runs the plugins that are using the same reporting interval +// gatherParallel runs the inputs that are using the same reporting interval // as the telegraf agent. func (a *Agent) gatherParallel(pointChan chan *client.Point) error { var wg sync.WaitGroup start := time.Now() counter := 0 - for _, plugin := range a.Config.Plugins { - if plugin.Config.Interval != 0 { + for _, input := range a.Config.Inputs { + if input.Config.Interval != 0 { continue } wg.Add(1) counter++ - go func(plugin *config.RunningPlugin) { + go func(input *config.RunningInput) { defer wg.Done() - acc := NewAccumulator(plugin.Config, pointChan) + acc := NewAccumulator(input.Config, pointChan) acc.SetDebug(a.Config.Agent.Debug) - // acc.SetPrefix(plugin.Name + "_") + // acc.SetPrefix(input.Name + "_") acc.SetDefaultTags(a.Config.Tags) - if err := plugin.Plugin.Gather(acc); err != nil { - log.Printf("Error in plugin [%s]: %s", plugin.Name, err) + if err := input.Input.Gather(acc); err != nil { + log.Printf("Error in input [%s]: %s", input.Name, err) } - }(plugin) + }(input) } if counter == 0 { @@ -121,36 +121,36 @@ func (a *Agent) gatherParallel(pointChan chan *client.Point) error { wg.Wait() elapsed := time.Since(start) - log.Printf("Gathered metrics, (%s interval), from %d plugins in %s\n", - a.Config.Agent.Interval, counter, elapsed) + log.Printf("Gathered metrics, (%s interval), from %d inputs in %s\n", + a.Config.Agent.Interval.Duration, counter, elapsed) return nil } -// gatherSeparate runs the plugins that have been configured with their own +// gatherSeparate runs the inputs that have been configured with their own // reporting interval. func (a *Agent) gatherSeparate( shutdown chan struct{}, - plugin *config.RunningPlugin, + input *config.RunningInput, pointChan chan *client.Point, ) error { - ticker := time.NewTicker(plugin.Config.Interval) + ticker := time.NewTicker(input.Config.Interval) for { var outerr error start := time.Now() - acc := NewAccumulator(plugin.Config, pointChan) + acc := NewAccumulator(input.Config, pointChan) acc.SetDebug(a.Config.Agent.Debug) - // acc.SetPrefix(plugin.Name + "_") + // acc.SetPrefix(input.Name + "_") acc.SetDefaultTags(a.Config.Tags) - if err := plugin.Plugin.Gather(acc); err != nil { - log.Printf("Error in plugin [%s]: %s", plugin.Name, err) + if err := input.Input.Gather(acc); err != nil { + log.Printf("Error in input [%s]: %s", input.Name, err) } elapsed := time.Since(start) log.Printf("Gathered metrics, (separate %s interval), from %s in %s\n", - plugin.Config.Interval, plugin.Name, elapsed) + input.Config.Interval, input.Name, elapsed) if outerr != nil { return outerr @@ -165,7 +165,7 @@ func (a *Agent) gatherSeparate( } } -// Test verifies that we can 'Gather' from all plugins with their configured +// Test verifies that we can 'Gather' from all inputs with their configured // Config struct func (a *Agent) Test() error { shutdown := make(chan struct{}) @@ -184,27 +184,27 @@ func (a *Agent) Test() error { } }() - for _, plugin := range a.Config.Plugins { - acc := NewAccumulator(plugin.Config, pointChan) + for _, input := range a.Config.Inputs { + acc := NewAccumulator(input.Config, pointChan) acc.SetDebug(true) - // acc.SetPrefix(plugin.Name + "_") + // acc.SetPrefix(input.Name + "_") - fmt.Printf("* Plugin: %s, Collection 1\n", plugin.Name) - if plugin.Config.Interval != 0 { - fmt.Printf("* Internal: %s\n", plugin.Config.Interval) + fmt.Printf("* Plugin: %s, Collection 1\n", input.Name) + if input.Config.Interval != 0 { + fmt.Printf("* Internal: %s\n", input.Config.Interval) } - if err := plugin.Plugin.Gather(acc); err != nil { + if err := input.Input.Gather(acc); err != nil { return err } - // Special instructions for some plugins. cpu, for example, needs to be + // Special instructions for some inputs. cpu, for example, needs to be // run twice in order to return cpu usage percentages. - switch plugin.Name { + switch input.Name { case "cpu", "mongodb": time.Sleep(500 * time.Millisecond) - fmt.Printf("* Plugin: %s, Collection 2\n", plugin.Name) - if err := plugin.Plugin.Gather(acc); err != nil { + fmt.Printf("* Plugin: %s, Collection 2\n", input.Name) + if err := input.Input.Gather(acc); err != nil { return err } } @@ -332,10 +332,10 @@ func (a *Agent) Run(shutdown chan struct{}) error { log.Printf("Agent Config: Interval:%s, Debug:%#v, Hostname:%#v, "+ "Flush Interval:%s\n", - a.Config.Agent.Interval, a.Config.Agent.Debug, - a.Config.Agent.Hostname, a.Config.Agent.FlushInterval) + a.Config.Agent.Interval.Duration, a.Config.Agent.Debug, + a.Config.Agent.Hostname, a.Config.Agent.FlushInterval.Duration) - // channel shared between all plugin threads for accumulating points + // channel shared between all input threads for accumulating points pointChan := make(chan *client.Point, 1000) // Round collection to nearest interval by sleeping @@ -354,29 +354,29 @@ func (a *Agent) Run(shutdown chan struct{}) error { } }() - for _, plugin := range a.Config.Plugins { + for _, input := range a.Config.Inputs { // Start service of any ServicePlugins - switch p := plugin.Plugin.(type) { - case plugins.ServicePlugin: + switch p := input.Input.(type) { + case inputs.ServiceInput: if err := p.Start(); err != nil { - log.Printf("Service for plugin %s failed to start, exiting\n%s\n", - plugin.Name, err.Error()) + log.Printf("Service for input %s failed to start, exiting\n%s\n", + input.Name, err.Error()) return err } defer p.Stop() } - // Special handling for plugins that have their own collection interval + // Special handling for inputs that have their own collection interval // configured. Default intervals are handled below with gatherParallel - if plugin.Config.Interval != 0 { + if input.Config.Interval != 0 { wg.Add(1) - go func(plugin *config.RunningPlugin) { + go func(input *config.RunningInput) { defer wg.Done() - if err := a.gatherSeparate(shutdown, plugin, pointChan); err != nil { + if err := a.gatherSeparate(shutdown, input, pointChan); err != nil { log.Printf(err.Error()) } - }(plugin) + }(input) } } diff --git a/agent_test.go b/agent_test.go index c08fbe292b9fc..1cb020c7bef5d 100644 --- a/agent_test.go +++ b/agent_test.go @@ -8,46 +8,46 @@ import ( "github.com/influxdb/telegraf/internal/config" // needing to load the plugins - _ "github.com/influxdb/telegraf/plugins/all" + _ "github.com/influxdb/telegraf/plugins/inputs/all" // needing to load the outputs - _ "github.com/influxdb/telegraf/outputs/all" + _ "github.com/influxdb/telegraf/plugins/outputs/all" ) func TestAgent_LoadPlugin(t *testing.T) { c := config.NewConfig() - c.PluginFilters = []string{"mysql"} + c.InputFilters = []string{"mysql"} err := c.LoadConfig("./internal/config/testdata/telegraf-agent.toml") assert.NoError(t, err) a, _ := NewAgent(c) - assert.Equal(t, 1, len(a.Config.Plugins)) + assert.Equal(t, 1, len(a.Config.Inputs)) c = config.NewConfig() - c.PluginFilters = []string{"foo"} + c.InputFilters = []string{"foo"} err = c.LoadConfig("./internal/config/testdata/telegraf-agent.toml") assert.NoError(t, err) a, _ = NewAgent(c) - assert.Equal(t, 0, len(a.Config.Plugins)) + assert.Equal(t, 0, len(a.Config.Inputs)) c = config.NewConfig() - c.PluginFilters = []string{"mysql", "foo"} + c.InputFilters = []string{"mysql", "foo"} err = c.LoadConfig("./internal/config/testdata/telegraf-agent.toml") assert.NoError(t, err) a, _ = NewAgent(c) - assert.Equal(t, 1, len(a.Config.Plugins)) + assert.Equal(t, 1, len(a.Config.Inputs)) c = config.NewConfig() - c.PluginFilters = []string{"mysql", "redis"} + c.InputFilters = []string{"mysql", "redis"} err = c.LoadConfig("./internal/config/testdata/telegraf-agent.toml") assert.NoError(t, err) a, _ = NewAgent(c) - assert.Equal(t, 2, len(a.Config.Plugins)) + assert.Equal(t, 2, len(a.Config.Inputs)) c = config.NewConfig() - c.PluginFilters = []string{"mysql", "foo", "redis", "bar"} + c.InputFilters = []string{"mysql", "foo", "redis", "bar"} err = c.LoadConfig("./internal/config/testdata/telegraf-agent.toml") assert.NoError(t, err) a, _ = NewAgent(c) - assert.Equal(t, 2, len(a.Config.Plugins)) + assert.Equal(t, 2, len(a.Config.Inputs)) } func TestAgent_LoadOutput(t *testing.T) { diff --git a/circle.yml b/circle.yml index 2d006d70ec56e..d86d46dbae762 100644 --- a/circle.yml +++ b/circle.yml @@ -10,8 +10,6 @@ machine: - go version dependencies: - cache_directories: - - "~/telegraf-build/src" override: - docker info diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index 8f9a628f91346..cc54dbc888986 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -10,23 +10,23 @@ import ( "github.com/influxdb/telegraf" "github.com/influxdb/telegraf/internal/config" - _ "github.com/influxdb/telegraf/outputs/all" - _ "github.com/influxdb/telegraf/plugins/all" + _ "github.com/influxdb/telegraf/plugins/inputs/all" + _ "github.com/influxdb/telegraf/plugins/outputs/all" ) var fDebug = flag.Bool("debug", false, "show metrics as they're generated to stdout") var fTest = flag.Bool("test", false, "gather metrics, print them out, and exit") var fConfig = flag.String("config", "", "configuration file to load") -var fConfigDirectory = flag.String("configdirectory", "", +var fConfigDirectory = flag.String("config-directory", "", "directory containing additional *.conf files") var fVersion = flag.Bool("version", false, "display the version") var fSampleConfig = flag.Bool("sample-config", false, "print out full sample configuration") var fPidfile = flag.String("pidfile", "", "file to write our pid to") -var fPLuginFilters = flag.String("filter", "", +var fInputFilters = flag.String("input-filter", "", "filter the plugins to enable, separator is :") -var fOutputFilters = flag.String("outputfilter", "", +var fOutputFilters = flag.String("output-filter", "", "filter the outputs to enable, separator is :") var fUsage = flag.String("usage", "", "print usage for a plugin, ie, 'telegraf -usage mysql'") @@ -35,13 +35,53 @@ var fUsage = flag.String("usage", "", // -ldflags "-X main.Version=`git describe --always --tags`" var Version string +const usage = `Telegraf, The plugin-driven server agent for reporting metrics into InfluxDB + +Usage: + + telegraf + +The flags are: + + -config configuration file to load + -test gather metrics once, print them to stdout, and exit + -sample-config print out full sample configuration to stdout + -config-directory directory containing additional *.conf files + -input-filter filter the input plugins to enable, separator is : + -output-filter filter the output plugins to enable, separator is : + -usage print usage for a plugin, ie, 'telegraf -usage mysql' + -version print the version to stdout + +Examples: + + # generate a telegraf config file: + telegraf -sample-config > telegraf.conf + + # generate a telegraf config file with only cpu input and influxdb output enabled + telegraf -sample-config -input-filter cpu -output-filter influxdb + + # run a single telegraf collection, outputting metrics to stdout + telegraf -config telegraf.conf -test + + # run telegraf with all plugins defined in config file + telegraf -config telegraf.conf + + # run telegraf, enabling only the cpu and memory inputs and influxdb output + telegraf -config telegraf.conf -input-filter cpu:mem -output-filter influxdb +` + func main() { + flag.Usage = usageExit flag.Parse() - var pluginFilters []string - if *fPLuginFilters != "" { - pluginsFilter := strings.TrimSpace(*fPLuginFilters) - pluginFilters = strings.Split(":"+pluginsFilter+":", ":") + if flag.NFlag() == 0 { + usageExit() + } + + var inputFilters []string + if *fInputFilters != "" { + inputFilter := strings.TrimSpace(*fInputFilters) + inputFilters = strings.Split(":"+inputFilter+":", ":") } var outputFilters []string @@ -57,12 +97,12 @@ func main() { } if *fSampleConfig { - config.PrintSampleConfig(pluginFilters, outputFilters) + config.PrintSampleConfig(inputFilters, outputFilters) return } if *fUsage != "" { - if err := config.PrintPluginConfig(*fUsage); err != nil { + if err := config.PrintInputConfig(*fUsage); err != nil { if err2 := config.PrintOutputConfig(*fUsage); err2 != nil { log.Fatalf("%s and %s", err, err2) } @@ -78,7 +118,7 @@ func main() { if *fConfig != "" { c = config.NewConfig() c.OutputFilters = outputFilters - c.PluginFilters = pluginFilters + c.InputFilters = inputFilters err = c.LoadConfig(*fConfig) if err != nil { log.Fatal(err) @@ -98,7 +138,7 @@ func main() { if len(c.Outputs) == 0 { log.Fatalf("Error: no outputs found, did you provide a valid config file?") } - if len(c.Plugins) == 0 { + if len(c.Inputs) == 0 { log.Fatalf("Error: no plugins found, did you provide a valid config file?") } @@ -134,7 +174,7 @@ func main() { log.Printf("Starting Telegraf (version %s)\n", Version) log.Printf("Loaded outputs: %s", strings.Join(c.OutputNames(), " ")) - log.Printf("Loaded plugins: %s", strings.Join(c.PluginNames(), " ")) + log.Printf("Loaded plugins: %s", strings.Join(c.InputNames(), " ")) log.Printf("Tags enabled: %s", c.ListTags()) if *fPidfile != "" { @@ -150,3 +190,8 @@ func main() { ag.Run(shutdown) } + +func usageExit() { + fmt.Println(usage) + os.Exit(0) +} diff --git a/etc/telegraf.conf b/etc/telegraf.conf index 9460cef25646f..eb50005a520e3 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -1,7 +1,7 @@ # Telegraf configuration # Telegraf is entirely plugin driven. All metrics are gathered from the -# declared plugins. +# declared inputs. # Even if a plugin has no configuration, it must be declared in here # to be active. Declaring a plugin means just specifying the name @@ -76,13 +76,13 @@ ############################################################################### -# PLUGINS # +# INPUTS # ############################################################################### -[plugins] +[inputs] # Read metrics about cpu usage -[[plugins.cpu]] +[[inputs.cpu]] # Whether to report per-cpu stats or not percpu = true # Whether to report total system cpu stats or not @@ -91,13 +91,13 @@ drop = ["cpu_time"] # Read metrics about disk usage by mount point -[[plugins.disk]] +[[inputs.disk]] # By default, telegraf gather stats for all mountpoints. # Setting mountpoints will restrict the stats to the specified mountpoints. # Mountpoints=["/"] # Read metrics about disk IO by device -[[plugins.diskio]] +[[inputs.diskio]] # By default, telegraf will gather stats for all devices including # disk partitions. # Setting devices will restrict the stats to the specified devices. @@ -106,18 +106,18 @@ # SkipSerialNumber = true # Read metrics about memory usage -[[plugins.mem]] +[[inputs.mem]] # no configuration # Read metrics about swap memory usage -[[plugins.swap]] +[[inputs.swap]] # no configuration # Read metrics about system load & uptime -[[plugins.system]] +[[inputs.system]] # no configuration ############################################################################### -# SERVICE PLUGINS # +# SERVICE INPUTS # ############################################################################### diff --git a/internal/config/config.go b/internal/config/config.go index 9275fa177e1b0..e96856015c1f8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,8 +11,8 @@ import ( "time" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/outputs" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" + "github.com/influxdb/telegraf/plugins/outputs" "github.com/naoina/toml" "github.com/naoina/toml/ast" @@ -25,11 +25,11 @@ import ( // specified type Config struct { Tags map[string]string - PluginFilters []string + InputFilters []string OutputFilters []string Agent *AgentConfig - Plugins []*RunningPlugin + Inputs []*RunningInput Outputs []*RunningOutput } @@ -45,9 +45,9 @@ func NewConfig() *Config { }, Tags: make(map[string]string), - Plugins: make([]*RunningPlugin, 0), + Inputs: make([]*RunningInput, 0), Outputs: make([]*RunningOutput, 0), - PluginFilters: make([]string, 0), + InputFilters: make([]string, 0), OutputFilters: make([]string, 0), } return c @@ -93,10 +93,10 @@ type RunningOutput struct { Config *OutputConfig } -type RunningPlugin struct { +type RunningInput struct { Name string - Plugin plugins.Plugin - Config *PluginConfig + Input inputs.Input + Config *InputConfig } // Filter containing drop/pass and tagdrop/tagpass rules @@ -110,8 +110,8 @@ type Filter struct { IsActive bool } -// PluginConfig containing a name, interval, and filter -type PluginConfig struct { +// InputConfig containing a name, interval, and filter +type InputConfig struct { Name string NameOverride string MeasurementPrefix string @@ -204,16 +204,16 @@ func (f Filter) ShouldTagsPass(tags map[string]string) bool { return true } -// Plugins returns a list of strings of the configured plugins. -func (c *Config) PluginNames() []string { +// Inputs returns a list of strings of the configured inputs. +func (c *Config) InputNames() []string { var name []string - for _, plugin := range c.Plugins { - name = append(name, plugin.Name) + for _, input := range c.Inputs { + name = append(name, input.Name) } return name } -// Outputs returns a list of strings of the configured plugins. +// Outputs returns a list of strings of the configured inputs. func (c *Config) OutputNames() []string { var name []string for _, output := range c.Outputs { @@ -239,7 +239,7 @@ func (c *Config) ListTags() string { var header = `# Telegraf configuration # Telegraf is entirely plugin driven. All metrics are gathered from the -# declared plugins. +# declared inputs. # Even if a plugin has no configuration, it must be declared in here # to be active. Declaring a plugin means just specifying the name @@ -263,7 +263,7 @@ var header = `# Telegraf configuration # Configuration for telegraf agent [agent] - # Default data collection interval for all plugins + # Default data collection interval for all inputs interval = "10s" # Rounds collection interval to 'interval' # ie, if interval="10s" then always collect on :00, :10, :20, etc. @@ -293,16 +293,16 @@ var header = `# Telegraf configuration var pluginHeader = ` ############################################################################### -# PLUGINS # +# INPUTS # ############################################################################### -[plugins] +[inputs] ` -var servicePluginHeader = ` +var serviceInputHeader = ` ############################################################################### -# SERVICE PLUGINS # +# SERVICE INPUTS # ############################################################################### ` @@ -326,35 +326,35 @@ func PrintSampleConfig(pluginFilters []string, outputFilters []string) { printConfig(oname, output, "outputs") } - // Filter plugins + // Filter inputs var pnames []string - for pname := range plugins.Plugins { + for pname := range inputs.Inputs { if len(pluginFilters) == 0 || sliceContains(pname, pluginFilters) { pnames = append(pnames, pname) } } sort.Strings(pnames) - // Print Plugins + // Print Inputs fmt.Printf(pluginHeader) - servPlugins := make(map[string]plugins.ServicePlugin) + servInputs := make(map[string]inputs.ServiceInput) for _, pname := range pnames { - creator := plugins.Plugins[pname] - plugin := creator() + creator := inputs.Inputs[pname] + input := creator() - switch p := plugin.(type) { - case plugins.ServicePlugin: - servPlugins[pname] = p + switch p := input.(type) { + case inputs.ServiceInput: + servInputs[pname] = p continue } - printConfig(pname, plugin, "plugins") + printConfig(pname, input, "inputs") } - // Print Service Plugins - fmt.Printf(servicePluginHeader) - for name, plugin := range servPlugins { - printConfig(name, plugin, "plugins") + // Print Service Inputs + fmt.Printf(serviceInputHeader) + for name, input := range servInputs { + printConfig(name, input, "inputs") } } @@ -382,12 +382,12 @@ func sliceContains(name string, list []string) bool { return false } -// PrintPluginConfig prints the config usage of a single plugin. -func PrintPluginConfig(name string) error { - if creator, ok := plugins.Plugins[name]; ok { - printConfig(name, creator(), "plugins") +// PrintInputConfig prints the config usage of a single input. +func PrintInputConfig(name string) error { + if creator, ok := inputs.Inputs[name]; ok { + printConfig(name, creator(), "inputs") } else { - return errors.New(fmt.Sprintf("Plugin %s not found", name)) + return errors.New(fmt.Sprintf("Input %s not found", name)) } return nil } @@ -453,33 +453,33 @@ func (c *Config) LoadConfig(path string) error { return err } case "outputs": - for outputName, outputVal := range subTable.Fields { - switch outputSubTable := outputVal.(type) { + for pluginName, pluginVal := range subTable.Fields { + switch pluginSubTable := pluginVal.(type) { case *ast.Table: - if err = c.addOutput(outputName, outputSubTable); err != nil { + if err = c.addOutput(pluginName, pluginSubTable); err != nil { return err } case []*ast.Table: - for _, t := range outputSubTable { - if err = c.addOutput(outputName, t); err != nil { + for _, t := range pluginSubTable { + if err = c.addOutput(pluginName, t); err != nil { return err } } default: return fmt.Errorf("Unsupported config format: %s", - outputName) + pluginName) } } - case "plugins": + case "inputs": for pluginName, pluginVal := range subTable.Fields { switch pluginSubTable := pluginVal.(type) { case *ast.Table: - if err = c.addPlugin(pluginName, pluginSubTable); err != nil { + if err = c.addInput(pluginName, pluginSubTable); err != nil { return err } case []*ast.Table: for _, t := range pluginSubTable { - if err = c.addPlugin(pluginName, t); err != nil { + if err = c.addInput(pluginName, t); err != nil { return err } } @@ -488,10 +488,10 @@ func (c *Config) LoadConfig(path string) error { pluginName) } } - // Assume it's a plugin for legacy config file support if no other + // Assume it's an input input for legacy config file support if no other // identifiers are present default: - if err = c.addPlugin(name, subTable); err != nil { + if err = c.addInput(name, subTable); err != nil { return err } } @@ -527,41 +527,41 @@ func (c *Config) addOutput(name string, table *ast.Table) error { return nil } -func (c *Config) addPlugin(name string, table *ast.Table) error { - if len(c.PluginFilters) > 0 && !sliceContains(name, c.PluginFilters) { +func (c *Config) addInput(name string, table *ast.Table) error { + if len(c.InputFilters) > 0 && !sliceContains(name, c.InputFilters) { return nil } - // Legacy support renaming io plugin to diskio + // Legacy support renaming io input to diskio if name == "io" { name = "diskio" } - creator, ok := plugins.Plugins[name] + creator, ok := inputs.Inputs[name] if !ok { - return fmt.Errorf("Undefined but requested plugin: %s", name) + return fmt.Errorf("Undefined but requested input: %s", name) } - plugin := creator() + input := creator() - pluginConfig, err := buildPlugin(name, table) + pluginConfig, err := buildInput(name, table) if err != nil { return err } - if err := toml.UnmarshalTable(table, plugin); err != nil { + if err := toml.UnmarshalTable(table, input); err != nil { return err } - rp := &RunningPlugin{ + rp := &RunningInput{ Name: name, - Plugin: plugin, + Input: input, Config: pluginConfig, } - c.Plugins = append(c.Plugins, rp) + c.Inputs = append(c.Inputs, rp) return nil } // buildFilter builds a Filter (tagpass/tagdrop/pass/drop) to -// be inserted into the OutputConfig/PluginConfig to be used for prefix +// be inserted into the OutputConfig/InputConfig to be used for prefix // filtering on tags and measurements func buildFilter(tbl *ast.Table) Filter { f := Filter{} @@ -637,11 +637,11 @@ func buildFilter(tbl *ast.Table) Filter { return f } -// buildPlugin parses plugin specific items from the ast.Table, +// buildInput parses input specific items from the ast.Table, // builds the filter and returns a -// PluginConfig to be inserted into RunningPlugin -func buildPlugin(name string, tbl *ast.Table) (*PluginConfig, error) { - cp := &PluginConfig{Name: name} +// InputConfig to be inserted into RunningInput +func buildInput(name string, tbl *ast.Table) (*InputConfig, error) { + cp := &InputConfig{Name: name} if node, ok := tbl.Fields["interval"]; ok { if kv, ok := node.(*ast.KeyValue); ok { if str, ok := kv.Value.(*ast.String); ok { @@ -683,7 +683,7 @@ func buildPlugin(name string, tbl *ast.Table) (*PluginConfig, error) { if node, ok := tbl.Fields["tags"]; ok { if subtbl, ok := node.(*ast.Table); ok { if err := toml.UnmarshalTable(subtbl, cp.Tags); err != nil { - log.Printf("Could not parse tags for plugin %s\n", name) + log.Printf("Could not parse tags for input %s\n", name) } } } @@ -698,7 +698,7 @@ func buildPlugin(name string, tbl *ast.Table) (*PluginConfig, error) { } // buildOutput parses output specific items from the ast.Table, builds the filter and returns an -// OutputConfig to be inserted into RunningPlugin +// OutputConfig to be inserted into RunningInput // Note: error exists in the return for future calls that might require error func buildOutput(name string, tbl *ast.Table) (*OutputConfig, error) { oc := &OutputConfig{ diff --git a/internal/config/config_test.go b/internal/config/config_test.go index eeb1f7faec030..c8ed79bdf1212 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -4,21 +4,21 @@ import ( "testing" "time" - "github.com/influxdb/telegraf/plugins" - "github.com/influxdb/telegraf/plugins/exec" - "github.com/influxdb/telegraf/plugins/memcached" - "github.com/influxdb/telegraf/plugins/procstat" + "github.com/influxdb/telegraf/plugins/inputs" + "github.com/influxdb/telegraf/plugins/inputs/exec" + "github.com/influxdb/telegraf/plugins/inputs/memcached" + "github.com/influxdb/telegraf/plugins/inputs/procstat" "github.com/stretchr/testify/assert" ) -func TestConfig_LoadSinglePlugin(t *testing.T) { +func TestConfig_LoadSingleInput(t *testing.T) { c := NewConfig() c.LoadConfig("./testdata/single_plugin.toml") - memcached := plugins.Plugins["memcached"]().(*memcached.Memcached) + memcached := inputs.Inputs["memcached"]().(*memcached.Memcached) memcached.Servers = []string{"localhost"} - mConfig := &PluginConfig{ + mConfig := &InputConfig{ Name: "memcached", Filter: Filter{ Drop: []string{"other", "stuff"}, @@ -41,9 +41,9 @@ func TestConfig_LoadSinglePlugin(t *testing.T) { } mConfig.Tags = make(map[string]string) - assert.Equal(t, memcached, c.Plugins[0].Plugin, + assert.Equal(t, memcached, c.Inputs[0].Input, "Testdata did not produce a correct memcached struct.") - assert.Equal(t, mConfig, c.Plugins[0].Config, + assert.Equal(t, mConfig, c.Inputs[0].Config, "Testdata did not produce correct memcached metadata.") } @@ -58,10 +58,10 @@ func TestConfig_LoadDirectory(t *testing.T) { t.Error(err) } - memcached := plugins.Plugins["memcached"]().(*memcached.Memcached) + memcached := inputs.Inputs["memcached"]().(*memcached.Memcached) memcached.Servers = []string{"localhost"} - mConfig := &PluginConfig{ + mConfig := &InputConfig{ Name: "memcached", Filter: Filter{ Drop: []string{"other", "stuff"}, @@ -84,36 +84,38 @@ func TestConfig_LoadDirectory(t *testing.T) { } mConfig.Tags = make(map[string]string) - assert.Equal(t, memcached, c.Plugins[0].Plugin, + assert.Equal(t, memcached, c.Inputs[0].Input, "Testdata did not produce a correct memcached struct.") - assert.Equal(t, mConfig, c.Plugins[0].Config, + assert.Equal(t, mConfig, c.Inputs[0].Config, "Testdata did not produce correct memcached metadata.") - ex := plugins.Plugins["exec"]().(*exec.Exec) + ex := inputs.Inputs["exec"]().(*exec.Exec) ex.Command = "/usr/bin/myothercollector --foo=bar" - ex.Name = "myothercollector" - eConfig := &PluginConfig{Name: "exec"} + eConfig := &InputConfig{ + Name: "exec", + MeasurementSuffix: "_myothercollector", + } eConfig.Tags = make(map[string]string) - assert.Equal(t, ex, c.Plugins[1].Plugin, + assert.Equal(t, ex, c.Inputs[1].Input, "Merged Testdata did not produce a correct exec struct.") - assert.Equal(t, eConfig, c.Plugins[1].Config, + assert.Equal(t, eConfig, c.Inputs[1].Config, "Merged Testdata did not produce correct exec metadata.") memcached.Servers = []string{"192.168.1.1"} - assert.Equal(t, memcached, c.Plugins[2].Plugin, + assert.Equal(t, memcached, c.Inputs[2].Input, "Testdata did not produce a correct memcached struct.") - assert.Equal(t, mConfig, c.Plugins[2].Config, + assert.Equal(t, mConfig, c.Inputs[2].Config, "Testdata did not produce correct memcached metadata.") - pstat := plugins.Plugins["procstat"]().(*procstat.Procstat) + pstat := inputs.Inputs["procstat"]().(*procstat.Procstat) pstat.PidFile = "/var/run/grafana-server.pid" - pConfig := &PluginConfig{Name: "procstat"} + pConfig := &InputConfig{Name: "procstat"} pConfig.Tags = make(map[string]string) - assert.Equal(t, pstat, c.Plugins[3].Plugin, + assert.Equal(t, pstat, c.Inputs[3].Input, "Merged Testdata did not produce a correct procstat struct.") - assert.Equal(t, pConfig, c.Plugins[3].Config, + assert.Equal(t, pConfig, c.Inputs[3].Config, "Merged Testdata did not produce correct procstat metadata.") } diff --git a/internal/config/testdata/single_plugin.toml b/internal/config/testdata/single_plugin.toml index e591984f1f2e3..6670f6b2ffb23 100644 --- a/internal/config/testdata/single_plugin.toml +++ b/internal/config/testdata/single_plugin.toml @@ -1,9 +1,9 @@ -[[plugins.memcached]] +[[inputs.memcached]] servers = ["localhost"] pass = ["some", "strings"] drop = ["other", "stuff"] interval = "5s" - [plugins.memcached.tagpass] + [inputs.memcached.tagpass] goodtag = ["mytag"] - [plugins.memcached.tagdrop] + [inputs.memcached.tagdrop] badtag = ["othertag"] diff --git a/internal/config/testdata/subconfig/exec.conf b/internal/config/testdata/subconfig/exec.conf index 80aca00e80165..d621e78e08563 100644 --- a/internal/config/testdata/subconfig/exec.conf +++ b/internal/config/testdata/subconfig/exec.conf @@ -1,6 +1,4 @@ -[[plugins.exec]] +[[inputs.exec]] # the command to run command = "/usr/bin/myothercollector --foo=bar" - - # name of the command (used as a prefix for measurements) - name = "myothercollector" + name_suffix = "_myothercollector" diff --git a/internal/config/testdata/subconfig/memcached.conf b/internal/config/testdata/subconfig/memcached.conf index 8d67886c10c6c..4c43febc7c98f 100644 --- a/internal/config/testdata/subconfig/memcached.conf +++ b/internal/config/testdata/subconfig/memcached.conf @@ -1,9 +1,9 @@ -[[plugins.memcached]] +[[inputs.memcached]] servers = ["192.168.1.1"] pass = ["some", "strings"] drop = ["other", "stuff"] interval = "5s" - [plugins.memcached.tagpass] + [inputs.memcached.tagpass] goodtag = ["mytag"] - [plugins.memcached.tagdrop] + [inputs.memcached.tagdrop] badtag = ["othertag"] diff --git a/internal/config/testdata/subconfig/procstat.conf b/internal/config/testdata/subconfig/procstat.conf index 9f23e8d58548a..82708667f8e39 100644 --- a/internal/config/testdata/subconfig/procstat.conf +++ b/internal/config/testdata/subconfig/procstat.conf @@ -1,2 +1,2 @@ -[[plugins.procstat]] +[[inputs.procstat]] pid_file = "/var/run/grafana-server.pid" diff --git a/internal/config/testdata/telegraf-agent.toml b/internal/config/testdata/telegraf-agent.toml index 7b8cdb2bb96fe..3c279db340eb4 100644 --- a/internal/config/testdata/telegraf-agent.toml +++ b/internal/config/testdata/telegraf-agent.toml @@ -1,7 +1,7 @@ # Telegraf configuration # Telegraf is entirely plugin driven. All metrics are gathered from the -# declared plugins. +# declared inputs. # Even if a plugin has no configuration, it must be declared in here # to be active. Declaring a plugin means just specifying the name @@ -70,15 +70,15 @@ # PLUGINS # ############################################################################### -[plugins] +[inputs] # Read Apache status information (mod_status) -[[plugins.apache]] +[[inputs.apache]] # An array of Apache status URI to gather stats. urls = ["http://localhost/server-status?auto"] # Read metrics about cpu usage -[[plugins.cpu]] +[[inputs.cpu]] # Whether to report per-cpu stats or not percpu = true # Whether to report total system cpu stats or not @@ -87,11 +87,11 @@ drop = ["cpu_time"] # Read metrics about disk usage by mount point -[[plugins.diskio]] +[[inputs.diskio]] # no configuration # Read metrics from one or many disque servers -[[plugins.disque]] +[[inputs.disque]] # 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. @@ -100,7 +100,7 @@ servers = ["localhost"] # Read stats from one or more Elasticsearch servers or clusters -[[plugins.elasticsearch]] +[[inputs.elasticsearch]] # specify a list of one or more Elasticsearch servers servers = ["http://localhost:9200"] @@ -109,15 +109,13 @@ local = true # Read flattened metrics from one or more commands that output JSON to stdout -[[plugins.exec]] +[[inputs.exec]] # the command to run command = "/usr/bin/mycollector --foo=bar" - - # name of the command (used as a prefix for measurements) - name = "mycollector" + name_suffix = "_mycollector" # Read metrics of haproxy, via socket or csv stats page -[[plugins.haproxy]] +[[inputs.haproxy]] # An array of address to gather stats about. Specify an ip on hostname # with optional port. ie localhost, 10.10.3.33:1936, etc. # @@ -127,7 +125,7 @@ # servers = ["socket:/run/haproxy/admin.sock"] # Read flattened metrics from one or more JSON HTTP endpoints -[[plugins.httpjson]] +[[inputs.httpjson]] # a name for the service being polled name = "webserver_stats" @@ -146,11 +144,11 @@ threshold = "0.75" # Read metrics about disk IO by device -[[plugins.diskio]] +[[inputs.diskio]] # no configuration # read metrics from a Kafka topic -[[plugins.kafka_consumer]] +[[inputs.kafka_consumer]] # topic(s) to consume topics = ["telegraf"] # an array of Zookeeper connection strings @@ -163,7 +161,7 @@ offset = "oldest" # Read metrics from a LeoFS Server via SNMP -[[plugins.leofs]] +[[inputs.leofs]] # An array of URI to gather stats about LeoFS. # Specify an ip or hostname with port. ie 127.0.0.1:4020 # @@ -171,7 +169,7 @@ servers = ["127.0.0.1:4021"] # Read metrics from local Lustre service on OST, MDS -[[plugins.lustre2]] +[[inputs.lustre2]] # An array of /proc globs to search for Lustre stats # If not specified, the default will work on Lustre 2.5.x # @@ -179,11 +177,11 @@ # mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"] # Read metrics about memory usage -[[plugins.mem]] +[[inputs.mem]] # no configuration # Read metrics from one or many memcached servers -[[plugins.memcached]] +[[inputs.memcached]] # An array of address to gather stats about. Specify an ip on hostname # with optional port. ie localhost, 10.0.0.1:11211, etc. # @@ -191,7 +189,7 @@ servers = ["localhost"] # Read metrics from one or many MongoDB servers -[[plugins.mongodb]] +[[inputs.mongodb]] # 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. @@ -200,7 +198,7 @@ servers = ["127.0.0.1:27017"] # Read metrics from one or many mysql servers -[[plugins.mysql]] +[[inputs.mysql]] # specify servers via a url matching: # [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]] # e.g. @@ -211,7 +209,7 @@ servers = ["localhost"] # Read metrics about network interface usage -[[plugins.net]] +[[inputs.net]] # By default, telegraf gathers stats from any up interface (excluding loopback) # Setting interfaces will tell it to gather these explicit interfaces, # regardless of status. @@ -219,12 +217,12 @@ # interfaces = ["eth0", ... ] # Read Nginx's basic status information (ngx_http_stub_status_module) -[[plugins.nginx]] +[[inputs.nginx]] # An array of Nginx stub_status URI to gather stats. urls = ["http://localhost/status"] # Ping given url(s) and return statistics -[[plugins.ping]] +[[inputs.ping]] # urls to ping urls = ["www.google.com"] # required # number of pings to send (ping -c ) @@ -237,7 +235,7 @@ interface = "" # Read metrics from one or many postgresql servers -[[plugins.postgresql]] +[[inputs.postgresql]] # specify address via a url matching: # postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full] # or a simple string: @@ -264,12 +262,12 @@ # address = "influx@remoteserver" # Read metrics from one or many prometheus clients -[[plugins.prometheus]] +[[inputs.prometheus]] # An array of urls to scrape metrics from. urls = ["http://localhost:9100/metrics"] # Read metrics from one or many RabbitMQ servers via the management API -[[plugins.rabbitmq]] +[[inputs.rabbitmq]] # Specify servers via an array of tables # name = "rmq-server-1" # optional tag # url = "http://localhost:15672" @@ -281,7 +279,7 @@ # nodes = ["rabbit@node1", "rabbit@node2"] # Read metrics from one or many redis servers -[[plugins.redis]] +[[inputs.redis]] # 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, # 10.0.0.1:10000, etc. @@ -290,7 +288,7 @@ servers = ["localhost"] # Read metrics from one or many RethinkDB servers -[[plugins.rethinkdb]] +[[inputs.rethinkdb]] # 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. @@ -299,9 +297,9 @@ servers = ["127.0.0.1:28015"] # Read metrics about swap memory usage -[[plugins.swap]] +[[inputs.swap]] # no configuration # Read metrics about system load & uptime -[[plugins.system]] +[[inputs.system]] # no configuration diff --git a/outputs/all/all.go b/outputs/all/all.go deleted file mode 100644 index 08ebf254994f7..0000000000000 --- a/outputs/all/all.go +++ /dev/null @@ -1,16 +0,0 @@ -package all - -import ( - _ "github.com/influxdb/telegraf/outputs/amon" - _ "github.com/influxdb/telegraf/outputs/amqp" - _ "github.com/influxdb/telegraf/outputs/datadog" - _ "github.com/influxdb/telegraf/outputs/influxdb" - _ "github.com/influxdb/telegraf/outputs/kafka" - _ "github.com/influxdb/telegraf/outputs/kinesis" - _ "github.com/influxdb/telegraf/outputs/librato" - _ "github.com/influxdb/telegraf/outputs/mqtt" - _ "github.com/influxdb/telegraf/outputs/nsq" - _ "github.com/influxdb/telegraf/outputs/opentsdb" - _ "github.com/influxdb/telegraf/outputs/prometheus_client" - _ "github.com/influxdb/telegraf/outputs/riemann" -) diff --git a/plugins/all/all.go b/plugins/all/all.go deleted file mode 100644 index 8b4e754be00d9..0000000000000 --- a/plugins/all/all.go +++ /dev/null @@ -1,37 +0,0 @@ -package all - -import ( - _ "github.com/influxdb/telegraf/plugins/aerospike" - _ "github.com/influxdb/telegraf/plugins/apache" - _ "github.com/influxdb/telegraf/plugins/bcache" - _ "github.com/influxdb/telegraf/plugins/disque" - _ "github.com/influxdb/telegraf/plugins/elasticsearch" - _ "github.com/influxdb/telegraf/plugins/exec" - _ "github.com/influxdb/telegraf/plugins/haproxy" - _ "github.com/influxdb/telegraf/plugins/httpjson" - _ "github.com/influxdb/telegraf/plugins/influxdb" - _ "github.com/influxdb/telegraf/plugins/jolokia" - _ "github.com/influxdb/telegraf/plugins/kafka_consumer" - _ "github.com/influxdb/telegraf/plugins/leofs" - _ "github.com/influxdb/telegraf/plugins/lustre2" - _ "github.com/influxdb/telegraf/plugins/mailchimp" - _ "github.com/influxdb/telegraf/plugins/memcached" - _ "github.com/influxdb/telegraf/plugins/mongodb" - _ "github.com/influxdb/telegraf/plugins/mysql" - _ "github.com/influxdb/telegraf/plugins/nginx" - _ "github.com/influxdb/telegraf/plugins/phpfpm" - _ "github.com/influxdb/telegraf/plugins/ping" - _ "github.com/influxdb/telegraf/plugins/postgresql" - _ "github.com/influxdb/telegraf/plugins/procstat" - _ "github.com/influxdb/telegraf/plugins/prometheus" - _ "github.com/influxdb/telegraf/plugins/puppetagent" - _ "github.com/influxdb/telegraf/plugins/rabbitmq" - _ "github.com/influxdb/telegraf/plugins/redis" - _ "github.com/influxdb/telegraf/plugins/rethinkdb" - _ "github.com/influxdb/telegraf/plugins/statsd" - _ "github.com/influxdb/telegraf/plugins/system" - _ "github.com/influxdb/telegraf/plugins/trig" - _ "github.com/influxdb/telegraf/plugins/twemproxy" - _ "github.com/influxdb/telegraf/plugins/zfs" - _ "github.com/influxdb/telegraf/plugins/zookeeper" -) diff --git a/plugins/aerospike/README.md b/plugins/inputs/aerospike/README.md similarity index 100% rename from plugins/aerospike/README.md rename to plugins/inputs/aerospike/README.md diff --git a/plugins/aerospike/aerospike.go b/plugins/inputs/aerospike/aerospike.go similarity index 96% rename from plugins/aerospike/aerospike.go rename to plugins/inputs/aerospike/aerospike.go index 9d920646d30ff..5f847ebfab42f 100644 --- a/plugins/aerospike/aerospike.go +++ b/plugins/inputs/aerospike/aerospike.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/binary" "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "net" "strconv" "strings" @@ -119,7 +119,7 @@ func (a *Aerospike) Description() string { return "Read stats from an aerospike server" } -func (a *Aerospike) Gather(acc plugins.Accumulator) error { +func (a *Aerospike) Gather(acc inputs.Accumulator) error { if len(a.Servers) == 0 { return a.gatherServer("127.0.0.1:3000", acc) } @@ -140,7 +140,7 @@ func (a *Aerospike) Gather(acc plugins.Accumulator) error { return outerr } -func (a *Aerospike) gatherServer(host string, acc plugins.Accumulator) error { +func (a *Aerospike) gatherServer(host string, acc inputs.Accumulator) error { aerospikeInfo, err := getMap(STATISTICS_COMMAND, host) if err != nil { return fmt.Errorf("Aerospike info failed: %s", err) @@ -249,7 +249,7 @@ func get(key []byte, host string) (map[string]string, error) { func readAerospikeStats( stats map[string]string, - acc plugins.Accumulator, + acc inputs.Accumulator, host string, namespace string, ) { @@ -336,7 +336,7 @@ func msgLenFromBytes(buf [6]byte) int64 { } func init() { - plugins.Add("aerospike", func() plugins.Plugin { + inputs.Add("aerospike", func() inputs.Input { return &Aerospike{} }) } diff --git a/plugins/aerospike/aerospike_test.go b/plugins/inputs/aerospike/aerospike_test.go similarity index 100% rename from plugins/aerospike/aerospike_test.go rename to plugins/inputs/aerospike/aerospike_test.go diff --git a/plugins/inputs/all/all.go b/plugins/inputs/all/all.go new file mode 100644 index 0000000000000..fea1c7ca04a60 --- /dev/null +++ b/plugins/inputs/all/all.go @@ -0,0 +1,37 @@ +package all + +import ( + _ "github.com/influxdb/telegraf/plugins/inputs/aerospike" + _ "github.com/influxdb/telegraf/plugins/inputs/apache" + _ "github.com/influxdb/telegraf/plugins/inputs/bcache" + _ "github.com/influxdb/telegraf/plugins/inputs/disque" + _ "github.com/influxdb/telegraf/plugins/inputs/elasticsearch" + _ "github.com/influxdb/telegraf/plugins/inputs/exec" + _ "github.com/influxdb/telegraf/plugins/inputs/haproxy" + _ "github.com/influxdb/telegraf/plugins/inputs/httpjson" + _ "github.com/influxdb/telegraf/plugins/inputs/influxdb" + _ "github.com/influxdb/telegraf/plugins/inputs/jolokia" + _ "github.com/influxdb/telegraf/plugins/inputs/kafka_consumer" + _ "github.com/influxdb/telegraf/plugins/inputs/leofs" + _ "github.com/influxdb/telegraf/plugins/inputs/lustre2" + _ "github.com/influxdb/telegraf/plugins/inputs/mailchimp" + _ "github.com/influxdb/telegraf/plugins/inputs/memcached" + _ "github.com/influxdb/telegraf/plugins/inputs/mongodb" + _ "github.com/influxdb/telegraf/plugins/inputs/mysql" + _ "github.com/influxdb/telegraf/plugins/inputs/nginx" + _ "github.com/influxdb/telegraf/plugins/inputs/phpfpm" + _ "github.com/influxdb/telegraf/plugins/inputs/ping" + _ "github.com/influxdb/telegraf/plugins/inputs/postgresql" + _ "github.com/influxdb/telegraf/plugins/inputs/procstat" + _ "github.com/influxdb/telegraf/plugins/inputs/prometheus" + _ "github.com/influxdb/telegraf/plugins/inputs/puppetagent" + _ "github.com/influxdb/telegraf/plugins/inputs/rabbitmq" + _ "github.com/influxdb/telegraf/plugins/inputs/redis" + _ "github.com/influxdb/telegraf/plugins/inputs/rethinkdb" + _ "github.com/influxdb/telegraf/plugins/inputs/statsd" + _ "github.com/influxdb/telegraf/plugins/inputs/system" + _ "github.com/influxdb/telegraf/plugins/inputs/trig" + _ "github.com/influxdb/telegraf/plugins/inputs/twemproxy" + _ "github.com/influxdb/telegraf/plugins/inputs/zfs" + _ "github.com/influxdb/telegraf/plugins/inputs/zookeeper" +) diff --git a/plugins/apache/README.md b/plugins/inputs/apache/README.md similarity index 100% rename from plugins/apache/README.md rename to plugins/inputs/apache/README.md diff --git a/plugins/apache/apache.go b/plugins/inputs/apache/apache.go similarity index 93% rename from plugins/apache/apache.go rename to plugins/inputs/apache/apache.go index 958a0296e680b..f48bac3361e44 100644 --- a/plugins/apache/apache.go +++ b/plugins/inputs/apache/apache.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Apache struct { @@ -31,7 +31,7 @@ func (n *Apache) Description() string { return "Read Apache status information (mod_status)" } -func (n *Apache) Gather(acc plugins.Accumulator) error { +func (n *Apache) Gather(acc inputs.Accumulator) error { var wg sync.WaitGroup var outerr error @@ -59,7 +59,7 @@ var tr = &http.Transport{ var client = &http.Client{Transport: tr} -func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error { +func (n *Apache) gatherUrl(addr *url.URL, acc inputs.Accumulator) error { resp, err := client.Get(addr.String()) if err != nil { return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err) @@ -164,7 +164,7 @@ func getTags(addr *url.URL) map[string]string { } func init() { - plugins.Add("apache", func() plugins.Plugin { + inputs.Add("apache", func() inputs.Input { return &Apache{} }) } diff --git a/plugins/apache/apache_test.go b/plugins/inputs/apache/apache_test.go similarity index 100% rename from plugins/apache/apache_test.go rename to plugins/inputs/apache/apache_test.go diff --git a/plugins/bcache/README.md b/plugins/inputs/bcache/README.md similarity index 97% rename from plugins/bcache/README.md rename to plugins/inputs/bcache/README.md index 27062b9158c5a..98a841bf57495 100644 --- a/plugins/bcache/README.md +++ b/plugins/inputs/bcache/README.md @@ -26,27 +26,27 @@ Measurement names: dirty_data Amount of dirty data for this backing device in the cache. Continuously updated unlike the cache set's version, but may be slightly off. - + bypassed Amount of IO (both reads and writes) that has bypassed the cache - + cache_bypass_hits cache_bypass_misses Hits and misses for IO that is intended to skip the cache are still counted, but broken out here. - + cache_hits cache_misses cache_hit_ratio Hits and misses are counted per individual IO as bcache sees them; a partial hit is counted as a miss. - + cache_miss_collisions Counts instances where data was going to be inserted into the cache from a cache miss, but raced with a write and data was already present (usually 0 since the synchronization for cache misses was rewritten) - + cache_readaheads Count of times readahead occurred. ``` @@ -70,7 +70,7 @@ Using this configuration: When run with: ``` -./telegraf -config telegraf.conf -filter bcache -test +./telegraf -config telegraf.conf -input-filter bcache -test ``` It produces: diff --git a/plugins/bcache/bcache.go b/plugins/inputs/bcache/bcache.go similarity index 92% rename from plugins/bcache/bcache.go rename to plugins/inputs/bcache/bcache.go index 92cea3d6311de..146849eef0477 100644 --- a/plugins/bcache/bcache.go +++ b/plugins/inputs/bcache/bcache.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Bcache struct { @@ -69,7 +69,7 @@ func prettyToBytes(v string) uint64 { return uint64(result) } -func (b *Bcache) gatherBcache(bdev string, acc plugins.Accumulator) error { +func (b *Bcache) gatherBcache(bdev string, acc inputs.Accumulator) error { tags := getTags(bdev) metrics, err := filepath.Glob(bdev + "/stats_total/*") if len(metrics) < 0 { @@ -104,7 +104,7 @@ func (b *Bcache) gatherBcache(bdev string, acc plugins.Accumulator) error { return nil } -func (b *Bcache) Gather(acc plugins.Accumulator) error { +func (b *Bcache) Gather(acc inputs.Accumulator) error { bcacheDevsChecked := make(map[string]bool) var restrictDevs bool if len(b.BcacheDevs) != 0 { @@ -135,7 +135,7 @@ func (b *Bcache) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("bcache", func() plugins.Plugin { + inputs.Add("bcache", func() inputs.Input { return &Bcache{} }) } diff --git a/plugins/bcache/bcache_test.go b/plugins/inputs/bcache/bcache_test.go similarity index 100% rename from plugins/bcache/bcache_test.go rename to plugins/inputs/bcache/bcache_test.go diff --git a/plugins/disque/disque.go b/plugins/inputs/disque/disque.go similarity index 94% rename from plugins/disque/disque.go rename to plugins/inputs/disque/disque.go index b7b7dd5c1933b..334fdd5543930 100644 --- a/plugins/disque/disque.go +++ b/plugins/inputs/disque/disque.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Disque struct { @@ -61,7 +61,7 @@ var ErrProtocolError = errors.New("disque protocol error") // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (g *Disque) Gather(acc plugins.Accumulator) error { +func (g *Disque) Gather(acc inputs.Accumulator) error { if len(g.Servers) == 0 { url := &url.URL{ Host: ":7711", @@ -98,7 +98,7 @@ func (g *Disque) Gather(acc plugins.Accumulator) error { const defaultPort = "7711" -func (g *Disque) gatherServer(addr *url.URL, acc plugins.Accumulator) error { +func (g *Disque) gatherServer(addr *url.URL, acc inputs.Accumulator) error { if g.c == nil { _, _, err := net.SplitHostPort(addr.Host) @@ -198,7 +198,7 @@ func (g *Disque) gatherServer(addr *url.URL, acc plugins.Accumulator) error { } func init() { - plugins.Add("disque", func() plugins.Plugin { + inputs.Add("disque", func() inputs.Input { return &Disque{} }) } diff --git a/plugins/disque/disque_test.go b/plugins/inputs/disque/disque_test.go similarity index 100% rename from plugins/disque/disque_test.go rename to plugins/inputs/disque/disque_test.go diff --git a/plugins/elasticsearch/README.md b/plugins/inputs/elasticsearch/README.md similarity index 100% rename from plugins/elasticsearch/README.md rename to plugins/inputs/elasticsearch/README.md diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/inputs/elasticsearch/elasticsearch.go similarity index 95% rename from plugins/elasticsearch/elasticsearch.go rename to plugins/inputs/elasticsearch/elasticsearch.go index 2266f22434b96..f8185a0535c67 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/inputs/elasticsearch/elasticsearch.go @@ -7,7 +7,7 @@ import ( "time" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) const statsPath = "/_nodes/stats" @@ -92,7 +92,7 @@ func (e *Elasticsearch) Description() string { // Gather reads the stats from Elasticsearch and writes it to the // Accumulator. -func (e *Elasticsearch) Gather(acc plugins.Accumulator) error { +func (e *Elasticsearch) Gather(acc inputs.Accumulator) error { for _, serv := range e.Servers { var url string if e.Local { @@ -110,7 +110,7 @@ func (e *Elasticsearch) Gather(acc plugins.Accumulator) error { return nil } -func (e *Elasticsearch) gatherNodeStats(url string, acc plugins.Accumulator) error { +func (e *Elasticsearch) gatherNodeStats(url string, acc inputs.Accumulator) error { nodeStats := &struct { ClusterName string `json:"cluster_name"` Nodes map[string]*node `json:"nodes"` @@ -155,7 +155,7 @@ func (e *Elasticsearch) gatherNodeStats(url string, acc plugins.Accumulator) err return nil } -func (e *Elasticsearch) gatherClusterStats(url string, acc plugins.Accumulator) error { +func (e *Elasticsearch) gatherClusterStats(url string, acc inputs.Accumulator) error { clusterStats := &clusterHealth{} if err := e.gatherData(url, clusterStats); err != nil { return err @@ -220,7 +220,7 @@ func (e *Elasticsearch) gatherData(url string, v interface{}) error { } func init() { - plugins.Add("elasticsearch", func() plugins.Plugin { + inputs.Add("elasticsearch", func() inputs.Input { return NewElasticsearch() }) } diff --git a/plugins/elasticsearch/elasticsearch_test.go b/plugins/inputs/elasticsearch/elasticsearch_test.go similarity index 100% rename from plugins/elasticsearch/elasticsearch_test.go rename to plugins/inputs/elasticsearch/elasticsearch_test.go diff --git a/plugins/elasticsearch/testdata_test.go b/plugins/inputs/elasticsearch/testdata_test.go similarity index 100% rename from plugins/elasticsearch/testdata_test.go rename to plugins/inputs/elasticsearch/testdata_test.go diff --git a/plugins/exec/README.md b/plugins/inputs/exec/README.md similarity index 100% rename from plugins/exec/README.md rename to plugins/inputs/exec/README.md diff --git a/plugins/exec/exec.go b/plugins/inputs/exec/exec.go similarity index 78% rename from plugins/exec/exec.go rename to plugins/inputs/exec/exec.go index 87a8cc72fca69..b3c1001f80f62 100644 --- a/plugins/exec/exec.go +++ b/plugins/inputs/exec/exec.go @@ -9,20 +9,19 @@ import ( "github.com/gonuts/go-shellquote" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) const sampleConfig = ` # the command to run command = "/usr/bin/mycollector --foo=bar" - # name of the command (used as a prefix for measurements) - name = "mycollector" + # measurement name suffix (for separating different commands) + name_suffix = "_mycollector" ` type Exec struct { Command string - Name string runner Runner } @@ -62,7 +61,7 @@ func (e *Exec) Description() string { return "Read flattened metrics from one or more commands that output JSON to stdout" } -func (e *Exec) Gather(acc plugins.Accumulator) error { +func (e *Exec) Gather(acc inputs.Accumulator) error { out, err := e.runner.Run(e) if err != nil { return err @@ -81,18 +80,12 @@ func (e *Exec) Gather(acc plugins.Accumulator) error { return err } - var msrmnt_name string - if e.Name == "" { - msrmnt_name = "exec" - } else { - msrmnt_name = "exec_" + e.Name - } - acc.AddFields(msrmnt_name, f.Fields, nil) + acc.AddFields("exec", f.Fields, nil) return nil } func init() { - plugins.Add("exec", func() plugins.Plugin { + inputs.Add("exec", func() inputs.Input { return NewExec() }) } diff --git a/plugins/exec/exec_test.go b/plugins/inputs/exec/exec_test.go similarity index 93% rename from plugins/exec/exec_test.go rename to plugins/inputs/exec/exec_test.go index bb94a2fd58144..d3e54429dbb87 100644 --- a/plugins/exec/exec_test.go +++ b/plugins/inputs/exec/exec_test.go @@ -54,7 +54,6 @@ func TestExec(t *testing.T) { e := &Exec{ runner: newRunnerMock([]byte(validJson), nil), Command: "testcommand arg1", - Name: "mycollector", } var acc testutil.Accumulator @@ -68,14 +67,13 @@ func TestExec(t *testing.T) { "cpu_free": float64(32), "percent": float64(0.81), } - acc.AssertContainsFields(t, "exec_mycollector", fields) + acc.AssertContainsFields(t, "exec", fields) } func TestExecMalformed(t *testing.T) { e := &Exec{ runner: newRunnerMock([]byte(malformedJson), nil), Command: "badcommand arg1", - Name: "mycollector", } var acc testutil.Accumulator @@ -88,7 +86,6 @@ func TestCommandError(t *testing.T) { e := &Exec{ runner: newRunnerMock(nil, fmt.Errorf("exit status code 1")), Command: "badcommand", - Name: "mycollector", } var acc testutil.Accumulator diff --git a/plugins/haproxy/haproxy.go b/plugins/inputs/haproxy/haproxy.go similarity index 97% rename from plugins/haproxy/haproxy.go rename to plugins/inputs/haproxy/haproxy.go index 10f7dab3ca6be..23b92fc266a2e 100644 --- a/plugins/haproxy/haproxy.go +++ b/plugins/inputs/haproxy/haproxy.go @@ -3,7 +3,7 @@ package haproxy import ( "encoding/csv" "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "io" "net/http" "net/url" @@ -104,7 +104,7 @@ func (r *haproxy) Description() string { // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (g *haproxy) Gather(acc plugins.Accumulator) error { +func (g *haproxy) Gather(acc inputs.Accumulator) error { if len(g.Servers) == 0 { return g.gatherServer("http://127.0.0.1:1936", acc) } @@ -126,7 +126,7 @@ func (g *haproxy) Gather(acc plugins.Accumulator) error { return outerr } -func (g *haproxy) gatherServer(addr string, acc plugins.Accumulator) error { +func (g *haproxy) gatherServer(addr string, acc inputs.Accumulator) error { if g.client == nil { client := &http.Client{} @@ -156,7 +156,7 @@ func (g *haproxy) gatherServer(addr string, acc plugins.Accumulator) error { return importCsvResult(res.Body, acc, u.Host) } -func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error { +func importCsvResult(r io.Reader, acc inputs.Accumulator, host string) error { csv := csv.NewReader(r) result, err := csv.ReadAll() now := time.Now() @@ -358,7 +358,7 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error { } func init() { - plugins.Add("haproxy", func() plugins.Plugin { + inputs.Add("haproxy", func() inputs.Input { return &haproxy{} }) } diff --git a/plugins/haproxy/haproxy_test.go b/plugins/inputs/haproxy/haproxy_test.go similarity index 100% rename from plugins/haproxy/haproxy_test.go rename to plugins/inputs/haproxy/haproxy_test.go diff --git a/plugins/httpjson/README.md b/plugins/inputs/httpjson/README.md similarity index 100% rename from plugins/httpjson/README.md rename to plugins/inputs/httpjson/README.md diff --git a/plugins/httpjson/httpjson.go b/plugins/inputs/httpjson/httpjson.go similarity index 95% rename from plugins/httpjson/httpjson.go rename to plugins/inputs/httpjson/httpjson.go index 9da0f63d0ff4c..e31085e3ab4f8 100644 --- a/plugins/httpjson/httpjson.go +++ b/plugins/inputs/httpjson/httpjson.go @@ -11,7 +11,7 @@ import ( "sync" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type HttpJson struct { @@ -63,7 +63,7 @@ var sampleConfig = ` # ] # HTTP parameters (all values must be strings) - [plugins.httpjson.parameters] + [inputs.httpjson.parameters] event_type = "cpu_spike" threshold = "0.75" ` @@ -77,7 +77,7 @@ func (h *HttpJson) Description() string { } // Gathers data for all servers. -func (h *HttpJson) Gather(acc plugins.Accumulator) error { +func (h *HttpJson) Gather(acc inputs.Accumulator) error { var wg sync.WaitGroup errorChannel := make(chan error, len(h.Servers)) @@ -116,7 +116,7 @@ func (h *HttpJson) Gather(acc plugins.Accumulator) error { // Returns: // error: Any error that may have occurred func (h *HttpJson) gatherServer( - acc plugins.Accumulator, + acc inputs.Accumulator, serverURL string, ) error { resp, err := h.sendRequest(serverURL) @@ -210,7 +210,7 @@ func (h *HttpJson) sendRequest(serverURL string) (string, error) { } func init() { - plugins.Add("httpjson", func() plugins.Plugin { + inputs.Add("httpjson", func() inputs.Input { return &HttpJson{client: RealHTTPClient{client: &http.Client{}}} }) } diff --git a/plugins/httpjson/httpjson_test.go b/plugins/inputs/httpjson/httpjson_test.go similarity index 100% rename from plugins/httpjson/httpjson_test.go rename to plugins/inputs/httpjson/httpjson_test.go diff --git a/plugins/influxdb/README.md b/plugins/inputs/influxdb/README.md similarity index 98% rename from plugins/influxdb/README.md rename to plugins/inputs/influxdb/README.md index 8d4727973c605..84dc3caf8f62a 100644 --- a/plugins/influxdb/README.md +++ b/plugins/inputs/influxdb/README.md @@ -5,7 +5,7 @@ The influxdb plugin collects InfluxDB-formatted data from JSON endpoints. With a configuration of: ```toml -[[plugins.influxdb]] +[[inputs.influxdb]] urls = [ "http://127.0.0.1:8086/debug/vars", "http://192.168.2.1:8086/debug/vars" diff --git a/plugins/influxdb/influxdb.go b/plugins/inputs/influxdb/influxdb.go similarity index 94% rename from plugins/influxdb/influxdb.go rename to plugins/inputs/influxdb/influxdb.go index a4044364affb1..cf5742e1d70b0 100644 --- a/plugins/influxdb/influxdb.go +++ b/plugins/inputs/influxdb/influxdb.go @@ -8,7 +8,7 @@ import ( "strings" "sync" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type InfluxDB struct { @@ -32,7 +32,7 @@ func (*InfluxDB) SampleConfig() string { ` } -func (i *InfluxDB) Gather(acc plugins.Accumulator) error { +func (i *InfluxDB) Gather(acc inputs.Accumulator) error { errorChannel := make(chan error, len(i.URLs)) var wg sync.WaitGroup @@ -77,7 +77,7 @@ type point struct { // Returns: // error: Any error that may have occurred func (i *InfluxDB) gatherURL( - acc plugins.Accumulator, + acc inputs.Accumulator, url string, ) error { resp, err := http.Get(url) @@ -140,7 +140,7 @@ func (i *InfluxDB) gatherURL( } func init() { - plugins.Add("influxdb", func() plugins.Plugin { + inputs.Add("influxdb", func() inputs.Input { return &InfluxDB{} }) } diff --git a/plugins/influxdb/influxdb_test.go b/plugins/inputs/influxdb/influxdb_test.go similarity index 97% rename from plugins/influxdb/influxdb_test.go rename to plugins/inputs/influxdb/influxdb_test.go index 7911156debb92..0e02cc6bdf4c3 100644 --- a/plugins/influxdb/influxdb_test.go +++ b/plugins/inputs/influxdb/influxdb_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "github.com/influxdb/telegraf/plugins/influxdb" + "github.com/influxdb/telegraf/plugins/inputs/influxdb" "github.com/influxdb/telegraf/testutil" "github.com/stretchr/testify/require" ) diff --git a/plugins/jolokia/README.md b/plugins/inputs/jolokia/README.md similarity index 100% rename from plugins/jolokia/README.md rename to plugins/inputs/jolokia/README.md diff --git a/plugins/jolokia/jolokia.go b/plugins/inputs/jolokia/jolokia.go similarity index 94% rename from plugins/jolokia/jolokia.go rename to plugins/inputs/jolokia/jolokia.go index 610f08cd5293a..36811bd2757f8 100644 --- a/plugins/jolokia/jolokia.go +++ b/plugins/inputs/jolokia/jolokia.go @@ -8,7 +8,7 @@ import ( "net/http" "net/url" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Server struct { @@ -49,7 +49,7 @@ func (j *Jolokia) SampleConfig() string { context = "/jolokia/read" # List of servers exposing jolokia read service - [[plugins.jolokia.servers]] + [[inputs.jolokia.servers]] name = "stable" host = "192.168.103.2" port = "8180" @@ -59,7 +59,7 @@ func (j *Jolokia) SampleConfig() string { # List of metrics collected on above servers # Each metric consists in a name, a jmx path and either a pass or drop slice attributes # This collect all heap memory usage metrics - [[plugins.jolokia.metrics]] + [[inputs.jolokia.metrics]] name = "heap_memory_usage" jmx = "/java.lang:type=Memory/HeapMemoryUsage" ` @@ -108,7 +108,7 @@ func (j *Jolokia) getAttr(requestUrl *url.URL) (map[string]interface{}, error) { return jsonOut, nil } -func (j *Jolokia) Gather(acc plugins.Accumulator) error { +func (j *Jolokia) Gather(acc inputs.Accumulator) error { context := j.Context //"/jolokia/read" servers := j.Servers metrics := j.Metrics @@ -157,7 +157,7 @@ func (j *Jolokia) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("jolokia", func() plugins.Plugin { + inputs.Add("jolokia", func() inputs.Input { return &Jolokia{jClient: &JolokiaClientImpl{client: &http.Client{}}} }) } diff --git a/plugins/jolokia/jolokia_test.go b/plugins/inputs/jolokia/jolokia_test.go similarity index 100% rename from plugins/jolokia/jolokia_test.go rename to plugins/inputs/jolokia/jolokia_test.go diff --git a/plugins/kafka_consumer/README.md b/plugins/inputs/kafka_consumer/README.md similarity index 100% rename from plugins/kafka_consumer/README.md rename to plugins/inputs/kafka_consumer/README.md diff --git a/plugins/kafka_consumer/kafka_consumer.go b/plugins/inputs/kafka_consumer/kafka_consumer.go similarity index 96% rename from plugins/kafka_consumer/kafka_consumer.go rename to plugins/inputs/kafka_consumer/kafka_consumer.go index f47e7e92c8060..f3558e2e510b8 100644 --- a/plugins/kafka_consumer/kafka_consumer.go +++ b/plugins/inputs/kafka_consumer/kafka_consumer.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/influxdb/influxdb/models" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "github.com/Shopify/sarama" "github.com/wvanbergen/kafka/consumergroup" @@ -148,7 +148,7 @@ func (k *Kafka) Stop() { } } -func (k *Kafka) Gather(acc plugins.Accumulator) error { +func (k *Kafka) Gather(acc inputs.Accumulator) error { k.Lock() defer k.Unlock() npoints := len(k.pointChan) @@ -160,7 +160,7 @@ func (k *Kafka) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("kafka_consumer", func() plugins.Plugin { + inputs.Add("kafka_consumer", func() inputs.Input { return &Kafka{} }) } diff --git a/plugins/kafka_consumer/kafka_consumer_integration_test.go b/plugins/inputs/kafka_consumer/kafka_consumer_integration_test.go similarity index 100% rename from plugins/kafka_consumer/kafka_consumer_integration_test.go rename to plugins/inputs/kafka_consumer/kafka_consumer_integration_test.go diff --git a/plugins/kafka_consumer/kafka_consumer_test.go b/plugins/inputs/kafka_consumer/kafka_consumer_test.go similarity index 100% rename from plugins/kafka_consumer/kafka_consumer_test.go rename to plugins/inputs/kafka_consumer/kafka_consumer_test.go diff --git a/plugins/leofs/leofs.go b/plugins/inputs/leofs/leofs.go similarity index 96% rename from plugins/leofs/leofs.go rename to plugins/inputs/leofs/leofs.go index 5a1df7c56444f..c65db5f3702f2 100644 --- a/plugins/leofs/leofs.go +++ b/plugins/inputs/leofs/leofs.go @@ -3,7 +3,7 @@ package leofs import ( "bufio" "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "net/url" "os/exec" "strconv" @@ -146,7 +146,7 @@ func (l *LeoFS) Description() string { return "Read metrics from a LeoFS Server via SNMP" } -func (l *LeoFS) Gather(acc plugins.Accumulator) error { +func (l *LeoFS) Gather(acc inputs.Accumulator) error { if len(l.Servers) == 0 { l.gatherServer(defaultEndpoint, ServerTypeManagerMaster, acc) return nil @@ -176,7 +176,7 @@ func (l *LeoFS) Gather(acc plugins.Accumulator) error { return outerr } -func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc plugins.Accumulator) error { +func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc inputs.Accumulator) error { cmd := exec.Command("snmpwalk", "-v2c", "-cpublic", endpoint, oid) stdout, err := cmd.StdoutPipe() if err != nil { @@ -225,7 +225,7 @@ func retrieveTokenAfterColon(line string) (string, error) { } func init() { - plugins.Add("leofs", func() plugins.Plugin { + inputs.Add("leofs", func() inputs.Input { return &LeoFS{} }) } diff --git a/plugins/leofs/leofs_test.go b/plugins/inputs/leofs/leofs_test.go similarity index 100% rename from plugins/leofs/leofs_test.go rename to plugins/inputs/leofs/leofs_test.go diff --git a/plugins/lustre2/lustre2.go b/plugins/inputs/lustre2/lustre2.go similarity index 96% rename from plugins/lustre2/lustre2.go rename to plugins/inputs/lustre2/lustre2.go index 65f9369669ad0..90222af79d9bf 100644 --- a/plugins/lustre2/lustre2.go +++ b/plugins/inputs/lustre2/lustre2.go @@ -14,7 +14,7 @@ import ( "strings" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) // Lustre proc files can change between versions, so we want to future-proof @@ -129,7 +129,7 @@ var wanted_mds_fields = []*mapping{ }, } -func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc plugins.Accumulator) error { +func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc inputs.Accumulator) error { files, err := filepath.Glob(fileglob) if err != nil { return err @@ -193,7 +193,7 @@ func (l *Lustre2) Description() string { } // Gather reads stats from all lustre targets -func (l *Lustre2) Gather(acc plugins.Accumulator) error { +func (l *Lustre2) Gather(acc inputs.Accumulator) error { l.allFields = make(map[string]map[string]interface{}) if len(l.Ost_procfiles) == 0 { @@ -244,7 +244,7 @@ func (l *Lustre2) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("lustre2", func() plugins.Plugin { + inputs.Add("lustre2", func() inputs.Input { return &Lustre2{} }) } diff --git a/plugins/lustre2/lustre2_test.go b/plugins/inputs/lustre2/lustre2_test.go similarity index 100% rename from plugins/lustre2/lustre2_test.go rename to plugins/inputs/lustre2/lustre2_test.go diff --git a/plugins/mailchimp/chimp_api.go b/plugins/inputs/mailchimp/chimp_api.go similarity index 100% rename from plugins/mailchimp/chimp_api.go rename to plugins/inputs/mailchimp/chimp_api.go diff --git a/plugins/mailchimp/mailchimp.go b/plugins/inputs/mailchimp/mailchimp.go similarity index 93% rename from plugins/mailchimp/mailchimp.go rename to plugins/inputs/mailchimp/mailchimp.go index d26d479afbad1..4b148a95ca8ca 100644 --- a/plugins/mailchimp/mailchimp.go +++ b/plugins/inputs/mailchimp/mailchimp.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type MailChimp struct { @@ -34,7 +34,7 @@ func (m *MailChimp) Description() string { return "Gathers metrics from the /3.0/reports MailChimp API" } -func (m *MailChimp) Gather(acc plugins.Accumulator) error { +func (m *MailChimp) Gather(acc inputs.Accumulator) error { if m.api == nil { m.api = NewChimpAPI(m.ApiKey) } @@ -71,7 +71,7 @@ func (m *MailChimp) Gather(acc plugins.Accumulator) error { return nil } -func gatherReport(acc plugins.Accumulator, report Report, now time.Time) { +func gatherReport(acc inputs.Accumulator, report Report, now time.Time) { tags := make(map[string]string) tags["id"] = report.ID tags["campaign_title"] = report.CampaignTitle @@ -110,7 +110,7 @@ func gatherReport(acc plugins.Accumulator, report Report, now time.Time) { } func init() { - plugins.Add("mailchimp", func() plugins.Plugin { + inputs.Add("mailchimp", func() inputs.Input { return &MailChimp{} }) } diff --git a/plugins/mailchimp/mailchimp_test.go b/plugins/inputs/mailchimp/mailchimp_test.go similarity index 100% rename from plugins/mailchimp/mailchimp_test.go rename to plugins/inputs/mailchimp/mailchimp_test.go diff --git a/plugins/memcached/memcached.go b/plugins/inputs/memcached/memcached.go similarity index 95% rename from plugins/memcached/memcached.go rename to plugins/inputs/memcached/memcached.go index 1964782646583..1d9ee95478f3e 100644 --- a/plugins/memcached/memcached.go +++ b/plugins/inputs/memcached/memcached.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) // Memcached is a memcached plugin @@ -69,7 +69,7 @@ func (m *Memcached) Description() string { } // Gather reads stats from all configured servers accumulates stats -func (m *Memcached) Gather(acc plugins.Accumulator) error { +func (m *Memcached) Gather(acc inputs.Accumulator) error { if len(m.Servers) == 0 && len(m.UnixSockets) == 0 { return m.gatherServer(":11211", false, acc) } @@ -92,7 +92,7 @@ func (m *Memcached) Gather(acc plugins.Accumulator) error { func (m *Memcached) gatherServer( address string, unix bool, - acc plugins.Accumulator, + acc inputs.Accumulator, ) error { var conn net.Conn if unix { @@ -178,7 +178,7 @@ func parseResponse(r *bufio.Reader) (map[string]string, error) { } func init() { - plugins.Add("memcached", func() plugins.Plugin { + inputs.Add("memcached", func() inputs.Input { return &Memcached{} }) } diff --git a/plugins/memcached/memcached_test.go b/plugins/inputs/memcached/memcached_test.go similarity index 100% rename from plugins/memcached/memcached_test.go rename to plugins/inputs/memcached/memcached_test.go diff --git a/plugins/mock_Plugin.go b/plugins/inputs/mock_Plugin.go similarity index 92% rename from plugins/mock_Plugin.go rename to plugins/inputs/mock_Plugin.go index 492384b25a884..87dd14884d194 100644 --- a/plugins/mock_Plugin.go +++ b/plugins/inputs/mock_Plugin.go @@ -1,4 +1,4 @@ -package plugins +package inputs import "github.com/stretchr/testify/mock" diff --git a/plugins/mongodb/mongodb.go b/plugins/inputs/mongodb/mongodb.go similarity index 93% rename from plugins/mongodb/mongodb.go rename to plugins/inputs/mongodb/mongodb.go index 40c77931a73c6..4cb3ffee56c6f 100644 --- a/plugins/mongodb/mongodb.go +++ b/plugins/inputs/mongodb/mongodb.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "gopkg.in/mgo.v2" ) @@ -45,7 +45,7 @@ var localhost = &url.URL{Host: "127.0.0.1:27017"} // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (m *MongoDB) Gather(acc plugins.Accumulator) error { +func (m *MongoDB) Gather(acc inputs.Accumulator) error { if len(m.Servers) == 0 { m.gatherServer(m.getMongoServer(localhost), acc) return nil @@ -88,7 +88,7 @@ func (m *MongoDB) getMongoServer(url *url.URL) *Server { return m.mongos[url.Host] } -func (m *MongoDB) gatherServer(server *Server, acc plugins.Accumulator) error { +func (m *MongoDB) gatherServer(server *Server, acc inputs.Accumulator) error { if server.Session == nil { var dialAddrs []string if server.Url.User != nil { @@ -138,7 +138,7 @@ func (m *MongoDB) gatherServer(server *Server, acc plugins.Accumulator) error { } func init() { - plugins.Add("mongodb", func() plugins.Plugin { + inputs.Add("mongodb", func() inputs.Input { return &MongoDB{ mongos: make(map[string]*Server), } diff --git a/plugins/mongodb/mongodb_data.go b/plugins/inputs/mongodb/mongodb_data.go similarity index 96% rename from plugins/mongodb/mongodb_data.go rename to plugins/inputs/mongodb/mongodb_data.go index 1ebb76ceda369..15f8c479b194d 100644 --- a/plugins/mongodb/mongodb_data.go +++ b/plugins/inputs/mongodb/mongodb_data.go @@ -5,7 +5,7 @@ import ( "reflect" "strconv" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type MongodbData struct { @@ -97,7 +97,7 @@ func (d *MongodbData) add(key string, val interface{}) { d.Fields[key] = val } -func (d *MongodbData) flush(acc plugins.Accumulator) { +func (d *MongodbData) flush(acc inputs.Accumulator) { acc.AddFields( "mongodb", d.Fields, diff --git a/plugins/mongodb/mongodb_data_test.go b/plugins/inputs/mongodb/mongodb_data_test.go similarity index 100% rename from plugins/mongodb/mongodb_data_test.go rename to plugins/inputs/mongodb/mongodb_data_test.go diff --git a/plugins/mongodb/mongodb_server.go b/plugins/inputs/mongodb/mongodb_server.go similarity index 90% rename from plugins/mongodb/mongodb_server.go rename to plugins/inputs/mongodb/mongodb_server.go index 134be5baeeda1..795cf97d7063a 100644 --- a/plugins/mongodb/mongodb_server.go +++ b/plugins/inputs/mongodb/mongodb_server.go @@ -4,7 +4,7 @@ import ( "net/url" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) @@ -21,7 +21,7 @@ func (s *Server) getDefaultTags() map[string]string { return tags } -func (s *Server) gatherData(acc plugins.Accumulator) error { +func (s *Server) gatherData(acc inputs.Accumulator) error { s.Session.SetMode(mgo.Eventual, true) s.Session.SetSocketTimeout(0) result := &ServerStatus{} diff --git a/plugins/mongodb/mongodb_server_test.go b/plugins/inputs/mongodb/mongodb_server_test.go similarity index 100% rename from plugins/mongodb/mongodb_server_test.go rename to plugins/inputs/mongodb/mongodb_server_test.go diff --git a/plugins/mongodb/mongodb_test.go b/plugins/inputs/mongodb/mongodb_test.go similarity index 100% rename from plugins/mongodb/mongodb_test.go rename to plugins/inputs/mongodb/mongodb_test.go diff --git a/plugins/mongodb/mongostat.go b/plugins/inputs/mongodb/mongostat.go similarity index 100% rename from plugins/mongodb/mongostat.go rename to plugins/inputs/mongodb/mongostat.go diff --git a/plugins/mysql/mysql.go b/plugins/inputs/mysql/mysql.go similarity index 94% rename from plugins/mysql/mysql.go rename to plugins/inputs/mysql/mysql.go index db99123ffae44..f9126b5ea853c 100644 --- a/plugins/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -6,7 +6,7 @@ import ( "strings" _ "github.com/go-sql-driver/mysql" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Mysql struct { @@ -35,7 +35,7 @@ func (m *Mysql) Description() string { var localhost = "" -func (m *Mysql) Gather(acc plugins.Accumulator) error { +func (m *Mysql) Gather(acc inputs.Accumulator) error { if len(m.Servers) == 0 { // if we can't get stats in this case, thats fine, don't report // an error. @@ -113,7 +113,7 @@ var mappings = []*mapping{ }, } -func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error { +func (m *Mysql) gatherServer(serv string, acc inputs.Accumulator) error { // If user forgot the '/', add it if strings.HasSuffix(serv, ")") { serv = serv + "/" @@ -207,7 +207,7 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error { } func init() { - plugins.Add("mysql", func() plugins.Plugin { + inputs.Add("mysql", func() inputs.Input { return &Mysql{} }) } diff --git a/plugins/mysql/mysql_test.go b/plugins/inputs/mysql/mysql_test.go similarity index 100% rename from plugins/mysql/mysql_test.go rename to plugins/inputs/mysql/mysql_test.go diff --git a/plugins/mysql/parse_dsn.go b/plugins/inputs/mysql/parse_dsn.go similarity index 100% rename from plugins/mysql/parse_dsn.go rename to plugins/inputs/mysql/parse_dsn.go diff --git a/plugins/nginx/nginx.go b/plugins/inputs/nginx/nginx.go similarity index 93% rename from plugins/nginx/nginx.go rename to plugins/inputs/nginx/nginx.go index 5d7aace2a717a..18e3244f700e6 100644 --- a/plugins/nginx/nginx.go +++ b/plugins/inputs/nginx/nginx.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Nginx struct { @@ -31,7 +31,7 @@ func (n *Nginx) Description() string { return "Read Nginx's basic status information (ngx_http_stub_status_module)" } -func (n *Nginx) Gather(acc plugins.Accumulator) error { +func (n *Nginx) Gather(acc inputs.Accumulator) error { var wg sync.WaitGroup var outerr error @@ -59,7 +59,7 @@ var tr = &http.Transport{ var client = &http.Client{Transport: tr} -func (n *Nginx) gatherUrl(addr *url.URL, acc plugins.Accumulator) error { +func (n *Nginx) gatherUrl(addr *url.URL, acc inputs.Accumulator) error { resp, err := client.Get(addr.String()) if err != nil { return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err) @@ -159,7 +159,7 @@ func getTags(addr *url.URL) map[string]string { } func init() { - plugins.Add("nginx", func() plugins.Plugin { + inputs.Add("nginx", func() inputs.Input { return &Nginx{} }) } diff --git a/plugins/nginx/nginx_test.go b/plugins/inputs/nginx/nginx_test.go similarity index 100% rename from plugins/nginx/nginx_test.go rename to plugins/inputs/nginx/nginx_test.go diff --git a/plugins/phpfpm/README.md b/plugins/inputs/phpfpm/README.md similarity index 98% rename from plugins/phpfpm/README.md rename to plugins/inputs/phpfpm/README.md index d2e52534c870f..c2a42523a177f 100644 --- a/plugins/phpfpm/README.md +++ b/plugins/inputs/phpfpm/README.md @@ -43,7 +43,7 @@ Using this configuration: When run with: ``` -./telegraf -config telegraf.conf -filter phpfpm -test +./telegraf -config telegraf.conf -input-filter phpfpm -test ``` It produces: diff --git a/plugins/phpfpm/phpfpm.go b/plugins/inputs/phpfpm/phpfpm.go similarity index 94% rename from plugins/phpfpm/phpfpm.go rename to plugins/inputs/phpfpm/phpfpm.go index 2f2164913b4d5..ceffc673eaccc 100644 --- a/plugins/phpfpm/phpfpm.go +++ b/plugins/inputs/phpfpm/phpfpm.go @@ -11,7 +11,7 @@ import ( "strings" "sync" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) const ( @@ -67,7 +67,7 @@ func (r *phpfpm) Description() string { // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (g *phpfpm) Gather(acc plugins.Accumulator) error { +func (g *phpfpm) Gather(acc inputs.Accumulator) error { if len(g.Urls) == 0 { return g.gatherServer("http://127.0.0.1/status", acc) } @@ -90,7 +90,7 @@ func (g *phpfpm) Gather(acc plugins.Accumulator) error { } // Request status page to get stat raw data -func (g *phpfpm) gatherServer(addr string, acc plugins.Accumulator) error { +func (g *phpfpm) gatherServer(addr string, acc inputs.Accumulator) error { if g.client == nil { client := &http.Client{} @@ -153,7 +153,7 @@ func (g *phpfpm) gatherServer(addr string, acc plugins.Accumulator) error { } // Import HTTP stat data into Telegraf system -func importMetric(r io.Reader, acc plugins.Accumulator, host string) (poolStat, error) { +func importMetric(r io.Reader, acc inputs.Accumulator, host string) (poolStat, error) { stats := make(poolStat) var currentPool string @@ -209,7 +209,7 @@ func importMetric(r io.Reader, acc plugins.Accumulator, host string) (poolStat, } func init() { - plugins.Add("phpfpm", func() plugins.Plugin { + inputs.Add("phpfpm", func() inputs.Input { return &phpfpm{} }) } diff --git a/plugins/phpfpm/phpfpm_fcgi.go b/plugins/inputs/phpfpm/phpfpm_fcgi.go similarity index 100% rename from plugins/phpfpm/phpfpm_fcgi.go rename to plugins/inputs/phpfpm/phpfpm_fcgi.go diff --git a/plugins/phpfpm/phpfpm_test.go b/plugins/inputs/phpfpm/phpfpm_test.go similarity index 100% rename from plugins/phpfpm/phpfpm_test.go rename to plugins/inputs/phpfpm/phpfpm_test.go diff --git a/plugins/ping/ping.go b/plugins/inputs/ping/ping.go similarity index 96% rename from plugins/ping/ping.go rename to plugins/inputs/ping/ping.go index 72eee91add273..e03fc71e8bfa0 100644 --- a/plugins/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) // HostPinger is a function that runs the "ping" function using a list of @@ -56,7 +56,7 @@ func (_ *Ping) SampleConfig() string { return sampleConfig } -func (p *Ping) Gather(acc plugins.Accumulator) error { +func (p *Ping) Gather(acc inputs.Accumulator) error { var wg sync.WaitGroup errorChannel := make(chan error, len(p.Urls)*2) @@ -64,7 +64,7 @@ func (p *Ping) Gather(acc plugins.Accumulator) error { // Spin off a go routine for each url to ping for _, url := range p.Urls { wg.Add(1) - go func(url string, acc plugins.Accumulator) { + go func(url string, acc inputs.Accumulator) { defer wg.Done() args := p.args(url) out, err := p.pingHost(args...) @@ -174,7 +174,7 @@ func processPingOutput(out string) (int, int, float64, error) { } func init() { - plugins.Add("ping", func() plugins.Plugin { + inputs.Add("ping", func() inputs.Input { return &Ping{pingHost: hostPinger} }) } diff --git a/plugins/ping/ping_test.go b/plugins/inputs/ping/ping_test.go similarity index 100% rename from plugins/ping/ping_test.go rename to plugins/inputs/ping/ping_test.go diff --git a/plugins/postgresql/README.md b/plugins/inputs/postgresql/README.md similarity index 100% rename from plugins/postgresql/README.md rename to plugins/inputs/postgresql/README.md diff --git a/plugins/postgresql/postgresql.go b/plugins/inputs/postgresql/postgresql.go similarity index 93% rename from plugins/postgresql/postgresql.go rename to plugins/inputs/postgresql/postgresql.go index eaefadb504877..c356cea7758cf 100644 --- a/plugins/postgresql/postgresql.go +++ b/plugins/inputs/postgresql/postgresql.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" _ "github.com/lib/pq" ) @@ -53,7 +53,7 @@ func (p *Postgresql) IgnoredColumns() map[string]bool { var localhost = "host=localhost sslmode=disable" -func (p *Postgresql) Gather(acc plugins.Accumulator) error { +func (p *Postgresql) Gather(acc inputs.Accumulator) error { var query string if p.Address == "" || p.Address == "localhost" { @@ -101,7 +101,7 @@ type scanner interface { Scan(dest ...interface{}) error } -func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error { +func (p *Postgresql) accRow(row scanner, acc inputs.Accumulator) error { var columnVars []interface{} var dbname bytes.Buffer @@ -145,7 +145,7 @@ func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error { } func init() { - plugins.Add("postgresql", func() plugins.Plugin { + inputs.Add("postgresql", func() inputs.Input { return &Postgresql{} }) } diff --git a/plugins/postgresql/postgresql_test.go b/plugins/inputs/postgresql/postgresql_test.go similarity index 100% rename from plugins/postgresql/postgresql_test.go rename to plugins/inputs/postgresql/postgresql_test.go diff --git a/plugins/procstat/README.md b/plugins/inputs/procstat/README.md similarity index 100% rename from plugins/procstat/README.md rename to plugins/inputs/procstat/README.md diff --git a/plugins/procstat/procstat.go b/plugins/inputs/procstat/procstat.go similarity index 95% rename from plugins/procstat/procstat.go rename to plugins/inputs/procstat/procstat.go index 2f171db3ea13f..5e596d6d8c4c4 100644 --- a/plugins/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -10,7 +10,7 @@ import ( "github.com/shirou/gopsutil/process" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Procstat struct { @@ -45,7 +45,7 @@ func (_ *Procstat) Description() string { return "Monitor process cpu and memory usage" } -func (p *Procstat) Gather(acc plugins.Accumulator) error { +func (p *Procstat) Gather(acc inputs.Accumulator) error { procs, err := p.createProcesses() if err != nil { log.Printf("Error: procstat getting process, exe: [%s] pidfile: [%s] pattern: [%s] %s", @@ -161,7 +161,7 @@ func pidsFromPattern(pattern string) ([]int32, error) { } func init() { - plugins.Add("procstat", func() plugins.Plugin { + inputs.Add("procstat", func() inputs.Input { return NewProcstat() }) } diff --git a/plugins/procstat/procstat_test.go b/plugins/inputs/procstat/procstat_test.go similarity index 100% rename from plugins/procstat/procstat_test.go rename to plugins/inputs/procstat/procstat_test.go diff --git a/plugins/procstat/spec_processor.go b/plugins/inputs/procstat/spec_processor.go similarity index 96% rename from plugins/procstat/spec_processor.go rename to plugins/inputs/procstat/spec_processor.go index a61152c9b171a..9c7e53826f81f 100644 --- a/plugins/procstat/spec_processor.go +++ b/plugins/inputs/procstat/spec_processor.go @@ -6,14 +6,14 @@ import ( "github.com/shirou/gopsutil/process" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type SpecProcessor struct { Prefix string tags map[string]string fields map[string]interface{} - acc plugins.Accumulator + acc inputs.Accumulator proc *process.Process } @@ -34,7 +34,7 @@ func (p *SpecProcessor) flush() { func NewSpecProcessor( prefix string, - acc plugins.Accumulator, + acc inputs.Accumulator, p *process.Process, ) *SpecProcessor { tags := make(map[string]string) diff --git a/plugins/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go similarity index 89% rename from plugins/prometheus/prometheus.go rename to plugins/inputs/prometheus/prometheus.go index 2742393c79aca..758788b8d84bc 100644 --- a/plugins/prometheus/prometheus.go +++ b/plugins/inputs/prometheus/prometheus.go @@ -3,7 +3,7 @@ package prometheus import ( "errors" "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "github.com/prometheus/common/expfmt" "github.com/prometheus/common/model" "io" @@ -32,7 +32,7 @@ var ErrProtocolError = errors.New("prometheus protocol error") // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (g *Prometheus) Gather(acc plugins.Accumulator) error { +func (g *Prometheus) Gather(acc inputs.Accumulator) error { var wg sync.WaitGroup var outerr error @@ -50,7 +50,7 @@ func (g *Prometheus) Gather(acc plugins.Accumulator) error { return outerr } -func (g *Prometheus) gatherURL(url string, acc plugins.Accumulator) error { +func (g *Prometheus) gatherURL(url string, acc inputs.Accumulator) error { resp, err := http.Get(url) if err != nil { return fmt.Errorf("error making HTTP request to %s: %s", url, err) @@ -97,7 +97,7 @@ func (g *Prometheus) gatherURL(url string, acc plugins.Accumulator) error { } func init() { - plugins.Add("prometheus", func() plugins.Plugin { + inputs.Add("prometheus", func() inputs.Input { return &Prometheus{} }) } diff --git a/plugins/prometheus/prometheus_test.go b/plugins/inputs/prometheus/prometheus_test.go similarity index 100% rename from plugins/prometheus/prometheus_test.go rename to plugins/inputs/prometheus/prometheus_test.go diff --git a/plugins/puppetagent/README.md b/plugins/inputs/puppetagent/README.md similarity index 100% rename from plugins/puppetagent/README.md rename to plugins/inputs/puppetagent/README.md diff --git a/plugins/puppetagent/last_run_summary.yaml b/plugins/inputs/puppetagent/last_run_summary.yaml similarity index 100% rename from plugins/puppetagent/last_run_summary.yaml rename to plugins/inputs/puppetagent/last_run_summary.yaml diff --git a/plugins/puppetagent/puppetagent.go b/plugins/inputs/puppetagent/puppetagent.go similarity index 92% rename from plugins/puppetagent/puppetagent.go rename to plugins/inputs/puppetagent/puppetagent.go index 8939e59631ee1..d0bedae9e8aaf 100644 --- a/plugins/puppetagent/puppetagent.go +++ b/plugins/inputs/puppetagent/puppetagent.go @@ -8,7 +8,7 @@ import ( "reflect" "strings" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) // PuppetAgent is a PuppetAgent plugin @@ -82,7 +82,7 @@ func (pa *PuppetAgent) Description() string { } // Gather reads stats from all configured servers accumulates stats -func (pa *PuppetAgent) Gather(acc plugins.Accumulator) error { +func (pa *PuppetAgent) Gather(acc inputs.Accumulator) error { if len(pa.Location) == 0 { pa.Location = "/var/lib/puppet/state/last_run_summary.yaml" @@ -110,7 +110,7 @@ func (pa *PuppetAgent) Gather(acc plugins.Accumulator) error { return nil } -func structPrinter(s *State, acc plugins.Accumulator, tags map[string]string) { +func structPrinter(s *State, acc inputs.Accumulator, tags map[string]string) { e := reflect.ValueOf(s).Elem() fields := make(map[string]interface{}) @@ -131,7 +131,7 @@ func structPrinter(s *State, acc plugins.Accumulator, tags map[string]string) { } func init() { - plugins.Add("puppetagent", func() plugins.Plugin { + inputs.Add("puppetagent", func() inputs.Input { return &PuppetAgent{} }) } diff --git a/plugins/puppetagent/puppetagent_test.go b/plugins/inputs/puppetagent/puppetagent_test.go similarity index 100% rename from plugins/puppetagent/puppetagent_test.go rename to plugins/inputs/puppetagent/puppetagent_test.go diff --git a/plugins/rabbitmq/rabbitmq.go b/plugins/inputs/rabbitmq/rabbitmq.go similarity index 94% rename from plugins/rabbitmq/rabbitmq.go rename to plugins/inputs/rabbitmq/rabbitmq.go index 227811bc865d9..fc95af4941b42 100644 --- a/plugins/rabbitmq/rabbitmq.go +++ b/plugins/inputs/rabbitmq/rabbitmq.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) const DefaultUsername = "guest" @@ -91,7 +91,7 @@ type Node struct { SocketsUsed int64 `json:"sockets_used"` } -type gatherFunc func(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) +type gatherFunc func(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) var gatherFunctions = []gatherFunc{gatherOverview, gatherNodes, gatherQueues} @@ -114,7 +114,7 @@ func (r *RabbitMQ) Description() string { return "Read metrics from one or many RabbitMQ servers via the management API" } -func (r *RabbitMQ) Gather(acc plugins.Accumulator) error { +func (r *RabbitMQ) Gather(acc inputs.Accumulator) error { if r.Client == nil { r.Client = &http.Client{} } @@ -167,7 +167,7 @@ func (r *RabbitMQ) requestJSON(u string, target interface{}) error { return nil } -func gatherOverview(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) { +func gatherOverview(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) { overview := &OverviewResponse{} err := r.requestJSON("/api/overview", &overview) @@ -203,7 +203,7 @@ func gatherOverview(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) { errChan <- nil } -func gatherNodes(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) { +func gatherNodes(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) { nodes := make([]Node, 0) // Gather information about nodes err := r.requestJSON("/api/nodes", &nodes) @@ -240,7 +240,7 @@ func gatherNodes(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) { errChan <- nil } -func gatherQueues(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) { +func gatherQueues(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) { // Gather information about queues queues := make([]Queue, 0) err := r.requestJSON("/api/queues", &queues) @@ -320,7 +320,7 @@ func (r *RabbitMQ) shouldGatherQueue(queue Queue) bool { } func init() { - plugins.Add("rabbitmq", func() plugins.Plugin { + inputs.Add("rabbitmq", func() inputs.Input { return &RabbitMQ{} }) } diff --git a/plugins/rabbitmq/rabbitmq_test.go b/plugins/inputs/rabbitmq/rabbitmq_test.go similarity index 100% rename from plugins/rabbitmq/rabbitmq_test.go rename to plugins/inputs/rabbitmq/rabbitmq_test.go diff --git a/plugins/redis/redis.go b/plugins/inputs/redis/redis.go similarity index 95% rename from plugins/redis/redis.go rename to plugins/inputs/redis/redis.go index 2e338ff19b338..c9e98e88672b8 100644 --- a/plugins/redis/redis.go +++ b/plugins/inputs/redis/redis.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Redis struct { @@ -76,7 +76,7 @@ var ErrProtocolError = errors.New("redis protocol error") // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (r *Redis) Gather(acc plugins.Accumulator) error { +func (r *Redis) Gather(acc inputs.Accumulator) error { if len(r.Servers) == 0 { url := &url.URL{ Host: ":6379", @@ -113,7 +113,7 @@ func (r *Redis) Gather(acc plugins.Accumulator) error { const defaultPort = "6379" -func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error { +func (r *Redis) gatherServer(addr *url.URL, acc inputs.Accumulator) error { _, _, err := net.SplitHostPort(addr.Host) if err != nil { addr.Host = addr.Host + ":" + defaultPort @@ -158,7 +158,7 @@ func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error { // gatherInfoOutput gathers func gatherInfoOutput( rdr *bufio.Reader, - acc plugins.Accumulator, + acc inputs.Accumulator, tags map[string]string, ) error { var keyspace_hits, keyspace_misses uint64 = 0, 0 @@ -227,7 +227,7 @@ func gatherInfoOutput( func gatherKeyspaceLine( name string, line string, - acc plugins.Accumulator, + acc inputs.Accumulator, tags map[string]string, ) { if strings.Contains(line, "keys=") { @@ -246,7 +246,7 @@ func gatherKeyspaceLine( } func init() { - plugins.Add("redis", func() plugins.Plugin { + inputs.Add("redis", func() inputs.Input { return &Redis{} }) } diff --git a/plugins/redis/redis_test.go b/plugins/inputs/redis/redis_test.go similarity index 100% rename from plugins/redis/redis_test.go rename to plugins/inputs/redis/redis_test.go diff --git a/plugins/registry.go b/plugins/inputs/registry.go similarity index 64% rename from plugins/registry.go rename to plugins/inputs/registry.go index 3e544917d4f6d..2b99078f0251e 100644 --- a/plugins/registry.go +++ b/plugins/inputs/registry.go @@ -1,4 +1,4 @@ -package plugins +package inputs import "time" @@ -17,40 +17,40 @@ type Accumulator interface { t ...time.Time) } -type Plugin interface { - // SampleConfig returns the default configuration of the Plugin +type Input interface { + // SampleConfig returns the default configuration of the Input SampleConfig() string - // Description returns a one-sentence description on the Plugin + // Description returns a one-sentence description on the Input Description() string - // Gather takes in an accumulator and adds the metrics that the Plugin + // Gather takes in an accumulator and adds the metrics that the Input // gathers. This is called every "interval" Gather(Accumulator) error } -type ServicePlugin interface { - // SampleConfig returns the default configuration of the Plugin +type ServiceInput interface { + // SampleConfig returns the default configuration of the Input SampleConfig() string - // Description returns a one-sentence description on the Plugin + // Description returns a one-sentence description on the Input Description() string - // Gather takes in an accumulator and adds the metrics that the Plugin + // Gather takes in an accumulator and adds the metrics that the Input // gathers. This is called every "interval" Gather(Accumulator) error - // Start starts the ServicePlugin's service, whatever that may be + // Start starts the ServiceInput's service, whatever that may be Start() error // Stop stops the services and closes any necessary channels and connections Stop() } -type Creator func() Plugin +type Creator func() Input -var Plugins = map[string]Creator{} +var Inputs = map[string]Creator{} func Add(name string, creator Creator) { - Plugins[name] = creator + Inputs[name] = creator } diff --git a/plugins/rethinkdb/rethinkdb.go b/plugins/inputs/rethinkdb/rethinkdb.go similarity index 89% rename from plugins/rethinkdb/rethinkdb.go rename to plugins/inputs/rethinkdb/rethinkdb.go index 8af8906618846..17873f1ced98c 100644 --- a/plugins/rethinkdb/rethinkdb.go +++ b/plugins/inputs/rethinkdb/rethinkdb.go @@ -5,7 +5,7 @@ import ( "net/url" "sync" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "gopkg.in/dancannon/gorethink.v1" ) @@ -35,7 +35,7 @@ var localhost = &Server{Url: &url.URL{Host: "127.0.0.1:28015"}} // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). -func (r *RethinkDB) Gather(acc plugins.Accumulator) error { +func (r *RethinkDB) Gather(acc inputs.Accumulator) error { if len(r.Servers) == 0 { r.gatherServer(localhost, acc) return nil @@ -65,7 +65,7 @@ func (r *RethinkDB) Gather(acc plugins.Accumulator) error { return outerr } -func (r *RethinkDB) gatherServer(server *Server, acc plugins.Accumulator) error { +func (r *RethinkDB) gatherServer(server *Server, acc inputs.Accumulator) error { var err error connectOpts := gorethink.ConnectOpts{ Address: server.Url.Host, @@ -87,7 +87,7 @@ func (r *RethinkDB) gatherServer(server *Server, acc plugins.Accumulator) error } func init() { - plugins.Add("rethinkdb", func() plugins.Plugin { + inputs.Add("rethinkdb", func() inputs.Input { return &RethinkDB{} }) } diff --git a/plugins/rethinkdb/rethinkdb_data.go b/plugins/inputs/rethinkdb/rethinkdb_data.go similarity index 95% rename from plugins/rethinkdb/rethinkdb_data.go rename to plugins/inputs/rethinkdb/rethinkdb_data.go index 59abd83ba9df2..3ea429d82af98 100644 --- a/plugins/rethinkdb/rethinkdb_data.go +++ b/plugins/inputs/rethinkdb/rethinkdb_data.go @@ -4,7 +4,7 @@ import ( "reflect" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type serverStatus struct { @@ -88,7 +88,7 @@ var engineStats = map[string]string{ func (e *Engine) AddEngineStats( keys []string, - acc plugins.Accumulator, + acc inputs.Accumulator, tags map[string]string, ) { engine := reflect.ValueOf(e).Elem() @@ -99,7 +99,7 @@ func (e *Engine) AddEngineStats( acc.AddFields("rethinkdb_engine", fields, tags) } -func (s *Storage) AddStats(acc plugins.Accumulator, tags map[string]string) { +func (s *Storage) AddStats(acc inputs.Accumulator, tags map[string]string) { fields := map[string]interface{}{ "cache_bytes_in_use": s.Cache.BytesInUse, "disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec, diff --git a/plugins/rethinkdb/rethinkdb_data_test.go b/plugins/inputs/rethinkdb/rethinkdb_data_test.go similarity index 100% rename from plugins/rethinkdb/rethinkdb_data_test.go rename to plugins/inputs/rethinkdb/rethinkdb_data_test.go diff --git a/plugins/rethinkdb/rethinkdb_server.go b/plugins/inputs/rethinkdb/rethinkdb_server.go similarity index 94% rename from plugins/rethinkdb/rethinkdb_server.go rename to plugins/inputs/rethinkdb/rethinkdb_server.go index 9285068bd7e13..4af916a4d162e 100644 --- a/plugins/rethinkdb/rethinkdb_server.go +++ b/plugins/inputs/rethinkdb/rethinkdb_server.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "gopkg.in/dancannon/gorethink.v1" ) @@ -20,7 +20,7 @@ type Server struct { serverStatus serverStatus } -func (s *Server) gatherData(acc plugins.Accumulator) error { +func (s *Server) gatherData(acc inputs.Accumulator) error { if err := s.getServerStatus(); err != nil { return fmt.Errorf("Failed to get server_status, %s\n", err) } @@ -110,7 +110,7 @@ var ClusterTracking = []string{ "written_docs_per_sec", } -func (s *Server) addClusterStats(acc plugins.Accumulator) error { +func (s *Server) addClusterStats(acc inputs.Accumulator) error { cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"cluster"}).Run(s.session) if err != nil { return fmt.Errorf("cluster stats query error, %s\n", err.Error()) @@ -138,7 +138,7 @@ var MemberTracking = []string{ "total_writes", } -func (s *Server) addMemberStats(acc plugins.Accumulator) error { +func (s *Server) addMemberStats(acc inputs.Accumulator) error { cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"server", s.serverStatus.Id}).Run(s.session) if err != nil { return fmt.Errorf("member stats query error, %s\n", err.Error()) @@ -162,7 +162,7 @@ var TableTracking = []string{ "total_writes", } -func (s *Server) addTableStats(acc plugins.Accumulator) error { +func (s *Server) addTableStats(acc inputs.Accumulator) error { tablesCursor, err := gorethink.DB("rethinkdb").Table("table_status").Run(s.session) defer tablesCursor.Close() var tables []tableStatus diff --git a/plugins/rethinkdb/rethinkdb_server_test.go b/plugins/inputs/rethinkdb/rethinkdb_server_test.go similarity index 100% rename from plugins/rethinkdb/rethinkdb_server_test.go rename to plugins/inputs/rethinkdb/rethinkdb_server_test.go diff --git a/plugins/rethinkdb/rethinkdb_test.go b/plugins/inputs/rethinkdb/rethinkdb_test.go similarity index 100% rename from plugins/rethinkdb/rethinkdb_test.go rename to plugins/inputs/rethinkdb/rethinkdb_test.go diff --git a/plugins/statsd/README.md b/plugins/inputs/statsd/README.md similarity index 100% rename from plugins/statsd/README.md rename to plugins/inputs/statsd/README.md diff --git a/plugins/statsd/running_stats.go b/plugins/inputs/statsd/running_stats.go similarity index 100% rename from plugins/statsd/running_stats.go rename to plugins/inputs/statsd/running_stats.go diff --git a/plugins/statsd/running_stats_test.go b/plugins/inputs/statsd/running_stats_test.go similarity index 100% rename from plugins/statsd/running_stats_test.go rename to plugins/inputs/statsd/running_stats_test.go diff --git a/plugins/statsd/statsd.go b/plugins/inputs/statsd/statsd.go similarity index 98% rename from plugins/statsd/statsd.go rename to plugins/inputs/statsd/statsd.go index bd86a56d709e7..d210b55fa8413 100644 --- a/plugins/statsd/statsd.go +++ b/plugins/inputs/statsd/statsd.go @@ -12,7 +12,7 @@ import ( "github.com/influxdb/influxdb/services/graphite" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) var dropwarn = "ERROR: Message queue full. Discarding line [%s] " + @@ -139,7 +139,7 @@ func (_ *Statsd) SampleConfig() string { return sampleConfig } -func (s *Statsd) Gather(acc plugins.Accumulator) error { +func (s *Statsd) Gather(acc inputs.Accumulator) error { s.Lock() defer s.Unlock() @@ -490,7 +490,7 @@ func (s *Statsd) Stop() { } func init() { - plugins.Add("statsd", func() plugins.Plugin { + inputs.Add("statsd", func() inputs.Input { return &Statsd{} }) } diff --git a/plugins/statsd/statsd_test.go b/plugins/inputs/statsd/statsd_test.go similarity index 100% rename from plugins/statsd/statsd_test.go rename to plugins/inputs/statsd/statsd_test.go diff --git a/plugins/system/CPU_README.md b/plugins/inputs/system/CPU_README.md similarity index 100% rename from plugins/system/CPU_README.md rename to plugins/inputs/system/CPU_README.md diff --git a/plugins/system/MEM_README.md b/plugins/inputs/system/MEM_README.md similarity index 100% rename from plugins/system/MEM_README.md rename to plugins/inputs/system/MEM_README.md diff --git a/plugins/system/NETSTAT_README.md b/plugins/inputs/system/NETSTAT_README.md similarity index 100% rename from plugins/system/NETSTAT_README.md rename to plugins/inputs/system/NETSTAT_README.md diff --git a/plugins/system/cpu.go b/plugins/inputs/system/cpu.go similarity index 95% rename from plugins/system/cpu.go rename to plugins/inputs/system/cpu.go index 24350fc6c986a..298df20bbcd21 100644 --- a/plugins/system/cpu.go +++ b/plugins/inputs/system/cpu.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" "github.com/shirou/gopsutil/cpu" ) @@ -39,7 +39,7 @@ func (_ *CPUStats) SampleConfig() string { return sampleConfig } -func (s *CPUStats) Gather(acc plugins.Accumulator) error { +func (s *CPUStats) Gather(acc inputs.Accumulator) error { times, err := s.ps.CPUTimes(s.PerCPU, s.TotalCPU) if err != nil { return fmt.Errorf("error getting CPU info: %s", err) @@ -111,7 +111,7 @@ func totalCpuTime(t cpu.CPUTimesStat) float64 { } func init() { - plugins.Add("cpu", func() plugins.Plugin { + inputs.Add("cpu", func() inputs.Input { return &CPUStats{ps: &systemPS{}} }) } diff --git a/plugins/system/cpu_test.go b/plugins/inputs/system/cpu_test.go similarity index 100% rename from plugins/system/cpu_test.go rename to plugins/inputs/system/cpu_test.go diff --git a/plugins/system/disk.go b/plugins/inputs/system/disk.go similarity index 91% rename from plugins/system/disk.go rename to plugins/inputs/system/disk.go index 410044d2cdffa..5d1553dd46263 100644 --- a/plugins/system/disk.go +++ b/plugins/inputs/system/disk.go @@ -3,7 +3,7 @@ package system import ( "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type DiskStats struct { @@ -26,7 +26,7 @@ func (_ *DiskStats) SampleConfig() string { return diskSampleConfig } -func (s *DiskStats) Gather(acc plugins.Accumulator) error { +func (s *DiskStats) Gather(acc inputs.Accumulator) error { disks, err := s.ps.DiskUsage() if err != nil { return fmt.Errorf("error getting disk usage info: %s", err) @@ -88,7 +88,7 @@ func (_ *DiskIOStats) SampleConfig() string { return diskIoSampleConfig } -func (s *DiskIOStats) Gather(acc plugins.Accumulator) error { +func (s *DiskIOStats) Gather(acc inputs.Accumulator) error { diskio, err := s.ps.DiskIO() if err != nil { return fmt.Errorf("error getting disk io info: %s", err) @@ -134,11 +134,11 @@ func (s *DiskIOStats) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("disk", func() plugins.Plugin { + inputs.Add("disk", func() inputs.Input { return &DiskStats{ps: &systemPS{}} }) - plugins.Add("diskio", func() plugins.Plugin { + inputs.Add("diskio", func() inputs.Input { return &DiskIOStats{ps: &systemPS{}} }) } diff --git a/plugins/system/disk_test.go b/plugins/inputs/system/disk_test.go similarity index 100% rename from plugins/system/disk_test.go rename to plugins/inputs/system/disk_test.go diff --git a/plugins/system/docker.go b/plugins/inputs/system/docker.go similarity index 94% rename from plugins/system/docker.go rename to plugins/inputs/system/docker.go index 2d6146a595b13..3a77fad5f69c0 100644 --- a/plugins/system/docker.go +++ b/plugins/inputs/system/docker.go @@ -5,7 +5,7 @@ package system import ( "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type DockerStats struct { @@ -18,7 +18,7 @@ func (_ *DockerStats) Description() string { func (_ *DockerStats) SampleConfig() string { return "" } -func (s *DockerStats) Gather(acc plugins.Accumulator) error { +func (s *DockerStats) Gather(acc inputs.Accumulator) error { containers, err := s.ps.DockerStat() if err != nil { return fmt.Errorf("error getting docker info: %s", err) @@ -83,7 +83,7 @@ func (s *DockerStats) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("docker", func() plugins.Plugin { + inputs.Add("docker", func() inputs.Input { return &DockerStats{ps: &systemPS{}} }) } diff --git a/plugins/system/docker_test.go b/plugins/inputs/system/docker_test.go similarity index 100% rename from plugins/system/docker_test.go rename to plugins/inputs/system/docker_test.go diff --git a/plugins/system/memory.go b/plugins/inputs/system/memory.go similarity index 85% rename from plugins/system/memory.go rename to plugins/inputs/system/memory.go index 23ce9460877d5..f58a8cd9245dc 100644 --- a/plugins/system/memory.go +++ b/plugins/inputs/system/memory.go @@ -3,7 +3,7 @@ package system import ( "fmt" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type MemStats struct { @@ -16,7 +16,7 @@ func (_ *MemStats) Description() string { func (_ *MemStats) SampleConfig() string { return "" } -func (s *MemStats) Gather(acc plugins.Accumulator) error { +func (s *MemStats) Gather(acc inputs.Accumulator) error { vm, err := s.ps.VMStat() if err != nil { return fmt.Errorf("error getting virtual memory info: %s", err) @@ -47,7 +47,7 @@ func (_ *SwapStats) Description() string { func (_ *SwapStats) SampleConfig() string { return "" } -func (s *SwapStats) Gather(acc plugins.Accumulator) error { +func (s *SwapStats) Gather(acc inputs.Accumulator) error { swap, err := s.ps.SwapStat() if err != nil { return fmt.Errorf("error getting swap memory info: %s", err) @@ -67,11 +67,11 @@ func (s *SwapStats) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("mem", func() plugins.Plugin { + inputs.Add("mem", func() inputs.Input { return &MemStats{ps: &systemPS{}} }) - plugins.Add("swap", func() plugins.Plugin { + inputs.Add("swap", func() inputs.Input { return &SwapStats{ps: &systemPS{}} }) } diff --git a/plugins/system/memory_test.go b/plugins/inputs/system/memory_test.go similarity index 100% rename from plugins/system/memory_test.go rename to plugins/inputs/system/memory_test.go diff --git a/plugins/system/mock_PS.go b/plugins/inputs/system/mock_PS.go similarity index 100% rename from plugins/system/mock_PS.go rename to plugins/inputs/system/mock_PS.go diff --git a/plugins/system/net.go b/plugins/inputs/system/net.go similarity index 93% rename from plugins/system/net.go rename to plugins/inputs/system/net.go index 72c450222c409..95df7a741ab94 100644 --- a/plugins/system/net.go +++ b/plugins/inputs/system/net.go @@ -5,7 +5,7 @@ import ( "net" "strings" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type NetIOStats struct { @@ -31,7 +31,7 @@ func (_ *NetIOStats) SampleConfig() string { return netSampleConfig } -func (s *NetIOStats) Gather(acc plugins.Accumulator) error { +func (s *NetIOStats) Gather(acc inputs.Accumulator) error { netio, err := s.ps.NetIO() if err != nil { return fmt.Errorf("error getting net io info: %s", err) @@ -100,7 +100,7 @@ func (s *NetIOStats) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("net", func() plugins.Plugin { + inputs.Add("net", func() inputs.Input { return &NetIOStats{ps: &systemPS{}} }) } diff --git a/plugins/system/net_test.go b/plugins/inputs/system/net_test.go similarity index 100% rename from plugins/system/net_test.go rename to plugins/inputs/system/net_test.go diff --git a/plugins/system/netstat.go b/plugins/inputs/system/netstat.go similarity index 90% rename from plugins/system/netstat.go rename to plugins/inputs/system/netstat.go index bd28971bcc7bd..71f2a0da6a1e6 100644 --- a/plugins/system/netstat.go +++ b/plugins/inputs/system/netstat.go @@ -4,7 +4,7 @@ import ( "fmt" "syscall" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type NetStats struct { @@ -21,7 +21,7 @@ func (_ *NetStats) SampleConfig() string { return tcpstatSampleConfig } -func (s *NetStats) Gather(acc plugins.Accumulator) error { +func (s *NetStats) Gather(acc inputs.Accumulator) error { netconns, err := s.ps.NetConnections() if err != nil { return fmt.Errorf("error getting net connections info: %s", err) @@ -64,7 +64,7 @@ func (s *NetStats) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("netstat", func() plugins.Plugin { + inputs.Add("netstat", func() inputs.Input { return &NetStats{ps: &systemPS{}} }) } diff --git a/plugins/system/ps.go b/plugins/inputs/system/ps.go similarity index 97% rename from plugins/system/ps.go rename to plugins/inputs/system/ps.go index d0c35c62cb833..9667477189bf6 100644 --- a/plugins/system/ps.go +++ b/plugins/inputs/system/ps.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" dc "github.com/fsouza/go-dockerclient" "github.com/shirou/gopsutil/cpu" @@ -37,7 +37,7 @@ type PS interface { NetConnections() ([]net.NetConnectionStat, error) } -func add(acc plugins.Accumulator, +func add(acc inputs.Accumulator, name string, val float64, tags map[string]string) { if val >= 0 { acc.Add(name, val, tags) diff --git a/plugins/system/system.go b/plugins/inputs/system/system.go similarity index 88% rename from plugins/system/system.go rename to plugins/inputs/system/system.go index 1adf6c051098c..813ab84f563f1 100644 --- a/plugins/system/system.go +++ b/plugins/inputs/system/system.go @@ -8,7 +8,7 @@ import ( "github.com/shirou/gopsutil/host" "github.com/shirou/gopsutil/load" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type SystemStats struct{} @@ -19,7 +19,7 @@ func (_ *SystemStats) Description() string { func (_ *SystemStats) SampleConfig() string { return "" } -func (_ *SystemStats) Gather(acc plugins.Accumulator) error { +func (_ *SystemStats) Gather(acc inputs.Accumulator) error { loadavg, err := load.LoadAvg() if err != nil { return err @@ -68,7 +68,7 @@ func format_uptime(uptime uint64) string { } func init() { - plugins.Add("system", func() plugins.Plugin { + inputs.Add("system", func() inputs.Input { return &SystemStats{} }) } diff --git a/plugins/trig/trig.go b/plugins/inputs/trig/trig.go similarity index 79% rename from plugins/trig/trig.go rename to plugins/inputs/trig/trig.go index 7ed2bf3d9651b..13c44e247846f 100644 --- a/plugins/trig/trig.go +++ b/plugins/inputs/trig/trig.go @@ -3,7 +3,7 @@ package trig import ( "math" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Trig struct { @@ -24,7 +24,7 @@ func (s *Trig) Description() string { return "Inserts sine and cosine waves for demonstration purposes" } -func (s *Trig) Gather(acc plugins.Accumulator) error { +func (s *Trig) Gather(acc inputs.Accumulator) error { sinner := math.Sin((s.x*math.Pi)/5.0) * s.Amplitude cosinner := math.Cos((s.x*math.Pi)/5.0) * s.Amplitude @@ -41,5 +41,5 @@ func (s *Trig) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("Trig", func() plugins.Plugin { return &Trig{x: 0.0} }) + inputs.Add("Trig", func() inputs.Input { return &Trig{x: 0.0} }) } diff --git a/plugins/trig/trig_test.go b/plugins/inputs/trig/trig_test.go similarity index 100% rename from plugins/trig/trig_test.go rename to plugins/inputs/trig/trig_test.go diff --git a/plugins/twemproxy/twemproxy.go b/plugins/inputs/twemproxy/twemproxy.go similarity index 93% rename from plugins/twemproxy/twemproxy.go rename to plugins/inputs/twemproxy/twemproxy.go index 268e465da7d58..95c9d0ba05067 100644 --- a/plugins/twemproxy/twemproxy.go +++ b/plugins/inputs/twemproxy/twemproxy.go @@ -7,7 +7,7 @@ import ( "net" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Twemproxy struct { @@ -31,7 +31,7 @@ func (t *Twemproxy) Description() string { } // Gather data from all Twemproxy instances -func (t *Twemproxy) Gather(acc plugins.Accumulator) error { +func (t *Twemproxy) Gather(acc inputs.Accumulator) error { conn, err := net.DialTimeout("tcp", t.Addr, 1*time.Second) if err != nil { return err @@ -55,7 +55,7 @@ func (t *Twemproxy) Gather(acc plugins.Accumulator) error { // Process Twemproxy server stats func (t *Twemproxy) processStat( - acc plugins.Accumulator, + acc inputs.Accumulator, tags map[string]string, data map[string]interface{}, ) { @@ -89,7 +89,7 @@ func (t *Twemproxy) processStat( // Process pool data in Twemproxy stats func (t *Twemproxy) processPool( - acc plugins.Accumulator, + acc inputs.Accumulator, tags map[string]string, data map[string]interface{}, ) { @@ -117,7 +117,7 @@ func (t *Twemproxy) processPool( // Process backend server(redis/memcached) stats func (t *Twemproxy) processServer( - acc plugins.Accumulator, + acc inputs.Accumulator, tags map[string]string, data map[string]interface{}, ) { @@ -143,7 +143,7 @@ func copyTags(tags map[string]string) map[string]string { } func init() { - plugins.Add("twemproxy", func() plugins.Plugin { + inputs.Add("twemproxy", func() inputs.Input { return &Twemproxy{} }) } diff --git a/plugins/twemproxy/twemproxy_test.go b/plugins/inputs/twemproxy/twemproxy_test.go similarity index 100% rename from plugins/twemproxy/twemproxy_test.go rename to plugins/inputs/twemproxy/twemproxy_test.go diff --git a/plugins/zfs/README.md b/plugins/inputs/zfs/README.md similarity index 100% rename from plugins/zfs/README.md rename to plugins/inputs/zfs/README.md diff --git a/plugins/zfs/zfs.go b/plugins/inputs/zfs/zfs.go similarity index 93% rename from plugins/zfs/zfs.go rename to plugins/inputs/zfs/zfs.go index 3594f670bf24a..109b261f88776 100644 --- a/plugins/zfs/zfs.go +++ b/plugins/inputs/zfs/zfs.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) type Zfs struct { @@ -68,7 +68,7 @@ func getTags(pools []poolInfo) map[string]string { return map[string]string{"pools": poolNames} } -func gatherPoolStats(pool poolInfo, acc plugins.Accumulator) error { +func gatherPoolStats(pool poolInfo, acc inputs.Accumulator) error { lines, err := internal.ReadLines(pool.ioFilename) if err != nil { return err @@ -101,7 +101,7 @@ func gatherPoolStats(pool poolInfo, acc plugins.Accumulator) error { return nil } -func (z *Zfs) Gather(acc plugins.Accumulator) error { +func (z *Zfs) Gather(acc inputs.Accumulator) error { kstatMetrics := z.KstatMetrics if len(kstatMetrics) == 0 { kstatMetrics = []string{"arcstats", "zfetchstats", "vdev_cache_stats"} @@ -149,7 +149,7 @@ func (z *Zfs) Gather(acc plugins.Accumulator) error { } func init() { - plugins.Add("zfs", func() plugins.Plugin { + inputs.Add("zfs", func() inputs.Input { return &Zfs{} }) } diff --git a/plugins/zfs/zfs_test.go b/plugins/inputs/zfs/zfs_test.go similarity index 100% rename from plugins/zfs/zfs_test.go rename to plugins/inputs/zfs/zfs_test.go diff --git a/plugins/zookeeper/README.md b/plugins/inputs/zookeeper/README.md similarity index 100% rename from plugins/zookeeper/README.md rename to plugins/inputs/zookeeper/README.md diff --git a/plugins/zookeeper/zookeeper.go b/plugins/inputs/zookeeper/zookeeper.go similarity index 90% rename from plugins/zookeeper/zookeeper.go rename to plugins/inputs/zookeeper/zookeeper.go index 342bace2c2300..93a07840dc32e 100644 --- a/plugins/zookeeper/zookeeper.go +++ b/plugins/inputs/zookeeper/zookeeper.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/influxdb/telegraf/plugins" + "github.com/influxdb/telegraf/plugins/inputs" ) // Zookeeper is a zookeeper plugin @@ -40,7 +40,7 @@ func (z *Zookeeper) Description() string { } // Gather reads stats from all configured servers accumulates stats -func (z *Zookeeper) Gather(acc plugins.Accumulator) error { +func (z *Zookeeper) Gather(acc inputs.Accumulator) error { if len(z.Servers) == 0 { return nil } @@ -53,7 +53,7 @@ func (z *Zookeeper) Gather(acc plugins.Accumulator) error { return nil } -func (z *Zookeeper) gatherServer(address string, acc plugins.Accumulator) error { +func (z *Zookeeper) gatherServer(address string, acc inputs.Accumulator) error { _, _, err := net.SplitHostPort(address) if err != nil { address = address + ":2181" @@ -103,7 +103,7 @@ func (z *Zookeeper) gatherServer(address string, acc plugins.Accumulator) error } func init() { - plugins.Add("zookeeper", func() plugins.Plugin { + inputs.Add("zookeeper", func() inputs.Input { return &Zookeeper{} }) } diff --git a/plugins/zookeeper/zookeeper_test.go b/plugins/inputs/zookeeper/zookeeper_test.go similarity index 100% rename from plugins/zookeeper/zookeeper_test.go rename to plugins/inputs/zookeeper/zookeeper_test.go diff --git a/plugins/outputs/all/all.go b/plugins/outputs/all/all.go new file mode 100644 index 0000000000000..8a0d24f9415dd --- /dev/null +++ b/plugins/outputs/all/all.go @@ -0,0 +1,16 @@ +package all + +import ( + _ "github.com/influxdb/telegraf/plugins/outputs/amon" + _ "github.com/influxdb/telegraf/plugins/outputs/amqp" + _ "github.com/influxdb/telegraf/plugins/outputs/datadog" + _ "github.com/influxdb/telegraf/plugins/outputs/influxdb" + _ "github.com/influxdb/telegraf/plugins/outputs/kafka" + _ "github.com/influxdb/telegraf/plugins/outputs/kinesis" + _ "github.com/influxdb/telegraf/plugins/outputs/librato" + _ "github.com/influxdb/telegraf/plugins/outputs/mqtt" + _ "github.com/influxdb/telegraf/plugins/outputs/nsq" + _ "github.com/influxdb/telegraf/plugins/outputs/opentsdb" + _ "github.com/influxdb/telegraf/plugins/outputs/prometheus_client" + _ "github.com/influxdb/telegraf/plugins/outputs/riemann" +) diff --git a/outputs/amon/README.md b/plugins/outputs/amon/README.md similarity index 100% rename from outputs/amon/README.md rename to plugins/outputs/amon/README.md diff --git a/outputs/amon/amon.go b/plugins/outputs/amon/amon.go similarity index 98% rename from outputs/amon/amon.go rename to plugins/outputs/amon/amon.go index 84914a27cf493..d8fceb0350d81 100644 --- a/outputs/amon/amon.go +++ b/plugins/outputs/amon/amon.go @@ -10,7 +10,7 @@ import ( "github.com/influxdb/influxdb/client/v2" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type Amon struct { diff --git a/outputs/amon/amon_test.go b/plugins/outputs/amon/amon_test.go similarity index 100% rename from outputs/amon/amon_test.go rename to plugins/outputs/amon/amon_test.go diff --git a/outputs/amqp/README.md b/plugins/outputs/amqp/README.md similarity index 100% rename from outputs/amqp/README.md rename to plugins/outputs/amqp/README.md diff --git a/outputs/amqp/amqp.go b/plugins/outputs/amqp/amqp.go similarity index 98% rename from outputs/amqp/amqp.go rename to plugins/outputs/amqp/amqp.go index a5c8c5a9fc7fb..6f0e0fde3b4ef 100644 --- a/outputs/amqp/amqp.go +++ b/plugins/outputs/amqp/amqp.go @@ -8,7 +8,7 @@ import ( "time" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" "github.com/streadway/amqp" ) diff --git a/outputs/amqp/amqp_test.go b/plugins/outputs/amqp/amqp_test.go similarity index 100% rename from outputs/amqp/amqp_test.go rename to plugins/outputs/amqp/amqp_test.go diff --git a/outputs/datadog/README.md b/plugins/outputs/datadog/README.md similarity index 100% rename from outputs/datadog/README.md rename to plugins/outputs/datadog/README.md diff --git a/outputs/datadog/datadog.go b/plugins/outputs/datadog/datadog.go similarity index 98% rename from outputs/datadog/datadog.go rename to plugins/outputs/datadog/datadog.go index e654f9780b091..4231b1f285d02 100644 --- a/outputs/datadog/datadog.go +++ b/plugins/outputs/datadog/datadog.go @@ -12,7 +12,7 @@ import ( "github.com/influxdb/influxdb/client/v2" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type Datadog struct { diff --git a/outputs/datadog/datadog_test.go b/plugins/outputs/datadog/datadog_test.go similarity index 100% rename from outputs/datadog/datadog_test.go rename to plugins/outputs/datadog/datadog_test.go diff --git a/outputs/influxdb/README.md b/plugins/outputs/influxdb/README.md similarity index 100% rename from outputs/influxdb/README.md rename to plugins/outputs/influxdb/README.md diff --git a/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go similarity index 98% rename from outputs/influxdb/influxdb.go rename to plugins/outputs/influxdb/influxdb.go index 14391884d4fa0..f6b79b009c7ea 100644 --- a/outputs/influxdb/influxdb.go +++ b/plugins/outputs/influxdb/influxdb.go @@ -11,7 +11,7 @@ import ( "github.com/influxdb/influxdb/client/v2" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type InfluxDB struct { diff --git a/outputs/influxdb/influxdb_test.go b/plugins/outputs/influxdb/influxdb_test.go similarity index 100% rename from outputs/influxdb/influxdb_test.go rename to plugins/outputs/influxdb/influxdb_test.go diff --git a/outputs/kafka/kafka.go b/plugins/outputs/kafka/kafka.go similarity index 97% rename from outputs/kafka/kafka.go rename to plugins/outputs/kafka/kafka.go index fae9552104a67..8e53cc511238e 100644 --- a/outputs/kafka/kafka.go +++ b/plugins/outputs/kafka/kafka.go @@ -6,7 +6,7 @@ import ( "github.com/Shopify/sarama" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type Kafka struct { diff --git a/outputs/kafka/kafka_test.go b/plugins/outputs/kafka/kafka_test.go similarity index 100% rename from outputs/kafka/kafka_test.go rename to plugins/outputs/kafka/kafka_test.go diff --git a/outputs/kinesis/README.md b/plugins/outputs/kinesis/README.md similarity index 100% rename from outputs/kinesis/README.md rename to plugins/outputs/kinesis/README.md diff --git a/outputs/kinesis/kinesis.go b/plugins/outputs/kinesis/kinesis.go similarity index 98% rename from outputs/kinesis/kinesis.go rename to plugins/outputs/kinesis/kinesis.go index 1441317070ddb..11e26fdf9c9f3 100644 --- a/outputs/kinesis/kinesis.go +++ b/plugins/outputs/kinesis/kinesis.go @@ -16,7 +16,7 @@ import ( "github.com/aws/aws-sdk-go/service/kinesis" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type KinesisOutput struct { diff --git a/outputs/kinesis/kinesis_test.go b/plugins/outputs/kinesis/kinesis_test.go similarity index 100% rename from outputs/kinesis/kinesis_test.go rename to plugins/outputs/kinesis/kinesis_test.go diff --git a/outputs/librato/README.md b/plugins/outputs/librato/README.md similarity index 100% rename from outputs/librato/README.md rename to plugins/outputs/librato/README.md diff --git a/outputs/librato/librato.go b/plugins/outputs/librato/librato.go similarity index 98% rename from outputs/librato/librato.go rename to plugins/outputs/librato/librato.go index a653ce1965707..75aecb756a9ca 100644 --- a/outputs/librato/librato.go +++ b/plugins/outputs/librato/librato.go @@ -9,7 +9,7 @@ import ( "github.com/influxdb/influxdb/client/v2" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type Librato struct { diff --git a/outputs/librato/librato_test.go b/plugins/outputs/librato/librato_test.go similarity index 100% rename from outputs/librato/librato_test.go rename to plugins/outputs/librato/librato_test.go diff --git a/outputs/mqtt/mqtt.go b/plugins/outputs/mqtt/mqtt.go similarity index 98% rename from outputs/mqtt/mqtt.go rename to plugins/outputs/mqtt/mqtt.go index aa6e17bc7dc34..a70b2e5750eac 100644 --- a/outputs/mqtt/mqtt.go +++ b/plugins/outputs/mqtt/mqtt.go @@ -12,7 +12,7 @@ import ( paho "git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git" "github.com/influxdb/influxdb/client/v2" "github.com/influxdb/telegraf/internal" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) const MaxClientIdLen = 8 diff --git a/outputs/mqtt/mqtt_test.go b/plugins/outputs/mqtt/mqtt_test.go similarity index 100% rename from outputs/mqtt/mqtt_test.go rename to plugins/outputs/mqtt/mqtt_test.go diff --git a/outputs/nsq/README.md b/plugins/outputs/nsq/README.md similarity index 100% rename from outputs/nsq/README.md rename to plugins/outputs/nsq/README.md diff --git a/outputs/nsq/nsq.go b/plugins/outputs/nsq/nsq.go similarity index 96% rename from outputs/nsq/nsq.go rename to plugins/outputs/nsq/nsq.go index 65b139c77d450..db58670a2c195 100644 --- a/outputs/nsq/nsq.go +++ b/plugins/outputs/nsq/nsq.go @@ -3,7 +3,7 @@ package nsq import ( "fmt" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" "github.com/nsqio/go-nsq" ) diff --git a/outputs/nsq/nsq_test.go b/plugins/outputs/nsq/nsq_test.go similarity index 100% rename from outputs/nsq/nsq_test.go rename to plugins/outputs/nsq/nsq_test.go diff --git a/outputs/opentsdb/README.md b/plugins/outputs/opentsdb/README.md similarity index 100% rename from outputs/opentsdb/README.md rename to plugins/outputs/opentsdb/README.md diff --git a/outputs/opentsdb/opentsdb.go b/plugins/outputs/opentsdb/opentsdb.go similarity index 98% rename from outputs/opentsdb/opentsdb.go rename to plugins/outputs/opentsdb/opentsdb.go index 0146458dcef21..236385d71b786 100644 --- a/outputs/opentsdb/opentsdb.go +++ b/plugins/outputs/opentsdb/opentsdb.go @@ -9,7 +9,7 @@ import ( "time" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type OpenTSDB struct { diff --git a/outputs/opentsdb/opentsdb_test.go b/plugins/outputs/opentsdb/opentsdb_test.go similarity index 100% rename from outputs/opentsdb/opentsdb_test.go rename to plugins/outputs/opentsdb/opentsdb_test.go diff --git a/outputs/prometheus_client/README.md b/plugins/outputs/prometheus_client/README.md similarity index 100% rename from outputs/prometheus_client/README.md rename to plugins/outputs/prometheus_client/README.md diff --git a/outputs/prometheus_client/prometheus_client.go b/plugins/outputs/prometheus_client/prometheus_client.go similarity index 98% rename from outputs/prometheus_client/prometheus_client.go rename to plugins/outputs/prometheus_client/prometheus_client.go index 6df69a0a4ee24..1fbf9056a66bb 100644 --- a/outputs/prometheus_client/prometheus_client.go +++ b/plugins/outputs/prometheus_client/prometheus_client.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" "github.com/prometheus/client_golang/prometheus" ) diff --git a/outputs/prometheus_client/prometheus_client_test.go b/plugins/outputs/prometheus_client/prometheus_client_test.go similarity index 97% rename from outputs/prometheus_client/prometheus_client_test.go rename to plugins/outputs/prometheus_client/prometheus_client_test.go index 53adcac17f06b..dc353486cf204 100644 --- a/outputs/prometheus_client/prometheus_client_test.go +++ b/plugins/outputs/prometheus_client/prometheus_client_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/plugins/prometheus" + "github.com/influxdb/telegraf/plugins/inputs/prometheus" "github.com/influxdb/telegraf/testutil" ) diff --git a/outputs/registry.go b/plugins/outputs/registry.go similarity index 100% rename from outputs/registry.go rename to plugins/outputs/registry.go diff --git a/outputs/riemann/riemann.go b/plugins/outputs/riemann/riemann.go similarity index 97% rename from outputs/riemann/riemann.go rename to plugins/outputs/riemann/riemann.go index eaa0aab9ced24..afbde00510950 100644 --- a/outputs/riemann/riemann.go +++ b/plugins/outputs/riemann/riemann.go @@ -7,7 +7,7 @@ import ( "github.com/amir/raidman" "github.com/influxdb/influxdb/client/v2" - "github.com/influxdb/telegraf/outputs" + "github.com/influxdb/telegraf/plugins/outputs" ) type Riemann struct { diff --git a/outputs/riemann/riemann_test.go b/plugins/outputs/riemann/riemann_test.go similarity index 100% rename from outputs/riemann/riemann_test.go rename to plugins/outputs/riemann/riemann_test.go diff --git a/scripts/circle-test.sh b/scripts/circle-test.sh index f00ac7d005a02..96319bf72f2c5 100755 --- a/scripts/circle-test.sh +++ b/scripts/circle-test.sh @@ -66,6 +66,6 @@ exit_if_fail "./telegraf -version | grep $VERSION" tmpdir=$(mktemp -d) ./telegraf -sample-config > $tmpdir/config.toml exit_if_fail ./telegraf -config $tmpdir/config.toml \ - -test -filter cpu:mem + -test -input-filter cpu:mem exit $rc diff --git a/scripts/init.sh b/scripts/init.sh index 91e9b47b387a7..8a0fd992c88cb 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -137,9 +137,9 @@ case $1 in log_success_msg "Starting the process" "$name" if which start-stop-daemon > /dev/null 2>&1; then - start-stop-daemon --chuid $GROUP:$USER --start --quiet --pidfile $pidfile --exec $daemon -- -pidfile $pidfile -config $config -configdirectory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR & + start-stop-daemon --chuid $GROUP:$USER --start --quiet --pidfile $pidfile --exec $daemon -- -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR & else - nohup $daemon -pidfile $pidfile -config $config -configdirectory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR & + nohup $daemon -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR & fi log_success_msg "$name process was started" ;; diff --git a/scripts/telegraf.service b/scripts/telegraf.service index d5e46b1243a22..62fc23a25b08d 100644 --- a/scripts/telegraf.service +++ b/scripts/telegraf.service @@ -6,7 +6,7 @@ After=network.target [Service] EnvironmentFile=-/etc/default/telegraf User=telegraf -ExecStart=/opt/telegraf/telegraf -config /etc/opt/telegraf/telegraf.conf -configdirectory /etc/opt/telegraf/telegraf.d $TELEGRAF_OPTS +ExecStart=/opt/telegraf/telegraf -config /etc/opt/telegraf/telegraf.conf -config-directory /etc/opt/telegraf/telegraf.d $TELEGRAF_OPTS Restart=on-failure KillMode=process