diff --git a/plugins/inputs/all/all.go b/plugins/inputs/all/all.go index 25f23d7f87d65..d55bb98f18c76 100644 --- a/plugins/inputs/all/all.go +++ b/plugins/inputs/all/all.go @@ -124,6 +124,7 @@ import ( _ "github.com/influxdata/telegraf/plugins/inputs/neptune_apex" _ "github.com/influxdata/telegraf/plugins/inputs/net" _ "github.com/influxdata/telegraf/plugins/inputs/net_response" + _ "github.com/influxdata/telegraf/plugins/inputs/netstat" _ "github.com/influxdata/telegraf/plugins/inputs/nfsclient" _ "github.com/influxdata/telegraf/plugins/inputs/nginx" _ "github.com/influxdata/telegraf/plugins/inputs/nginx_plus" diff --git a/plugins/inputs/mailchimp/README.md b/plugins/inputs/mailchimp/README.md index a3a7f599de8bf..fe9d403264a22 100644 --- a/plugins/inputs/mailchimp/README.md +++ b/plugins/inputs/mailchimp/README.md @@ -8,15 +8,16 @@ This section contains the default TOML to configure the plugin. You can generate it using `telegraf --usage mailchimp`. ```toml +# Gathers metrics from the /3.0/reports MailChimp API [[inputs.mailchimp]] ## MailChimp API key ## get from https://admin.mailchimp.com/account/api/ api_key = "" # required - + ## Reports for campaigns sent more than days_old ago will not be collected. ## 0 means collect all and is the default value. days_old = 0 - + ## Campaign ID to get, if empty gets all campaigns, this option overrides days_old # campaign_id = "" ``` diff --git a/plugins/inputs/mailchimp/mailchimp.go b/plugins/inputs/mailchimp/mailchimp.go index b898cb6ba1768..3a4cf04beb4c8 100644 --- a/plugins/inputs/mailchimp/mailchimp.go +++ b/plugins/inputs/mailchimp/mailchimp.go @@ -18,25 +18,6 @@ type MailChimp struct { Log telegraf.Logger `toml:"-"` } -var sampleConfig = ` - ## MailChimp API key - ## get from https://admin.mailchimp.com/account/api/ - api_key = "" # required - ## Reports for campaigns sent more than days_old ago will not be collected. - ## 0 means collect all. - days_old = 0 - ## Campaign ID to get, if empty gets all campaigns, this option overrides days_old - # campaign_id = "" -` - -func (m *MailChimp) SampleConfig() string { - return sampleConfig -} - -func (m *MailChimp) Description() string { - return "Gathers metrics from the /3.0/reports MailChimp API" -} - func (m *MailChimp) Init() error { m.api = NewChimpAPI(m.APIKey, m.Log) diff --git a/plugins/inputs/mailchimp/mailchimp_sample_config.go b/plugins/inputs/mailchimp/mailchimp_sample_config.go new file mode 100644 index 0000000000000..71dc385337adf --- /dev/null +++ b/plugins/inputs/mailchimp/mailchimp_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mailchimp + +func (m *MailChimp) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/marklogic/README.md b/plugins/inputs/marklogic/README.md index acd6100df75f8..539cb531b3a1f 100644 --- a/plugins/inputs/marklogic/README.md +++ b/plugins/inputs/marklogic/README.md @@ -5,6 +5,7 @@ The MarkLogic Telegraf plugin gathers health status metrics from one or more hos ## Configuration ```toml +# Retrieves information on a specific host in a MarkLogic Cluster [[inputs.marklogic]] ## Base URL of the MarkLogic HTTP Server. url = "http://localhost:8002" diff --git a/plugins/inputs/marklogic/marklogic.go b/plugins/inputs/marklogic/marklogic.go index 30f9ee6403074..b4b2078e6eda5 100644 --- a/plugins/inputs/marklogic/marklogic.go +++ b/plugins/inputs/marklogic/marklogic.go @@ -82,30 +82,6 @@ type MlHost struct { } `json:"host-status"` } -// Description of plugin returned -func (c *Marklogic) Description() string { - return "Retrieves information on a specific host in a MarkLogic Cluster" -} - -var sampleConfig = ` - ## Base URL of the MarkLogic HTTP Server. - url = "http://localhost:8002" - - ## List of specific hostnames to retrieve information. At least (1) required. - # hosts = ["hostname1", "hostname2"] - - ## Using HTTP Basic Authentication. Management API requires 'manage-user' role privileges - # username = "myuser" - # password = "mypassword" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - // Init parse all source URLs and place on the Marklogic struct func (c *Marklogic) Init() error { if len(c.URL) == 0 { @@ -128,11 +104,6 @@ func (c *Marklogic) Init() error { return nil } -// SampleConfig to gather stats from localhost, default port. -func (c *Marklogic) SampleConfig() string { - return sampleConfig -} - // Gather metrics from HTTP Server. func (c *Marklogic) Gather(accumulator telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/marklogic/marklogic_sample_config.go b/plugins/inputs/marklogic/marklogic_sample_config.go new file mode 100644 index 0000000000000..0616e75368120 --- /dev/null +++ b/plugins/inputs/marklogic/marklogic_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package marklogic + +func (c *Marklogic) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mcrouter/mcrouter.go b/plugins/inputs/mcrouter/mcrouter.go index 07599ca2cc0b0..8867081f9bf29 100644 --- a/plugins/inputs/mcrouter/mcrouter.go +++ b/plugins/inputs/mcrouter/mcrouter.go @@ -29,15 +29,6 @@ const ( typeFloat statType = iota ) -var sampleConfig = ` - ## An array of address to gather stats about. Specify an ip or hostname - ## with port. ie tcp://localhost:11211, tcp://10.0.0.1:11211, etc. - servers = ["tcp://localhost:11211", "unix:///var/run/mcrouter.sock"] - - ## Timeout for metric collections from all servers. Minimum timeout is "1s". - # timeout = "5s" -` - var defaultTimeout = 5 * time.Second var defaultServerURL = url.URL{ @@ -113,16 +104,6 @@ var sendMetrics = map[string]statType{ "cmd_lease_set_out_all": typeInt, } -// SampleConfig returns sample configuration message -func (m *Mcrouter) SampleConfig() string { - return sampleConfig -} - -// Description returns description of Mcrouter plugin -func (m *Mcrouter) Description() string { - return "Read metrics from one or many mcrouter servers" -} - // Gather reads stats from all configured servers accumulates stats func (m *Mcrouter) Gather(acc telegraf.Accumulator) error { ctx := context.Background() diff --git a/plugins/inputs/mcrouter/mcrouter_sample_config.go b/plugins/inputs/mcrouter/mcrouter_sample_config.go new file mode 100644 index 0000000000000..3b3a1fc1a35e5 --- /dev/null +++ b/plugins/inputs/mcrouter/mcrouter_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mcrouter + +func (m *Mcrouter) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mdstat/mdstat.go b/plugins/inputs/mdstat/mdstat.go index 685fa3eab4fa4..7aef0e41f9478 100644 --- a/plugins/inputs/mdstat/mdstat.go +++ b/plugins/inputs/mdstat/mdstat.go @@ -62,20 +62,6 @@ type MdstatConf struct { FileName string `toml:"file_name"` } -func (k *MdstatConf) Description() string { - return "Get md array statistics from /proc/mdstat" -} - -var mdSampleConfig = ` - ## Sets file path - ## If not specified, then default is /proc/mdstat - # file_name = "/proc/mdstat" -` - -func (k *MdstatConf) SampleConfig() string { - return mdSampleConfig -} - func evalStatusLine(deviceLine, statusLineStr string) (statusLine, error) { sizeFields := strings.Fields(statusLineStr) if len(sizeFields) < 1 { diff --git a/plugins/inputs/mdstat/mdstat_sample_config.go b/plugins/inputs/mdstat/mdstat_sample_config.go new file mode 100644 index 0000000000000..eaad61998e25f --- /dev/null +++ b/plugins/inputs/mdstat/mdstat_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mdstat + +func (k *MdstatConf) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mem/memory.go b/plugins/inputs/mem/mem.go similarity index 94% rename from plugins/inputs/mem/memory.go rename to plugins/inputs/mem/mem.go index 84fcbc32eb3ea..633f34f5084bc 100644 --- a/plugins/inputs/mem/memory.go +++ b/plugins/inputs/mem/mem.go @@ -14,12 +14,6 @@ type MemStats struct { platform string } -func (ms *MemStats) Description() string { - return "Read metrics about memory usage" -} - -func (ms *MemStats) SampleConfig() string { return "" } - func (ms *MemStats) Init() error { ms.platform = runtime.GOOS return nil diff --git a/plugins/inputs/mem/mem_sample_config.go b/plugins/inputs/mem/mem_sample_config.go new file mode 100644 index 0000000000000..07f7711efd422 --- /dev/null +++ b/plugins/inputs/mem/mem_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mem + +func (ms *MemStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mem/memory_test.go b/plugins/inputs/mem/mem_test.go similarity index 100% rename from plugins/inputs/mem/memory_test.go rename to plugins/inputs/mem/mem_test.go diff --git a/plugins/inputs/memcached/memcached.go b/plugins/inputs/memcached/memcached.go index f71669a952c6c..af1cc5c1e6dc5 100644 --- a/plugins/inputs/memcached/memcached.go +++ b/plugins/inputs/memcached/memcached.go @@ -23,21 +23,6 @@ type Memcached struct { tlsint.ClientConfig } -var sampleConfig = ` - ## An array of address to gather stats about. Specify an ip on hostname - ## with optional port. ie localhost, 10.0.0.1:11211, etc. - servers = ["localhost:11211"] - # unix_sockets = ["/var/run/memcached.sock"] - - ## Optional TLS Config - # enable_tls = true - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## If false, skip chain & host verification - # insecure_skip_verify = true -` - var defaultTimeout = 5 * time.Second // The list of metrics that should be sent @@ -91,16 +76,6 @@ var sendMetrics = []string{ "uptime", } -// SampleConfig returns sample configuration message -func (m *Memcached) SampleConfig() string { - return sampleConfig -} - -// Description returns description of Memcached plugin -func (m *Memcached) Description() string { - return "Read metrics from one or many memcached servers" -} - // Gather reads stats from all configured servers accumulates stats func (m *Memcached) Gather(acc telegraf.Accumulator) error { if len(m.Servers) == 0 && len(m.UnixSockets) == 0 { diff --git a/plugins/inputs/memcached/memcached_sample_config.go b/plugins/inputs/memcached/memcached_sample_config.go new file mode 100644 index 0000000000000..f1e4c4a9b3ba8 --- /dev/null +++ b/plugins/inputs/memcached/memcached_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package memcached + +func (m *Memcached) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mesos/mesos.go b/plugins/inputs/mesos/mesos.go index 991f8a9fd7003..350bf01374d98 100644 --- a/plugins/inputs/mesos/mesos.go +++ b/plugins/inputs/mesos/mesos.go @@ -46,59 +46,6 @@ var allMetrics = map[Role][]string{ SLAVE: {"resources", "agent", "system", "executors", "tasks", "messages"}, } -var sampleConfig = ` - ## Timeout, in ms. - timeout = 100 - - ## A list of Mesos masters. - masters = ["http://localhost:5050"] - - ## Master metrics groups to be collected, by default, all enabled. - master_collections = [ - "resources", - "master", - "system", - "agents", - "frameworks", - "framework_offers", - "tasks", - "messages", - "evqueue", - "registrar", - "allocator", - ] - - ## A list of Mesos slaves, default is [] - # slaves = [] - - ## Slave metrics groups to be collected, by default, all enabled. - # slave_collections = [ - # "resources", - # "agent", - # "system", - # "executors", - # "tasks", - # "messages", - # ] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -// SampleConfig returns a sample configuration block -func (m *Mesos) SampleConfig() string { - return sampleConfig -} - -// Description just returns a short description of the Mesos plugin -func (m *Mesos) Description() string { - return "Telegraf plugin for gathering metrics from N Mesos masters" -} - func (m *Mesos) parseURL(s string, role Role) (*url.URL, error) { if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") { host, port, err := net.SplitHostPort(s) diff --git a/plugins/inputs/mesos/mesos_sample_config.go b/plugins/inputs/mesos/mesos_sample_config.go new file mode 100644 index 0000000000000..098c92209ad4a --- /dev/null +++ b/plugins/inputs/mesos/mesos_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mesos + +func (m *Mesos) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/minecraft/README.md b/plugins/inputs/minecraft/README.md index e5f1f00ef26b8..f595a5841c5f0 100644 --- a/plugins/inputs/minecraft/README.md +++ b/plugins/inputs/minecraft/README.md @@ -45,6 +45,7 @@ View the current scores with a command, substituting your player name: ## Configuration ```toml +# Collects scores from a Minecraft server's scoreboard using the RCON protocol [[inputs.minecraft]] ## Address of the Minecraft server. # server = "localhost" @@ -54,6 +55,9 @@ View the current scores with a command, substituting your player name: ## Server RCON Password. password = "" + + ## Uncomment to remove deprecated metric components. + # tagdrop = ["server"] ``` ## Metrics diff --git a/plugins/inputs/minecraft/minecraft.go b/plugins/inputs/minecraft/minecraft.go index e953b3c2b5d7f..bd5cb4ae61af3 100644 --- a/plugins/inputs/minecraft/minecraft.go +++ b/plugins/inputs/minecraft/minecraft.go @@ -5,20 +5,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## Address of the Minecraft server. - # server = "localhost" - - ## Server RCON Port. - # port = "25575" - - ## Server RCON Password. - password = "" - - ## Uncomment to remove deprecated metric components. - # tagdrop = ["server"] -` - // Client is a client for the Minecraft server. type Client interface { // Connect establishes a connection to the server. @@ -40,14 +26,6 @@ type Minecraft struct { client Client } -func (s *Minecraft) Description() string { - return "Collects scores from a Minecraft server's scoreboard using the RCON protocol" -} - -func (s *Minecraft) SampleConfig() string { - return sampleConfig -} - func (s *Minecraft) Gather(acc telegraf.Accumulator) error { if s.client == nil { connector := newConnector(s.Server, s.Port, s.Password) diff --git a/plugins/inputs/minecraft/minecraft_sample_config.go b/plugins/inputs/minecraft/minecraft_sample_config.go new file mode 100644 index 0000000000000..1a404971164e5 --- /dev/null +++ b/plugins/inputs/minecraft/minecraft_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package minecraft + +func (s *Minecraft) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mock/README.md b/plugins/inputs/mock/README.md index c26f26621fcbd..85fbddf5cfb98 100644 --- a/plugins/inputs/mock/README.md +++ b/plugins/inputs/mock/README.md @@ -17,6 +17,7 @@ The mock plugin only requires that: Below is a sample config to generate one of each of the four types: ```toml +# Generate metrics for test and demonstration purposes [[inputs.mock]] ## Set the metric name to use for reporting metric_name = "mock" diff --git a/plugins/inputs/mock/mock.go b/plugins/inputs/mock/mock.go index d82486bfc2abb..2c506898658c3 100644 --- a/plugins/inputs/mock/mock.go +++ b/plugins/inputs/mock/mock.go @@ -49,42 +49,6 @@ type stock struct { Volatility float64 `toml:"volatility"` } -const sampleConfig = ` - ## Set the metric name to use for reporting - metric_name = "mock" - - ## Optional string key-value pairs of tags to add to all metrics - # [inputs.mock.tags] - # "key" = "value" - - ## One or more mock data fields *must* be defined. - ## - ## [[inputs.mock.random]] - ## name = "rand" - ## min = 1.0 - ## max = 6.0 - ## [[inputs.mock.sine_wave]] - ## name = "wave" - ## amplitude = 1.0 - ## period = 0.5 - ## [[inputs.mock.step]] - ## name = "plus_one" - ## start = 0.0 - ## step = 1.0 - ## [[inputs.mock.stock]] - ## name = "abc" - ## price = 50.00 - ## volatility = 0.2 -` - -func (m *Mock) SampleConfig() string { - return sampleConfig -} - -func (m *Mock) Description() string { - return "Generate metrics for test and demonstration purposes" -} - func (m *Mock) Init() error { rand.Seed(time.Now().UnixNano()) return nil diff --git a/plugins/inputs/mock/mock_sample_config.go b/plugins/inputs/mock/mock_sample_config.go new file mode 100644 index 0000000000000..d963d51dabb96 --- /dev/null +++ b/plugins/inputs/mock/mock_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mock + +func (m *Mock) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/modbus/README.md b/plugins/inputs/modbus/README.md index 715fe8ec357a5..373304dee3dd3 100644 --- a/plugins/inputs/modbus/README.md +++ b/plugins/inputs/modbus/README.md @@ -3,9 +3,10 @@ The Modbus plugin collects Discrete Inputs, Coils, Input Registers and Holding Registers via Modbus TCP or Modbus RTU/ASCII. -## Example configuration +## Configuration ```toml +# Retrieve data from MODBUS slave devices [[inputs.modbus]] ## Connection Configuration ## @@ -187,7 +188,7 @@ Registers via Modbus TCP or Modbus RTU/ASCII. { address=1, name="temperature", type="INT16", scale=0.1 }, # will result in FLOAT64 field { address=2, name="force", type="INT32", output="FLOAT64" }, # will result in FLOAT64 field { address=4, name="hours", type="UINT32" }, # will result in UIN64 field - ] + ] [[inputs.modbus.request.tags]] machine = "impresser" diff --git a/plugins/inputs/modbus/modbus.go b/plugins/inputs/modbus/modbus.go index 63cab7d206191..d844b2ad858a4 100644 --- a/plugins/inputs/modbus/modbus.go +++ b/plugins/inputs/modbus/modbus.go @@ -74,84 +74,6 @@ const ( cInputRegisters = "input_register" ) -const description = `Retrieve data from MODBUS slave devices` -const sampleConfigStart = ` - ## Connection Configuration - ## - ## The plugin supports connections to PLCs via MODBUS/TCP, RTU over TCP, ASCII over TCP or - ## via serial line communication in binary (RTU) or readable (ASCII) encoding - ## - ## Device name - name = "Device" - - ## Slave ID - addresses a MODBUS device on the bus - ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved] - slave_id = 1 - - ## Timeout for each request - timeout = "1s" - - ## Maximum number of retries and the time to wait between retries - ## when a slave-device is busy. - # busy_retries = 0 - # busy_retries_wait = "100ms" - - # TCP - connect via Modbus/TCP - controller = "tcp://localhost:502" - - ## Serial (RS485; RS232) - # controller = "file:///dev/ttyUSB0" - # baud_rate = 9600 - # data_bits = 8 - # parity = "N" - # stop_bits = 1 - - ## Trace the connection to the modbus device as debug messages - ## Note: You have to enable telegraf's debug mode to see those messages! - # debug_connection = false - - ## For Modbus over TCP you can choose between "TCP", "RTUoverTCP" and "ASCIIoverTCP" - ## default behaviour is "TCP" if the controller is TCP - ## For Serial you can choose between "RTU" and "ASCII" - # transmission_mode = "RTU" - - ## Define the configuration schema - ## |---register -- define fields per register type in the original style (only supports one slave ID) - ## |---request -- define fields on a requests base - configuration_type = "register" -` -const sampleConfigEnd = ` - ## Enable workarounds required by some devices to work correctly - # [inputs.modbus.workarounds] - ## Pause between read requests sent to the device. This might be necessary for (slow) serial devices. - # pause_between_requests = "0ms" - ## Close the connection after every gather cycle. Usually the plugin closes the connection after a certain - ## idle-timeout, however, if you query a device with limited simultaneous connectivity (e.g. serial devices) - ## from multiple instances you might want to only stay connected during gather and disconnect afterwards. - # close_connection_after_gather = false -` - -// SampleConfig returns a basic configuration for the plugin -func (m *Modbus) SampleConfig() string { - configs := []Configuration{} - cfgOriginal := m.ConfigurationOriginal - cfgPerRequest := m.ConfigurationPerRequest - configs = append(configs, &cfgOriginal, &cfgPerRequest) - - totalConfig := sampleConfigStart - for _, c := range configs { - totalConfig += c.SampleConfigPart() + "\n" - } - totalConfig += "\n" - totalConfig += sampleConfigEnd - return totalConfig -} - -// Description returns a short description of what the plugin does -func (m *Modbus) Description() string { - return description -} - func (m *Modbus) Init() error { //check device name if m.Name == "" { diff --git a/plugins/inputs/modbus/modbus_sample_config.go b/plugins/inputs/modbus/modbus_sample_config.go new file mode 100644 index 0000000000000..a29d296a5c1c4 --- /dev/null +++ b/plugins/inputs/modbus/modbus_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package modbus + +func (m *Modbus) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mongodb/README.md b/plugins/inputs/mongodb/README.md index 975ca593c41a3..42a15e156aabd 100644 --- a/plugins/inputs/mongodb/README.md +++ b/plugins/inputs/mongodb/README.md @@ -5,6 +5,7 @@ All MongoDB server versions from 2.6 and higher are supported. ## Configuration ```toml +# Read metrics from one or many MongoDB servers [[inputs.mongodb]] ## An array of URLs of the form: ## "mongodb://" [user ":" pass "@"] host [ ":" port] diff --git a/plugins/inputs/mongodb/mongodb.go b/plugins/inputs/mongodb/mongodb.go index c7258378fb114..94633434687b4 100644 --- a/plugins/inputs/mongodb/mongodb.go +++ b/plugins/inputs/mongodb/mongodb.go @@ -38,49 +38,6 @@ type Ssl struct { CaCerts []string `toml:"cacerts" deprecated:"1.3.0;use 'tls_ca' instead"` } -var sampleConfig = ` - ## An array of URLs of the form: - ## "mongodb://" [user ":" pass "@"] host [ ":" port] - ## For example: - ## mongodb://user:auth_key@10.10.3.30:27017, - ## mongodb://10.10.3.33:18832, - servers = ["mongodb://127.0.0.1:27017?connect=direct"] - - ## When true, collect cluster status - ## Note that the query that counts jumbo chunks triggers a COLLSCAN, which - ## may have an impact on performance. - # gather_cluster_status = true - - ## When true, collect per database stats - # gather_perdb_stats = false - - ## When true, collect per collection stats - # gather_col_stats = false - - ## When true, collect usage statistics for each collection - ## (insert, update, queries, remove, getmore, commands etc...). - # gather_top_stat = false - - ## List of db where collections stats are collected - ## If empty, all db are concerned - # col_stats_dbs = ["local"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (m *MongoDB) SampleConfig() string { - return sampleConfig -} - -func (*MongoDB) Description() string { - return "Read metrics from one or many MongoDB servers" -} - func (m *MongoDB) Init() error { var tlsConfig *tls.Config if m.Ssl.Enabled { diff --git a/plugins/inputs/mongodb/mongodb_sample_config.go b/plugins/inputs/mongodb/mongodb_sample_config.go new file mode 100644 index 0000000000000..fd8ac219f2686 --- /dev/null +++ b/plugins/inputs/mongodb/mongodb_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mongodb + +func (m *MongoDB) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/monit/README.md b/plugins/inputs/monit/README.md index 053e745982a5b..f166252e0faea 100644 --- a/plugins/inputs/monit/README.md +++ b/plugins/inputs/monit/README.md @@ -15,6 +15,7 @@ Minimum Version of Monit tested with is 5.16. ## Configuration ```toml +# Read metrics and status information about processes managed by Monit [[inputs.monit]] ## Monit HTTPD address address = "http://127.0.0.1:2812" diff --git a/plugins/inputs/monit/monit.go b/plugins/inputs/monit/monit.go index 051e0b36982fe..066df699249a6 100644 --- a/plugins/inputs/monit/monit.go +++ b/plugins/inputs/monit/monit.go @@ -187,33 +187,6 @@ type Messagebody struct { Metrics []string `json:"metrics"` } -func (m *Monit) Description() string { - return "Read metrics and status information about processes managed by Monit" -} - -var sampleConfig = ` - ## Monit HTTPD address - address = "http://127.0.0.1:2812" - - ## Username and Password for Monit - # username = "" - # password = "" - - ## Amount of time allowed to complete the HTTP request - # timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (m *Monit) SampleConfig() string { - return sampleConfig -} - func (m *Monit) Init() error { tlsCfg, err := m.ClientConfig.TLSConfig() if err != nil { diff --git a/plugins/inputs/monit/monit_sample_config.go b/plugins/inputs/monit/monit_sample_config.go new file mode 100644 index 0000000000000..9a3e28305fe37 --- /dev/null +++ b/plugins/inputs/monit/monit_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package monit + +func (m *Monit) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mqtt_consumer/mqtt_consumer.go b/plugins/inputs/mqtt_consumer/mqtt_consumer.go index d486bb7a93fe8..27b46d23ce753 100644 --- a/plugins/inputs/mqtt_consumer/mqtt_consumer.go +++ b/plugins/inputs/mqtt_consumer/mqtt_consumer.go @@ -85,81 +85,6 @@ type MQTTConsumer struct { cancel context.CancelFunc } -var sampleConfig = ` - ## Broker URLs for the MQTT server or cluster. To connect to multiple - ## clusters or standalone servers, use a separate plugin instance. - ## example: servers = ["tcp://localhost:1883"] - ## servers = ["ssl://localhost:1883"] - ## servers = ["ws://localhost:1883"] - servers = ["tcp://127.0.0.1:1883"] - ## Topics that will be subscribed to. - topics = [ - "telegraf/host01/cpu", - "telegraf/+/mem", - "sensors/#", - ] - # topic_fields = "_/_/_/temperature" - ## The message topic will be stored in a tag specified by this value. If set - ## to the empty string no topic tag will be created. - # topic_tag = "topic" - ## QoS policy for messages - ## 0 = at most once - ## 1 = at least once - ## 2 = exactly once - ## - ## When using a QoS of 1 or 2, you should enable persistent_session to allow - ## resuming unacknowledged messages. - # qos = 0 - ## Connection timeout for initial connection in seconds - # connection_timeout = "30s" - ## Maximum messages to read from the broker that have not been written by an - ## output. For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message from the queue contains 10 metrics and the - ## output metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - ## Persistent session disables clearing of the client session on connection. - ## In order for this option to work you must also set client_id to identify - ## the client. To receive messages that arrived while the client is offline, - ## also set the qos option to 1 or 2 and don't forget to also set the QoS when - ## publishing. - # persistent_session = false - ## If unset, a random client ID will be generated. - # client_id = "" - ## Username and password to connect MQTT server. - # username = "telegraf" - # password = "metricsmetricsmetricsmetrics" - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" - ## Enable extracting tag values from MQTT topics - ## _ denotes an ignored entry in the topic path - ## [[inputs.mqtt_consumer.topic_parsing]] - ## topic = "" - ## measurement = "" - ## tags = "" - ## fields = "" - ## [inputs.mqtt_consumer.topic_parsing.types] - ## -` - -func (m *MQTTConsumer) SampleConfig() string { - return sampleConfig -} -func (m *MQTTConsumer) Description() string { - return "Read metrics from MQTT topic(s)" -} func (m *MQTTConsumer) SetParser(parser parsers.Parser) { m.parser = parser } diff --git a/plugins/inputs/mqtt_consumer/mqtt_consumer_sample_config.go b/plugins/inputs/mqtt_consumer/mqtt_consumer_sample_config.go new file mode 100644 index 0000000000000..2509c01bcffcf --- /dev/null +++ b/plugins/inputs/mqtt_consumer/mqtt_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mqtt_consumer + +func (m *MQTTConsumer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/multifile/README.md b/plugins/inputs/multifile/README.md index b460d59aa90ed..3df7b32cb4fd3 100644 --- a/plugins/inputs/multifile/README.md +++ b/plugins/inputs/multifile/README.md @@ -10,6 +10,7 @@ useful creating custom metrics from the `/sys` or `/proc` filesystems. ## Configuration ```toml +# Aggregates the contents of multiple files into a single point [[inputs.multifile]] ## Base directory where telegraf will look for files. ## Omit this option to use absolute paths. diff --git a/plugins/inputs/multifile/multifile.go b/plugins/inputs/multifile/multifile.go index 65c2ac4e4b783..fd2f2fa3e2e16 100644 --- a/plugins/inputs/multifile/multifile.go +++ b/plugins/inputs/multifile/multifile.go @@ -27,39 +27,6 @@ type File struct { Conversion string } -const sampleConfig = ` - ## Base directory where telegraf will look for files. - ## Omit this option to use absolute paths. - base_dir = "/sys/bus/i2c/devices/1-0076/iio:device0" - - ## If true, Telegraf discard all data when a single file can't be read. - ## Else, Telegraf omits the field generated from this file. - # fail_early = true - - ## Files to parse each interval. - [[inputs.multifile.file]] - file = "in_pressure_input" - dest = "pressure" - conversion = "float" - [[inputs.multifile.file]] - file = "in_temp_input" - dest = "temperature" - conversion = "float(3)" - [[inputs.multifile.file]] - file = "in_humidityrelative_input" - dest = "humidityrelative" - conversion = "float(3)" -` - -// SampleConfig returns the default configuration of the Input -func (m *MultiFile) SampleConfig() string { - return sampleConfig -} - -func (m *MultiFile) Description() string { - return "Aggregates the contents of multiple files into a single point" -} - func (m *MultiFile) init() { if m.initialized { return diff --git a/plugins/inputs/multifile/multifile_sample_config.go b/plugins/inputs/multifile/multifile_sample_config.go new file mode 100644 index 0000000000000..ce2ae8009021f --- /dev/null +++ b/plugins/inputs/multifile/multifile_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package multifile + +func (m *MultiFile) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/mysql/README.md b/plugins/inputs/mysql/README.md index cd98b454408b0..e14db4831b3f9 100644 --- a/plugins/inputs/mysql/README.md +++ b/plugins/inputs/mysql/README.md @@ -21,6 +21,7 @@ This plugin gathers the statistic data from MySQL server ## Configuration ```toml +# Read metrics from one or many mysql servers [[inputs.mysql]] ## specify servers via a url matching: ## [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify|custom]] @@ -65,7 +66,7 @@ This plugin gathers the statistic data from MySQL server ## gather metrics from all channels from SHOW SLAVE STATUS command output # gather_all_slave_channels = false - + ## gather metrics from SHOW SLAVE STATUS command output # gather_slave_status = false diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index 7841b4b5b0d8f..11886441eabac 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -52,105 +52,6 @@ type Mysql struct { getStatusQuery string } -const sampleConfig = ` - ## specify servers via a url matching: - ## [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify|custom]] - ## see https://github.com/go-sql-driver/mysql#dsn-data-source-name - ## e.g. - ## servers = ["user:passwd@tcp(127.0.0.1:3306)/?tls=false"] - ## servers = ["user@tcp(127.0.0.1:3306)/?tls=false"] - # - ## If no servers are specified, then localhost is used as the host. - servers = ["tcp(127.0.0.1:3306)/"] - - ## Selects the metric output format. - ## - ## This option exists to maintain backwards compatibility, if you have - ## existing metrics do not set or change this value until you are ready to - ## migrate to the new format. - ## - ## If you do not have existing metrics from this plugin set to the latest - ## version. - ## - ## Telegraf >=1.6: metric_version = 2 - ## <1.6: metric_version = 1 (or unset) - metric_version = 2 - - ## if the list is empty, then metrics are gathered from all database tables - # table_schema_databases = [] - - ## gather metrics from INFORMATION_SCHEMA.TABLES for databases provided above list - # gather_table_schema = false - - ## gather thread state counts from INFORMATION_SCHEMA.PROCESSLIST - # gather_process_list = false - - ## gather user statistics from INFORMATION_SCHEMA.USER_STATISTICS - # gather_user_statistics = false - - ## gather auto_increment columns and max values from information schema - # gather_info_schema_auto_inc = false - - ## gather metrics from INFORMATION_SCHEMA.INNODB_METRICS - # gather_innodb_metrics = false - - ## gather metrics from SHOW SLAVE STATUS command output - # gather_slave_status = false - - ## gather metrics from all channels from SHOW SLAVE STATUS command output - # gather_all_slave_channels = false - - ## use MariaDB dialect for all channels SHOW SLAVE STATUS - # mariadb_dialect = false - - ## gather metrics from SHOW BINARY LOGS command output - # gather_binary_logs = false - - ## gather metrics from PERFORMANCE_SCHEMA.GLOBAL_VARIABLES - # gather_global_variables = true - - ## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE - # gather_table_io_waits = false - - ## gather metrics from PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS - # gather_table_lock_waits = false - - ## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE - # gather_index_io_waits = false - - ## gather metrics from PERFORMANCE_SCHEMA.EVENT_WAITS - # gather_event_waits = false - - ## gather metrics from PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME - # gather_file_events_stats = false - - ## gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST - # gather_perf_events_statements = false - - ## the limits for metrics form perf_events_statements - # perf_events_statements_digest_text_limit = 120 - # perf_events_statements_limit = 250 - # perf_events_statements_time_limit = 86400 - - ## gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME - # gather_perf_sum_per_acc_per_event = false - - ## list of events to be gathered for gather_perf_sum_per_acc_per_event - ## in case of empty list all events will be gathered - # perf_summary_events = [] - - ## Some queries we may want to run less often (such as SHOW GLOBAL VARIABLES) - ## example: interval_slow = "30m" - # interval_slow = "" - - ## Optional TLS Config (will be used if tls=custom parameter specified in server uri) - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - const ( defaultPerfEventsStatementsDigestTextLimit = 120 defaultPerfEventsStatementsLimit = 250 @@ -158,14 +59,6 @@ const ( defaultGatherGlobalVars = true ) -func (m *Mysql) SampleConfig() string { - return sampleConfig -} - -func (m *Mysql) Description() string { - return "Read metrics from one or many mysql servers" -} - const localhost = "" func (m *Mysql) InitMysql() { diff --git a/plugins/inputs/mysql/mysql_sample_config.go b/plugins/inputs/mysql/mysql_sample_config.go new file mode 100644 index 0000000000000..8551b8e38fa51 --- /dev/null +++ b/plugins/inputs/mysql/mysql_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package mysql + +func (m *Mysql) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nats/README.md b/plugins/inputs/nats/README.md index 59262bfd6cb52..7ddbfe7be3717 100644 --- a/plugins/inputs/nats/README.md +++ b/plugins/inputs/nats/README.md @@ -6,6 +6,7 @@ the NATS [monitoring http server](https://www.nats.io/documentation/server/gnats ## Configuration ```toml +# Provides metrics about the state of a NATS server [[inputs.nats]] ## The address of the monitoring endpoint of the NATS server server = "http://localhost:8222" diff --git a/plugins/inputs/nats/nats.go b/plugins/inputs/nats/nats.go index c9e99824d4de5..98914bb414ae7 100644 --- a/plugins/inputs/nats/nats.go +++ b/plugins/inputs/nats/nats.go @@ -25,22 +25,6 @@ type Nats struct { client *http.Client } -var sampleConfig = ` - ## The address of the monitoring endpoint of the NATS server - server = "http://localhost:8222" - - ## Maximum time to receive response - # response_timeout = "5s" -` - -func (n *Nats) SampleConfig() string { - return sampleConfig -} - -func (n *Nats) Description() string { - return "Provides metrics about the state of a NATS server" -} - func (n *Nats) Gather(acc telegraf.Accumulator) error { address, err := url.Parse(n.Server) if err != nil { diff --git a/plugins/inputs/nats/nats_sample_config.go b/plugins/inputs/nats/nats_sample_config.go new file mode 100644 index 0000000000000..09bf691139469 --- /dev/null +++ b/plugins/inputs/nats/nats_sample_config.go @@ -0,0 +1,11 @@ +//go:build !freebsd || (freebsd && cgo) +// +build !freebsd freebsd,cgo + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nats + +func (n *Nats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nats_consumer/nats_consumer.go b/plugins/inputs/nats_consumer/nats_consumer.go index 44e971b3480be..715206fe4eefe 100644 --- a/plugins/inputs/nats_consumer/nats_consumer.go +++ b/plugins/inputs/nats_consumer/nats_consumer.go @@ -1,4 +1,4 @@ -package natsconsumer +package nats_consumer import ( "context" @@ -64,63 +64,6 @@ type natsConsumer struct { cancel context.CancelFunc } -var sampleConfig = ` - ## urls of NATS servers - servers = ["nats://localhost:4222"] - - ## subject(s) to consume - subjects = ["telegraf"] - - ## name a queue group - queue_group = "telegraf_consumers" - - ## Optional credentials - # username = "" - # password = "" - - ## Optional NATS 2.0 and NATS NGS compatible user credentials - # credentials = "/etc/telegraf/nats.creds" - - ## Use Transport Layer Security - # secure = false - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Sets the limits for pending msgs and bytes for each subscription - ## These shouldn't need to be adjusted except in very high throughput scenarios - # pending_message_limit = 65536 - # pending_bytes_limit = 67108864 - - ## Maximum messages to read from the broker that have not been written by an - ## output. For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message from the queue contains 10 metrics and the - ## output metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - -func (n *natsConsumer) SampleConfig() string { - return sampleConfig -} - -func (n *natsConsumer) Description() string { - return "Read metrics from NATS subject(s)" -} - func (n *natsConsumer) SetParser(parser parsers.Parser) { n.parser = parser } diff --git a/plugins/inputs/nats_consumer/nats_consumer_sample_config.go b/plugins/inputs/nats_consumer/nats_consumer_sample_config.go new file mode 100644 index 0000000000000..baa02fdb27856 --- /dev/null +++ b/plugins/inputs/nats_consumer/nats_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nats_consumer + +func (n *natsConsumer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/neptune_apex/README.md b/plugins/inputs/neptune_apex/README.md index df0de4574eca4..e43dbe084ec8b 100644 --- a/plugins/inputs/neptune_apex/README.md +++ b/plugins/inputs/neptune_apex/README.md @@ -9,6 +9,7 @@ The [Neptune Apex](https://www.neptunesystems.com/) input plugin collects real-t ## Configuration ```toml +# Neptune Apex data collector [[inputs.neptune_apex]] ## The Neptune Apex plugin reads the publicly available status.xml data from a local Apex. ## Measurements will be logged under "apex". diff --git a/plugins/inputs/neptune_apex/neptune_apex.go b/plugins/inputs/neptune_apex/neptune_apex.go index a8934bd01ee94..4a2003c045b2a 100644 --- a/plugins/inputs/neptune_apex/neptune_apex.go +++ b/plugins/inputs/neptune_apex/neptune_apex.go @@ -1,6 +1,6 @@ -// Package neptuneapex implements an input plugin for the Neptune Apex +// Package neptune_apex implements an input plugin for the Neptune Apex // aquarium controller. -package neptuneapex +package neptune_apex import ( "encoding/xml" @@ -55,28 +55,6 @@ type NeptuneApex struct { httpClient *http.Client } -// Description implements telegraf.Input.Description -func (*NeptuneApex) Description() string { - return "Neptune Apex data collector" -} - -// SampleConfig implements telegraf.Input.SampleConfig -func (*NeptuneApex) SampleConfig() string { - return ` - ## The Neptune Apex plugin reads the publicly available status.xml data from a local Apex. - ## Measurements will be logged under "apex". - - ## The base URL of the local Apex(es). If you specify more than one server, they will - ## be differentiated by the "source" tag. - servers = [ - "http://apex.local", - ] - - ## The response_timeout specifies how long to wait for a reply from the Apex. - #response_timeout = "5s" -` -} - // Gather implements telegraf.Input.Gather func (n *NeptuneApex) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/neptune_apex/neptune_apex_sample_config.go b/plugins/inputs/neptune_apex/neptune_apex_sample_config.go new file mode 100644 index 0000000000000..809c69f6c8733 --- /dev/null +++ b/plugins/inputs/neptune_apex/neptune_apex_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package neptune_apex + +func (*NeptuneApex) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/neptune_apex/neptune_apex_test.go b/plugins/inputs/neptune_apex/neptune_apex_test.go index dd2bbeb3d9227..0c2971efe5e65 100644 --- a/plugins/inputs/neptune_apex/neptune_apex_test.go +++ b/plugins/inputs/neptune_apex/neptune_apex_test.go @@ -1,4 +1,4 @@ -package neptuneapex +package neptune_apex import ( "context" diff --git a/plugins/inputs/net/NET_README.md b/plugins/inputs/net/README.md similarity index 100% rename from plugins/inputs/net/NET_README.md rename to plugins/inputs/net/README.md diff --git a/plugins/inputs/net/net.go b/plugins/inputs/net/net.go index bb1621061ae9b..7403349f17a21 100644 --- a/plugins/inputs/net/net.go +++ b/plugins/inputs/net/net.go @@ -20,28 +20,6 @@ type NetIOStats struct { Interfaces []string } -func (n *NetIOStats) Description() string { - return "Read metrics about network interface usage" -} - -var netSampleConfig = ` - ## By default, telegraf gathers stats from any up interface (excluding loopback) - ## Setting interfaces will tell it to gather these explicit interfaces, - ## regardless of status. - ## - # interfaces = ["eth0"] - ## - ## On linux systems telegraf also collects protocol stats. - ## Setting ignore_protocol_stats to true will skip reporting of protocol metrics. - ## - # ignore_protocol_stats = false - ## -` - -func (n *NetIOStats) SampleConfig() string { - return netSampleConfig -} - func (n *NetIOStats) Gather(acc telegraf.Accumulator) error { netio, err := n.ps.NetIO() if err != nil { diff --git a/plugins/inputs/net/net_sample_config.go b/plugins/inputs/net/net_sample_config.go new file mode 100644 index 0000000000000..04d2950d2de20 --- /dev/null +++ b/plugins/inputs/net/net_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package net + +func (n *NetIOStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/net/net_test.go b/plugins/inputs/net/net_test.go index 9ef3b6fb0d91c..68babcf977fc4 100644 --- a/plugins/inputs/net/net_test.go +++ b/plugins/inputs/net/net_test.go @@ -4,6 +4,7 @@ import ( "syscall" "testing" + "github.com/influxdata/telegraf/plugins/inputs/netstat" "github.com/influxdata/telegraf/plugins/inputs/system" "github.com/influxdata/telegraf/testutil" "github.com/shirou/gopsutil/v3/net" @@ -88,7 +89,9 @@ func TestNetStats(t *testing.T) { acc.Metrics = nil - err = (&NetStats{&mps}).Gather(&acc) + err = (&netstat.NetStats{ + PS: &mps, + }).Gather(&acc) require.NoError(t, err) fields3 := map[string]interface{}{ diff --git a/plugins/inputs/net_response/net_response.go b/plugins/inputs/net_response/net_response.go index 043a3c44760ed..1e8b6cf393f8d 100644 --- a/plugins/inputs/net_response/net_response.go +++ b/plugins/inputs/net_response/net_response.go @@ -33,44 +33,6 @@ type NetResponse struct { Protocol string } -var description = "Collect response time of a TCP or UDP connection" - -// Description will return a short string to explain what the plugin does. -func (*NetResponse) Description() string { - return description -} - -var sampleConfig = ` - ## Protocol, must be "tcp" or "udp" - ## NOTE: because the "udp" protocol does not respond to requests, it requires - ## a send/expect string pair (see below). - protocol = "tcp" - ## Server address (default localhost) - address = "localhost:80" - - ## Set timeout - # timeout = "1s" - - ## Set read timeout (only used if expecting a response) - # read_timeout = "1s" - - ## The following options are required for UDP checks. For TCP, they are - ## optional. The plugin will send the given string to the server and then - ## expect to receive the given 'expect' string back. - ## string sent to the server - # send = "ssh" - ## expected string in answer - # expect = "ssh" - - ## Uncomment to remove deprecated fields - # fielddrop = ["result_type", "string_found"] -` - -// SampleConfig will return a complete configuration example with details about each field. -func (*NetResponse) SampleConfig() string { - return sampleConfig -} - // TCPGather will execute if there are TCP tests defined in the configuration. // It will return a map[string]interface{} for fields and a map[string]string for tags func (n *NetResponse) TCPGather() (map[string]string, map[string]interface{}, error) { diff --git a/plugins/inputs/net_response/net_response_sample_config.go b/plugins/inputs/net_response/net_response_sample_config.go new file mode 100644 index 0000000000000..ad4c2a9c4665e --- /dev/null +++ b/plugins/inputs/net_response/net_response_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package net_response + +func (*NetResponse) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/net_response/net_response_test.go b/plugins/inputs/net_response/net_response_test.go index 34a7992e3ddf1..83b23e11b1688 100644 --- a/plugins/inputs/net_response/net_response_test.go +++ b/plugins/inputs/net_response/net_response_test.go @@ -12,17 +12,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestSample(t *testing.T) { - c := &NetResponse{} - output := c.SampleConfig() - require.Equal(t, output, sampleConfig, "Sample config doesn't match") -} - -func TestDescription(t *testing.T) { - c := &NetResponse{} - output := c.Description() - require.Equal(t, output, description, "Description output is not correct") -} func TestBadProtocol(t *testing.T) { var acc testutil.Accumulator // Init plugin diff --git a/plugins/inputs/net/NETSTAT_README.md b/plugins/inputs/netstat/README.md similarity index 91% rename from plugins/inputs/net/NETSTAT_README.md rename to plugins/inputs/netstat/README.md index 95a9ad6124d2e..c29c57d4c37f9 100644 --- a/plugins/inputs/net/NETSTAT_README.md +++ b/plugins/inputs/netstat/README.md @@ -5,7 +5,7 @@ This plugin collects TCP connections state and UDP socket counts by using `lsof` ## Configuration ``` toml -# Collect TCP connections state and UDP socket counts +# Read TCP metrics such as established, time wait and sockets counts. [[inputs.netstat]] # no configuration ``` diff --git a/plugins/inputs/net/netstat.go b/plugins/inputs/netstat/netstat.go similarity index 80% rename from plugins/inputs/net/netstat.go rename to plugins/inputs/netstat/netstat.go index 150f271a31b53..a074e5c076754 100644 --- a/plugins/inputs/net/netstat.go +++ b/plugins/inputs/netstat/netstat.go @@ -1,4 +1,4 @@ -package net +package netstat import ( "fmt" @@ -10,21 +10,11 @@ import ( ) type NetStats struct { - ps system.PS -} - -func (ns *NetStats) Description() string { - return "Read TCP metrics such as established, time wait and sockets counts." -} - -var tcpstatSampleConfig = "" - -func (ns *NetStats) SampleConfig() string { - return tcpstatSampleConfig + PS system.PS } func (ns *NetStats) Gather(acc telegraf.Accumulator) error { - netconns, err := ns.ps.NetConnections() + netconns, err := ns.PS.NetConnections() if err != nil { return fmt.Errorf("error getting net connections info: %s", err) } @@ -67,6 +57,6 @@ func (ns *NetStats) Gather(acc telegraf.Accumulator) error { func init() { inputs.Add("netstat", func() telegraf.Input { - return &NetStats{ps: system.NewSystemPS()} + return &NetStats{PS: system.NewSystemPS()} }) } diff --git a/plugins/inputs/netstat/netstat_sample_config.go b/plugins/inputs/netstat/netstat_sample_config.go new file mode 100644 index 0000000000000..5b52405c1b4c7 --- /dev/null +++ b/plugins/inputs/netstat/netstat_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package netstat + +func (n *NetStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nfsclient/README.md b/plugins/inputs/nfsclient/README.md index ec593254ec245..e5cca8bac56dd 100644 --- a/plugins/inputs/nfsclient/README.md +++ b/plugins/inputs/nfsclient/README.md @@ -8,6 +8,7 @@ If `fullstat` is set, a great deal of additional metrics are collected, detailed ## Configuration ```toml +# Read per-mount NFS client metrics from /proc/self/mountstats [[inputs.nfsclient]] ## Read more low-level metrics (optional, defaults to false) # fullstat = false diff --git a/plugins/inputs/nfsclient/nfsclient.go b/plugins/inputs/nfsclient/nfsclient.go index 7627905336675..5936e8b66ba4b 100644 --- a/plugins/inputs/nfsclient/nfsclient.go +++ b/plugins/inputs/nfsclient/nfsclient.go @@ -25,42 +25,6 @@ type NFSClient struct { mountstatsPath string } -const sampleConfig = ` - ## Read more low-level metrics (optional, defaults to false) - # fullstat = false - - ## List of mounts to explictly include or exclude (optional) - ## The pattern (Go regexp) is matched against the mount point (not the - ## device being mounted). If include_mounts is set, all mounts are ignored - ## unless present in the list. If a mount is listed in both include_mounts - ## and exclude_mounts, it is excluded. Go regexp patterns can be used. - # include_mounts = [] - # exclude_mounts = [] - - ## List of operations to include or exclude from collecting. This applies - ## only when fullstat=true. Symantics are similar to {include,exclude}_mounts: - ## the default is to collect everything; when include_operations is set, only - ## those OPs are collected; when exclude_operations is set, all are collected - ## except those listed. If include and exclude are set, the OP is excluded. - ## See /proc/self/mountstats for a list of valid operations; note that - ## NFSv3 and NFSv4 have different lists. While it is not possible to - ## have different include/exclude lists for NFSv3/4, unused elements - ## in the list should be okay. It is possible to have different lists - ## for different mountpoints: use mulitple [[input.nfsclient]] stanzas, - ## with their own lists. See "include_mounts" above, and be careful of - ## duplicate metrics. - # include_operations = [] - # exclude_operations = [] -` - -func (n *NFSClient) SampleConfig() string { - return sampleConfig -} - -func (n *NFSClient) Description() string { - return "Read per-mount NFS client metrics from /proc/self/mountstats" -} - func convertToUint64(line []string) ([]uint64, error) { /* A "line" of input data (a pre-split array of strings) is processed one field at a time. Each field is converted to diff --git a/plugins/inputs/nfsclient/nfsclient_sample_config.go b/plugins/inputs/nfsclient/nfsclient_sample_config.go new file mode 100644 index 0000000000000..4fd51e37de0a8 --- /dev/null +++ b/plugins/inputs/nfsclient/nfsclient_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nfsclient + +func (n *NFSClient) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nginx/nginx.go b/plugins/inputs/nginx/nginx.go index 5e15022708682..ed3d2c22356fa 100644 --- a/plugins/inputs/nginx/nginx.go +++ b/plugins/inputs/nginx/nginx.go @@ -26,29 +26,6 @@ type Nginx struct { client *http.Client } -var sampleConfig = ` - # An array of Nginx stub_status URI to gather stats. - urls = ["http://localhost/server_status"] - - ## Optional TLS Config - tls_ca = "/etc/telegraf/ca.pem" - tls_cert = "/etc/telegraf/cert.cer" - tls_key = "/etc/telegraf/key.key" - ## Use TLS but skip chain & host verification - insecure_skip_verify = false - - # HTTP response timeout (default: 5s) - response_timeout = "5s" -` - -func (n *Nginx) SampleConfig() string { - return sampleConfig -} - -func (n *Nginx) Description() string { - return "Read Nginx's basic status information (ngx_http_stub_status_module)" -} - func (n *Nginx) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/nginx/nginx_sample_config.go b/plugins/inputs/nginx/nginx_sample_config.go new file mode 100644 index 0000000000000..b531aa6a007e0 --- /dev/null +++ b/plugins/inputs/nginx/nginx_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nginx + +func (n *Nginx) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nginx_plus/README.md b/plugins/inputs/nginx_plus/README.md index 5afb82d2f7c7e..a56908a1d05d5 100644 --- a/plugins/inputs/nginx_plus/README.md +++ b/plugins/inputs/nginx_plus/README.md @@ -12,6 +12,16 @@ Structures for Nginx Plus have been built based on history of [[inputs.nginx_plus]] ## An array of Nginx status URIs to gather stats. urls = ["http://localhost/status"] + + # HTTP response timeout (default: 5s) + response_timeout = "5s" + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false ``` ## Measurements & Fields diff --git a/plugins/inputs/nginx_plus/nginx_plus.go b/plugins/inputs/nginx_plus/nginx_plus.go index 32a8516986f64..276d6e5b8f398 100644 --- a/plugins/inputs/nginx_plus/nginx_plus.go +++ b/plugins/inputs/nginx_plus/nginx_plus.go @@ -26,29 +26,6 @@ type NginxPlus struct { client *http.Client } -var sampleConfig = ` - ## An array of ngx_http_status_module or status URI to gather stats. - urls = ["http://localhost/status"] - - # HTTP response timeout (default: 5s) - response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (n *NginxPlus) SampleConfig() string { - return sampleConfig -} - -func (n *NginxPlus) Description() string { - return "Read Nginx Plus' full status information (ngx_http_status_module)" -} - func (n *NginxPlus) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/nginx_plus/nginx_plus_sample_config.go b/plugins/inputs/nginx_plus/nginx_plus_sample_config.go new file mode 100644 index 0000000000000..c8de4f6087287 --- /dev/null +++ b/plugins/inputs/nginx_plus/nginx_plus_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nginx_plus + +func (n *NginxPlus) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nginx_plus_api/README.md b/plugins/inputs/nginx_plus_api/README.md index 3d8d9bf07a6fc..516e68126081a 100644 --- a/plugins/inputs/nginx_plus_api/README.md +++ b/plugins/inputs/nginx_plus_api/README.md @@ -11,6 +11,16 @@ Nginx Plus is a commercial version of the open source web server Nginx. The use urls = ["http://localhost/api"] # Nginx API version, default: 3 # api_version = 3 + + # HTTP response timeout (default: 5s) + response_timeout = "5s" + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false ``` ## Migration from Nginx Plus (Status) input plugin diff --git a/plugins/inputs/nginx_plus_api/nginx_plus_api.go b/plugins/inputs/nginx_plus_api/nginx_plus_api.go index 09fe3fca3cb01..95d037a0f0a8f 100644 --- a/plugins/inputs/nginx_plus_api/nginx_plus_api.go +++ b/plugins/inputs/nginx_plus_api/nginx_plus_api.go @@ -43,32 +43,6 @@ const ( streamUpstreamsPath = "stream/upstreams" ) -var sampleConfig = ` - ## An array of API URI to gather stats. - urls = ["http://localhost/api"] - - # Nginx API version, default: 3 - # api_version = 3 - - # HTTP response timeout (default: 5s) - response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (n *NginxPlusAPI) SampleConfig() string { - return sampleConfig -} - -func (n *NginxPlusAPI) Description() string { - return "Read Nginx Plus Api documentation" -} - func (n *NginxPlusAPI) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/nginx_plus_api/nginx_plus_api_sample_config.go b/plugins/inputs/nginx_plus_api/nginx_plus_api_sample_config.go new file mode 100644 index 0000000000000..3116e786982c2 --- /dev/null +++ b/plugins/inputs/nginx_plus_api/nginx_plus_api_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nginx_plus_api + +func (n *NginxPlusAPI) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nginx_sts/README.md b/plugins/inputs/nginx_sts/README.md index 7d23fd029dfb5..bacc1a32ad0cc 100644 --- a/plugins/inputs/nginx_sts/README.md +++ b/plugins/inputs/nginx_sts/README.md @@ -12,6 +12,7 @@ Telegraf minimum version: Telegraf 1.15.0 ## Configuration ```toml +# Read Nginx virtual host traffic status module information (nginx-module-sts) [[inputs.nginx_sts]] ## An array of ngx_http_status_module or status URI to gather stats. urls = ["http://localhost/status"] diff --git a/plugins/inputs/nginx_sts/nginx_sts.go b/plugins/inputs/nginx_sts/nginx_sts.go index d3e9118577f6f..7d232791096f5 100644 --- a/plugins/inputs/nginx_sts/nginx_sts.go +++ b/plugins/inputs/nginx_sts/nginx_sts.go @@ -25,29 +25,6 @@ type NginxSTS struct { client *http.Client } -var sampleConfig = ` - ## An array of ngx_http_status_module or status URI to gather stats. - urls = ["http://localhost/status"] - - ## HTTP response timeout (default: 5s) - response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (n *NginxSTS) SampleConfig() string { - return sampleConfig -} - -func (n *NginxSTS) Description() string { - return "Read Nginx virtual host traffic status module information (nginx-module-sts)" -} - func (n *NginxSTS) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/nginx_sts/nginx_sts_sample_config.go b/plugins/inputs/nginx_sts/nginx_sts_sample_config.go new file mode 100644 index 0000000000000..a2b87daea77a2 --- /dev/null +++ b/plugins/inputs/nginx_sts/nginx_sts_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nginx_sts + +func (n *NginxSTS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nginx_upstream_check/README.md b/plugins/inputs/nginx_upstream_check/README.md index 6e5974ebf801e..6321f3f482c01 100644 --- a/plugins/inputs/nginx_upstream_check/README.md +++ b/plugins/inputs/nginx_upstream_check/README.md @@ -11,6 +11,8 @@ checks. This information can be exported in JSON format and parsed by this input ## Configuration ```toml +# Read nginx_upstream_check module status information (https://github.com/yaoweibin/nginx_upstream_check_module) +[[inputs.nginx_upstream_check]] ## An URL where Nginx Upstream check module is enabled ## It should be set to return a JSON formatted response url = "http://127.0.0.1/status?format=json" diff --git a/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go b/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go index 8ad8cc91e8a9e..d925ce87e32d5 100644 --- a/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go +++ b/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go @@ -15,37 +15,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## An URL where Nginx Upstream check module is enabled - ## It should be set to return a JSON formatted response - url = "http://127.0.0.1/status?format=json" - - ## HTTP method - # method = "GET" - - ## Optional HTTP headers - # headers = {"X-Special-Header" = "Special-Value"} - - ## Override HTTP "Host" header - # host_header = "check.example.com" - - ## Timeout for HTTP requests - timeout = "5s" - - ## Optional HTTP Basic Auth credentials - # username = "username" - # password = "pa$$word" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -const description = "Read nginx_upstream_check module status information (https://github.com/yaoweibin/nginx_upstream_check_module)" - type NginxUpstreamCheck struct { URL string `toml:"url"` @@ -76,14 +45,6 @@ func init() { }) } -func (check *NginxUpstreamCheck) SampleConfig() string { - return sampleConfig -} - -func (check *NginxUpstreamCheck) Description() string { - return description -} - type NginxUpstreamCheckData struct { Servers struct { Total uint64 `json:"total"` diff --git a/plugins/inputs/nginx_upstream_check/nginx_upstream_check_sample_config.go b/plugins/inputs/nginx_upstream_check/nginx_upstream_check_sample_config.go new file mode 100644 index 0000000000000..33397b16414dd --- /dev/null +++ b/plugins/inputs/nginx_upstream_check/nginx_upstream_check_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nginx_upstream_check + +func (check *NginxUpstreamCheck) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nginx_vts/README.md b/plugins/inputs/nginx_vts/README.md index 117b0ca24cb17..9d446f8c5e474 100644 --- a/plugins/inputs/nginx_vts/README.md +++ b/plugins/inputs/nginx_vts/README.md @@ -6,10 +6,20 @@ For module configuration details please see its [documentation](https://github.c ## Configuration ```toml -# Read nginx status information using nginx-module-vts module +# Read Nginx virtual host traffic status module information (nginx-module-vts) [[inputs.nginx_vts]] - ## An array of Nginx status URIs to gather stats. + ## An array of ngx_http_status_module or status URI to gather stats. urls = ["http://localhost/status"] + + ## HTTP response timeout (default: 5s) + response_timeout = "5s" + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false ``` ## Measurements & Fields diff --git a/plugins/inputs/nginx_vts/nginx_vts.go b/plugins/inputs/nginx_vts/nginx_vts.go index bca7c62db9b83..29343dd7e6ac5 100644 --- a/plugins/inputs/nginx_vts/nginx_vts.go +++ b/plugins/inputs/nginx_vts/nginx_vts.go @@ -25,29 +25,6 @@ type NginxVTS struct { client *http.Client } -var sampleConfig = ` - ## An array of ngx_http_status_module or status URI to gather stats. - urls = ["http://localhost/status"] - - ## HTTP response timeout (default: 5s) - response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (n *NginxVTS) SampleConfig() string { - return sampleConfig -} - -func (n *NginxVTS) Description() string { - return "Read Nginx virtual host traffic status module information (nginx-module-vts)" -} - func (n *NginxVTS) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/nginx_vts/nginx_vts_sample_config.go b/plugins/inputs/nginx_vts/nginx_vts_sample_config.go new file mode 100644 index 0000000000000..5eabb07e07676 --- /dev/null +++ b/plugins/inputs/nginx_vts/nginx_vts_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nginx_vts + +func (n *NginxVTS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nomad/README.md b/plugins/inputs/nomad/README.md index ea011e07e149a..508f5d64bb969 100644 --- a/plugins/inputs/nomad/README.md +++ b/plugins/inputs/nomad/README.md @@ -7,6 +7,7 @@ The Nomad plugin must grab metrics from every Nomad agent of the cluster. Telegr ## Configuration ```toml +# Read metrics from the Nomad API [[inputs.nomad]] ## URL for the Nomad agent # url = "http://127.0.0.1:4646" diff --git a/plugins/inputs/nomad/nomad.go b/plugins/inputs/nomad/nomad.go index 4498b16db81d2..debd07c126fda 100644 --- a/plugins/inputs/nomad/nomad.go +++ b/plugins/inputs/nomad/nomad.go @@ -25,19 +25,6 @@ type Nomad struct { const timeLayout = "2006-01-02 15:04:05 -0700 MST" -var sampleConfig = ` - ## URL for the Nomad agent - # url = "http://127.0.0.1:4646" - - ## Set response_timeout (default 5 seconds) - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = /path/to/cafile - # tls_cert = /path/to/certfile - # tls_key = /path/to/keyfile -` - func init() { inputs.Add("nomad", func() telegraf.Input { return &Nomad{ @@ -46,16 +33,6 @@ func init() { }) } -// SampleConfig returns a sample config -func (n *Nomad) SampleConfig() string { - return sampleConfig -} - -// Description returns a description of the plugin -func (n *Nomad) Description() string { - return "Read metrics from the Nomad API" -} - func (n *Nomad) Init() error { if n.URL == "" { n.URL = "http://127.0.0.1:4646" diff --git a/plugins/inputs/nomad/nomad_sample_config.go b/plugins/inputs/nomad/nomad_sample_config.go new file mode 100644 index 0000000000000..b8750dfc0e295 --- /dev/null +++ b/plugins/inputs/nomad/nomad_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nomad + +func (n *Nomad) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nsd/nsd.go b/plugins/inputs/nsd/nsd.go index 6c8998129cf90..948f205953a80 100644 --- a/plugins/inputs/nsd/nsd.go +++ b/plugins/inputs/nsd/nsd.go @@ -32,34 +32,6 @@ type NSD struct { var defaultBinary = "/usr/sbin/nsd-control" var defaultTimeout = config.Duration(time.Second) -var sampleConfig = ` - ## Address of server to connect to, optionally ':port'. Defaults to the - ## address in the nsd config file. - server = "127.0.0.1:8953" - - ## If running as a restricted user you can prepend sudo for additional access: - # use_sudo = false - - ## The default location of the nsd-control binary can be overridden with: - # binary = "/usr/sbin/nsd-control" - - ## The default location of the nsd config file can be overridden with: - # config_file = "/etc/nsd/nsd.conf" - - ## The default timeout of 1s can be overridden with: - # timeout = "1s" -` - -// Description displays what this plugin is about -func (s *NSD) Description() string { - return "A plugin to collect stats from the NSD authoritative DNS name server" -} - -// SampleConfig displays configuration instructions -func (s *NSD) SampleConfig() string { - return sampleConfig -} - // Shell out to nsd_stat and return the output func nsdRunner(cmdName string, timeout config.Duration, useSudo bool, server string, configFile string) (*bytes.Buffer, error) { cmdArgs := []string{"stats_noreset"} diff --git a/plugins/inputs/nsd/nsd_sample_config.go b/plugins/inputs/nsd/nsd_sample_config.go new file mode 100644 index 0000000000000..ed25231c7fcf9 --- /dev/null +++ b/plugins/inputs/nsd/nsd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nsd + +func (s *NSD) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nsq/README.md b/plugins/inputs/nsq/README.md index 78ba28d49b11f..6d25a9c4207f8 100644 --- a/plugins/inputs/nsq/README.md +++ b/plugins/inputs/nsq/README.md @@ -3,7 +3,7 @@ ## Configuration ```toml -# Description +# Read NSQ topic and channel statistics. [[inputs.nsq]] ## An array of NSQD HTTP API endpoints endpoints = ["http://localhost:4151"] diff --git a/plugins/inputs/nsq/nsq.go b/plugins/inputs/nsq/nsq.go index 58f60192b96d0..dec8ccd741c2f 100644 --- a/plugins/inputs/nsq/nsq.go +++ b/plugins/inputs/nsq/nsq.go @@ -44,18 +44,6 @@ type NSQ struct { httpClient *http.Client } -var sampleConfig = ` - ## An array of NSQD HTTP API endpoints - endpoints = ["http://localhost:4151"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - const ( requestPattern = `%s/stats?format=json` ) @@ -70,14 +58,6 @@ func New() *NSQ { return &NSQ{} } -func (n *NSQ) SampleConfig() string { - return sampleConfig -} - -func (n *NSQ) Description() string { - return "Read NSQ topic and channel statistics." -} - func (n *NSQ) Gather(acc telegraf.Accumulator) error { var err error diff --git a/plugins/inputs/nsq/nsq_sample_config.go b/plugins/inputs/nsq/nsq_sample_config.go new file mode 100644 index 0000000000000..75efaba5a5793 --- /dev/null +++ b/plugins/inputs/nsq/nsq_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nsq + +func (n *NSQ) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nsq_consumer/nsq_consumer.go b/plugins/inputs/nsq_consumer/nsq_consumer.go index fb62f3eb86176..086c71722aac0 100644 --- a/plugins/inputs/nsq_consumer/nsq_consumer.go +++ b/plugins/inputs/nsq_consumer/nsq_consumer.go @@ -49,48 +49,11 @@ type NSQConsumer struct { cancel context.CancelFunc } -var sampleConfig = ` - ## An array representing the NSQD TCP HTTP Endpoints - nsqd = ["localhost:4150"] - - ## An array representing the NSQLookupd HTTP Endpoints - nsqlookupd = ["localhost:4161"] - topic = "telegraf" - channel = "consumer" - max_in_flight = 100 - - ## Maximum messages to read from the broker that have not been written by an - ## output. For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message from the queue contains 10 metrics and the - ## output metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - // SetParser takes the data_format from the config and finds the right parser for that format func (n *NSQConsumer) SetParser(parser parsers.Parser) { n.parser = parser } -// SampleConfig returns config values for generating a sample configuration file -func (n *NSQConsumer) SampleConfig() string { - return sampleConfig -} - -// Description prints description string -func (n *NSQConsumer) Description() string { - return "Read NSQ topic for metrics." -} - // Start pulls data from nsq func (n *NSQConsumer) Start(ac telegraf.Accumulator) error { acc := ac.WithTracking(n.MaxUndeliveredMessages) diff --git a/plugins/inputs/nsq_consumer/nsq_consumer_sample_config.go b/plugins/inputs/nsq_consumer/nsq_consumer_sample_config.go new file mode 100644 index 0000000000000..58597d2b66199 --- /dev/null +++ b/plugins/inputs/nsq_consumer/nsq_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nsq_consumer + +func (n *NSQConsumer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nstat/README.md b/plugins/inputs/nstat/README.md index 0e2fa217300c7..72d4ffb4016c8 100644 --- a/plugins/inputs/nstat/README.md +++ b/plugins/inputs/nstat/README.md @@ -30,14 +30,16 @@ So if nothing is given, no paths in config and in env vars, the plugin takes the The sample config file ```toml +# Collect kernel snmp counters and network interface statistics [[inputs.nstat]] - ## file paths - ## e.g: /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6 - # proc_net_netstat = "" - # proc_net_snmp = "" - # proc_net_snmp6 = "" + ## file paths for proc files. If empty default paths will be used: + ## /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6 + ## These can also be overridden with env variables, see README. + proc_net_netstat = "/proc/net/netstat" + proc_net_snmp = "/proc/net/snmp" + proc_net_snmp6 = "/proc/net/snmp6" ## dump metrics with 0 values too - # dump_zeros = true + dump_zeros = true ``` In case that `proc_net_snmp6` path doesn't exist (e.g. IPv6 is not enabled) no error would be raised. diff --git a/plugins/inputs/nstat/nstat.go b/plugins/inputs/nstat/nstat.go index b5ada855479c9..2feddb3b6fb6d 100644 --- a/plugins/inputs/nstat/nstat.go +++ b/plugins/inputs/nstat/nstat.go @@ -38,25 +38,6 @@ type Nstat struct { DumpZeros bool `toml:"dump_zeros"` } -var sampleConfig = ` - ## file paths for proc files. If empty default paths will be used: - ## /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6 - ## These can also be overridden with env variables, see README. - proc_net_netstat = "/proc/net/netstat" - proc_net_snmp = "/proc/net/snmp" - proc_net_snmp6 = "/proc/net/snmp6" - ## dump metrics with 0 values too - dump_zeros = true -` - -func (ns *Nstat) Description() string { - return "Collect kernel snmp counters and network interface statistics" -} - -func (ns *Nstat) SampleConfig() string { - return sampleConfig -} - func (ns *Nstat) Gather(acc telegraf.Accumulator) error { // load paths, get from env if config values are empty ns.loadPaths() diff --git a/plugins/inputs/nstat/nstat_sample_config.go b/plugins/inputs/nstat/nstat_sample_config.go new file mode 100644 index 0000000000000..ffed972bcfd07 --- /dev/null +++ b/plugins/inputs/nstat/nstat_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nstat + +func (ns *Nstat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ntpq/README.md b/plugins/inputs/ntpq/README.md index 41684cc40550c..79838b5c002e9 100644 --- a/plugins/inputs/ntpq/README.md +++ b/plugins/inputs/ntpq/README.md @@ -27,9 +27,9 @@ server (RMS of difference of multiple time samples, milliseconds); ## Configuration ```toml -# Get standard NTP query metrics, requires ntpq executable +# Get standard NTP query metrics, requires ntpq executable. [[inputs.ntpq]] - ## If false, add -n for ntpq command. Can reduce metric gather times. + ## If false, set the -n ntpq flag. Can reduce metric gather time. dns_lookup = true ``` diff --git a/plugins/inputs/ntpq/ntpq.go b/plugins/inputs/ntpq/ntpq.go index d84df60f7ed54..91ba1c4446bfa 100644 --- a/plugins/inputs/ntpq/ntpq.go +++ b/plugins/inputs/ntpq/ntpq.go @@ -30,17 +30,6 @@ type NTPQ struct { DNSLookup bool `toml:"dns_lookup"` } -func (n *NTPQ) Description() string { - return "Get standard NTP query metrics, requires ntpq executable." -} - -func (n *NTPQ) SampleConfig() string { - return ` - ## If false, set the -n ntpq flag. Can reduce metric gather time. - dns_lookup = true -` -} - func (n *NTPQ) Gather(acc telegraf.Accumulator) error { out, err := n.runQ() if err != nil { diff --git a/plugins/inputs/ntpq/ntpq_sample_config.go b/plugins/inputs/ntpq/ntpq_sample_config.go new file mode 100644 index 0000000000000..71afaf57eb479 --- /dev/null +++ b/plugins/inputs/ntpq/ntpq_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ntpq + +func (n *NTPQ) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/nvidia_smi/nvidia_smi.go b/plugins/inputs/nvidia_smi/nvidia_smi.go index 68f25ba428611..bc4b571575b12 100644 --- a/plugins/inputs/nvidia_smi/nvidia_smi.go +++ b/plugins/inputs/nvidia_smi/nvidia_smi.go @@ -23,24 +23,6 @@ type NvidiaSMI struct { Timeout config.Duration } -// Description returns the description of the NvidiaSMI plugin -func (smi *NvidiaSMI) Description() string { - return "Pulls statistics from nvidia GPUs attached to the host" -} - -// SampleConfig returns the sample configuration for the NvidiaSMI plugin -func (smi *NvidiaSMI) SampleConfig() string { - return ` - ## Optional: path to nvidia-smi binary, defaults "/usr/bin/nvidia-smi" - ## We will first try to locate the nvidia-smi binary with the explicitly specified value (or default value), - ## if it is not found, we will try to locate it on PATH(exec.LookPath), if it is still not found, an error will be returned - # bin_path = "/usr/bin/nvidia-smi" - - ## Optional: timeout for GPU polling - # timeout = "5s" -` -} - func (smi *NvidiaSMI) Init() error { if _, err := os.Stat(smi.BinPath); os.IsNotExist(err) { binPath, err := exec.LookPath("nvidia-smi") diff --git a/plugins/inputs/nvidia_smi/nvidia_smi_sample_config.go b/plugins/inputs/nvidia_smi/nvidia_smi_sample_config.go new file mode 100644 index 0000000000000..9919a1f1b0915 --- /dev/null +++ b/plugins/inputs/nvidia_smi/nvidia_smi_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package nvidia_smi + +func (smi *NvidiaSMI) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/opcua/README.md b/plugins/inputs/opcua/README.md index 7ae752fe1d449..e8505c6943c1f 100644 --- a/plugins/inputs/opcua/README.md +++ b/plugins/inputs/opcua/README.md @@ -8,6 +8,7 @@ Plugin minimum tested version: 1.16 ## Configuration ```toml +# Retrieve data from OPCUA devices [[inputs.opcua]] ## Metric name # name = "opcua" @@ -89,7 +90,7 @@ Plugin minimum tested version: 1.16 # {name="", namespace="", identifier_type="", identifier=""}, # {name="", namespace="", identifier_type="", identifier=""}, #] - + ## Enable workarounds required by some devices to work correctly # [inputs.opcua.workarounds] ## Set additional valid status codes, StatusOK (0x0) is always considered valid diff --git a/plugins/inputs/opcua/opcua_client.go b/plugins/inputs/opcua/opcua.go similarity index 78% rename from plugins/inputs/opcua/opcua_client.go rename to plugins/inputs/opcua/opcua.go index 09245c96a05f9..66fbdcb68c91f 100644 --- a/plugins/inputs/opcua/opcua_client.go +++ b/plugins/inputs/opcua/opcua.go @@ -1,4 +1,4 @@ -package opcua_client +package opcua import ( "context" @@ -106,104 +106,6 @@ const ( Connected ) -const description = `Retrieve data from OPCUA devices` -const sampleConfig = ` - ## Metric name - # name = "opcua" - # - ## OPC UA Endpoint URL - # endpoint = "opc.tcp://localhost:4840" - # - ## Maximum time allowed to establish a connect to the endpoint. - # connect_timeout = "10s" - # - ## Maximum time allowed for a request over the estabilished connection. - # request_timeout = "5s" - # - ## Security policy, one of "None", "Basic128Rsa15", "Basic256", - ## "Basic256Sha256", or "auto" - # security_policy = "auto" - # - ## Security mode, one of "None", "Sign", "SignAndEncrypt", or "auto" - # security_mode = "auto" - # - ## Path to cert.pem. Required when security mode or policy isn't "None". - ## If cert path is not supplied, self-signed cert and key will be generated. - # certificate = "/etc/telegraf/cert.pem" - # - ## Path to private key.pem. Required when security mode or policy isn't "None". - ## If key path is not supplied, self-signed cert and key will be generated. - # private_key = "/etc/telegraf/key.pem" - # - ## Authentication Method, one of "Certificate", "UserName", or "Anonymous". To - ## authenticate using a specific ID, select 'Certificate' or 'UserName' - # auth_method = "Anonymous" - # - ## Username. Required for auth_method = "UserName" - # username = "" - # - ## Password. Required for auth_method = "UserName" - # password = "" - # - ## Option to select the metric timestamp to use. Valid options are: - ## "gather" -- uses the time of receiving the data in telegraf - ## "server" -- uses the timestamp provided by the server - ## "source" -- uses the timestamp provided by the source - # timestamp = "gather" - # - ## Node ID configuration - ## name - field name to use in the output - ## namespace - OPC UA namespace of the node (integer value 0 thru 3) - ## identifier_type - OPC UA ID type (s=string, i=numeric, g=guid, b=opaque) - ## identifier - OPC UA ID (tag as shown in opcua browser) - ## Example: - ## {name="ProductUri", namespace="0", identifier_type="i", identifier="2262"} - # nodes = [ - # {name="", namespace="", identifier_type="", identifier=""}, - # {name="", namespace="", identifier_type="", identifier=""}, - #] - # - ## Node Group - ## Sets defaults for OPC UA namespace and ID type so they aren't required in - ## every node. A group can also have a metric name that overrides the main - ## plugin metric name. - ## - ## Multiple node groups are allowed - #[[inputs.opcua.group]] - ## Group Metric name. Overrides the top level name. If unset, the - ## top level name is used. - # name = - # - ## Group default namespace. If a node in the group doesn't set its - ## namespace, this is used. - # namespace = - # - ## Group default identifier type. If a node in the group doesn't set its - ## namespace, this is used. - # identifier_type = - # - ## Node ID Configuration. Array of nodes with the same settings as above. - # nodes = [ - # {name="", namespace="", identifier_type="", identifier=""}, - # {name="", namespace="", identifier_type="", identifier=""}, - #] - - ## Enable workarounds required by some devices to work correctly - # [inputs.opcua.workarounds] - ## Set additional valid status codes, StatusOK (0x0) is always considered valid - # additional_valid_status_codes = ["0xC0"] -` - -// Description will appear directly above the plugin definition in the config file -func (o *OpcUA) Description() string { - return description -} - -// SampleConfig will populate the sample configuration portion of the plugin's configuration -func (o *OpcUA) SampleConfig() string { - return sampleConfig -} - // Init will initialize all tags func (o *OpcUA) Init() error { o.state = Disconnected diff --git a/plugins/inputs/opcua/opcua_sample_config.go b/plugins/inputs/opcua/opcua_sample_config.go new file mode 100644 index 0000000000000..4d8f96ceabd4a --- /dev/null +++ b/plugins/inputs/opcua/opcua_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package opcua + +func (o *OpcUA) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/opcua/opcua_client_test.go b/plugins/inputs/opcua/opcua_test.go similarity index 99% rename from plugins/inputs/opcua/opcua_client_test.go rename to plugins/inputs/opcua/opcua_test.go index 6f05d9d803880..c4a866f839570 100644 --- a/plugins/inputs/opcua/opcua_client_test.go +++ b/plugins/inputs/opcua/opcua_test.go @@ -1,4 +1,4 @@ -package opcua_client +package opcua import ( "context" diff --git a/plugins/inputs/opcua/opcua_util.go b/plugins/inputs/opcua/opcua_util.go index 0afe07115e197..e5335babae2ad 100644 --- a/plugins/inputs/opcua/opcua_util.go +++ b/plugins/inputs/opcua/opcua_util.go @@ -1,4 +1,4 @@ -package opcua_client +package opcua import ( "crypto/ecdsa" diff --git a/plugins/inputs/openldap/README.md b/plugins/inputs/openldap/README.md index 9b2dd44214d14..2acc0366143f8 100644 --- a/plugins/inputs/openldap/README.md +++ b/plugins/inputs/openldap/README.md @@ -7,6 +7,7 @@ This plugin gathers metrics from OpenLDAP's cn=Monitor backend. To use this plugin you must enable the [slapd monitoring](https://www.openldap.org/devel/admin/monitoringslapd.html) backend. ```toml +# OpenLDAP cn=Monitor plugin [[inputs.openldap]] host = "localhost" port = 389 @@ -25,7 +26,7 @@ To use this plugin you must enable the [slapd monitoring](https://www.openldap.o # dn/password to bind with. If bind_dn is empty, an anonymous bind is performed. bind_dn = "" bind_password = "" - + # reverse metric names so they sort more naturally # Defaults to false if unset, but is set to true when generating a new config reverse_metric_names = true diff --git a/plugins/inputs/openldap/openldap.go b/plugins/inputs/openldap/openldap.go index a8622922f8466..4853ff19d11da 100644 --- a/plugins/inputs/openldap/openldap.go +++ b/plugins/inputs/openldap/openldap.go @@ -25,30 +25,6 @@ type Openldap struct { ReverseMetricNames bool } -const sampleConfig string = ` - host = "localhost" - port = 389 - - # ldaps, starttls, or no encryption. default is an empty string, disabling all encryption. - # note that port will likely need to be changed to 636 for ldaps - # valid options: "" | "starttls" | "ldaps" - tls = "" - - # skip peer certificate verification. Default is false. - insecure_skip_verify = false - - # Path to PEM-encoded Root certificate to use to verify server certificate - tls_ca = "/etc/ssl/certs.pem" - - # dn/password to bind with. If bind_dn is empty, an anonymous bind is performed. - bind_dn = "" - bind_password = "" - - # Reverse metric names so they sort more naturally. Recommended. - # This defaults to false if unset, but is set to true when generating a new config - reverse_metric_names = true -` - var searchBase = "cn=Monitor" var searchFilter = "(|(objectClass=monitorCounterObject)(objectClass=monitorOperation)(objectClass=monitoredObject))" var searchAttrs = []string{"monitorCounter", "monitorOpInitiated", "monitorOpCompleted", "monitoredInfo"} @@ -65,14 +41,6 @@ var attrTranslate = map[string]string{ "olmMDBEntries": "_mdb_entries", } -func (o *Openldap) SampleConfig() string { - return sampleConfig -} - -func (o *Openldap) Description() string { - return "OpenLDAP cn=Monitor plugin" -} - // return an initialized Openldap func NewOpenldap() *Openldap { return &Openldap{ diff --git a/plugins/inputs/openldap/openldap_sample_config.go b/plugins/inputs/openldap/openldap_sample_config.go new file mode 100644 index 0000000000000..f9705bd7947f1 --- /dev/null +++ b/plugins/inputs/openldap/openldap_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package openldap + +func (o *Openldap) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/openntpd/README.md b/plugins/inputs/openntpd/README.md index f1b418e7849e2..c8cb7edabbc2e 100644 --- a/plugins/inputs/openntpd/README.md +++ b/plugins/inputs/openntpd/README.md @@ -23,6 +23,7 @@ server (RMS of difference of multiple time samples, milliseconds); ## Configuration ```toml +# Get standard NTP query metrics from OpenNTPD. [[inputs.openntpd]] ## Run ntpctl binary with sudo. # use_sudo = false diff --git a/plugins/inputs/openntpd/openntpd.go b/plugins/inputs/openntpd/openntpd.go index 2689c9cc7c845..b5c293cc39473 100644 --- a/plugins/inputs/openntpd/openntpd.go +++ b/plugins/inputs/openntpd/openntpd.go @@ -49,23 +49,6 @@ type Openntpd struct { var defaultBinary = "/usr/sbin/ntpctl" var defaultTimeout = config.Duration(5 * time.Second) -func (n *Openntpd) Description() string { - return "Get standard NTP query metrics from OpenNTPD." -} - -func (n *Openntpd) SampleConfig() string { - return ` - ## Run ntpctl binary with sudo. - # use_sudo = false - - ## Location of the ntpctl binary. - # binary = "/usr/sbin/ntpctl" - - ## Maximum time the ntpctl binary is allowed to run. - # timeout = "5ms" - ` -} - // Shell out to ntpctl and return the output func openntpdRunner(cmdName string, timeout config.Duration, useSudo bool) (*bytes.Buffer, error) { cmdArgs := []string{"-s", "peers"} diff --git a/plugins/inputs/openntpd/openntpd_sample_config.go b/plugins/inputs/openntpd/openntpd_sample_config.go new file mode 100644 index 0000000000000..a6a5964d08329 --- /dev/null +++ b/plugins/inputs/openntpd/openntpd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package openntpd + +func (n *Openntpd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/opensmtpd/README.md b/plugins/inputs/opensmtpd/README.md index ba360e45bf6fa..5aaad1a35969e 100644 --- a/plugins/inputs/opensmtpd/README.md +++ b/plugins/inputs/opensmtpd/README.md @@ -5,6 +5,7 @@ This plugin gathers stats from [OpenSMTPD - a FREE implementation of the server- ## Configuration ```toml +# A plugin to collect stats from Opensmtpd - a validating, recursive, and caching DNS resolver [[inputs.opensmtpd]] ## If running as a restricted user you can prepend sudo for additional access: #use_sudo = false diff --git a/plugins/inputs/opensmtpd/opensmtpd.go b/plugins/inputs/opensmtpd/opensmtpd.go index 9ce6ec5421ff1..2b670c03de92c 100644 --- a/plugins/inputs/opensmtpd/opensmtpd.go +++ b/plugins/inputs/opensmtpd/opensmtpd.go @@ -30,26 +30,6 @@ type Opensmtpd struct { var defaultBinary = "/usr/sbin/smtpctl" var defaultTimeout = config.Duration(time.Second) -var sampleConfig = ` - ## If running as a restricted user you can prepend sudo for additional access: - #use_sudo = false - - ## The default location of the smtpctl binary can be overridden with: - binary = "/usr/sbin/smtpctl" - - ## The default timeout of 1000ms can be overridden with (in milliseconds): - timeout = 1000 -` - -func (s *Opensmtpd) Description() string { - return "A plugin to collect stats from Opensmtpd - a validating, recursive, and caching DNS resolver " -} - -// SampleConfig displays configuration instructions -func (s *Opensmtpd) SampleConfig() string { - return sampleConfig -} - // Shell out to opensmtpd_stat and return the output func opensmtpdRunner(cmdName string, timeout config.Duration, useSudo bool) (*bytes.Buffer, error) { cmdArgs := []string{"show", "stats"} diff --git a/plugins/inputs/opensmtpd/opensmtpd_sample_config.go b/plugins/inputs/opensmtpd/opensmtpd_sample_config.go new file mode 100644 index 0000000000000..d4f3cc03dbf69 --- /dev/null +++ b/plugins/inputs/opensmtpd/opensmtpd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package opensmtpd + +func (s *Opensmtpd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/openstack/README.md b/plugins/inputs/openstack/README.md index 6efbe46d4a27a..0a70426d61254 100644 --- a/plugins/inputs/openstack/README.md +++ b/plugins/inputs/openstack/README.md @@ -51,6 +51,8 @@ Also, consider polling OpenStack services at different intervals depending on yo ### Configuration ```toml +# Collects performance metrics from OpenStack services +[[inputs.openstack]] ## The recommended interval to poll is '30m' ## The identity endpoint to authenticate against and get the service catalog from. @@ -66,7 +68,7 @@ Also, consider polling OpenStack services at different intervals depending on yo username = "admin" password = "password" - ## Available services are: + ## Available services are: ## "agents", "aggregates", "flavors", "hypervisors", "networks", "nova_services", ## "ports", "projects", "servers", "services", "stacks", "storage_pools", "subnets", "volumes" # enabled_services = ["services", "projects", "hypervisors", "flavors", "networks", "volumes"] @@ -90,7 +92,7 @@ Also, consider polling OpenStack services at different intervals depending on yo ## Use TLS but skip chain & host verification # insecure_skip_verify = false - ## Options for tags received from Openstack + ## Options for tags received from Openstack # tag_prefix = "openstack_tag_" # tag_value = "true" diff --git a/plugins/inputs/openstack/openstack.go b/plugins/inputs/openstack/openstack.go index 3a2edc0526199..1da597946bfe3 100644 --- a/plugins/inputs/openstack/openstack.go +++ b/plugins/inputs/openstack/openstack.go @@ -105,71 +105,6 @@ func (o *OpenStack) convertTimeFormat(t time.Time) interface{} { return t.UnixNano() } -// Description returns a description string of the input plugin and implements -// the Input interface. -func (o *OpenStack) Description() string { - return "Collects performance metrics from OpenStack services" -} - -// sampleConfig is a sample configuration file entry. -var sampleConfig = ` - ## The recommended interval to poll is '30m' - - ## The identity endpoint to authenticate against and get the service catalog from. - authentication_endpoint = "https://my.openstack.cloud:5000" - - ## The domain to authenticate against when using a V3 identity endpoint. - # domain = "default" - - ## The project to authenticate as. - # project = "admin" - - ## User authentication credentials. Must have admin rights. - username = "admin" - password = "password" - - ## Available services are: - ## "agents", "aggregates", "flavors", "hypervisors", "networks", "nova_services", - ## "ports", "projects", "servers", "services", "stacks", "storage_pools", "subnets", "volumes" - # enabled_services = ["services", "projects", "hypervisors", "flavors", "networks", "volumes"] - - ## Collect Server Diagnostics - # server_diagnotics = false - - ## output secrets (such as adminPass(for server) and UserID(for volume)). - # output_secrets = false - - ## Amount of time allowed to complete the HTTP(s) request. - # timeout = "5s" - - ## HTTP Proxy support - # http_proxy_url = "" - - ## Optional TLS Config - # tls_ca = /path/to/cafile - # tls_cert = /path/to/certfile - # tls_key = /path/to/keyfile - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Options for tags received from Openstack - # tag_prefix = "openstack_tag_" - # tag_value = "true" - - ## Timestamp format for timestamp data recieved from Openstack. - ## If false format is unix nanoseconds. - # human_readable_timestamps = false - - ## Measure Openstack call duration - # measure_openstack_requests = false -` - -// SampleConfig return a sample configuration file for auto-generation and -// implements the Input interface. -func (o *OpenStack) SampleConfig() string { - return sampleConfig -} - // initialize performs any necessary initialization functions func (o *OpenStack) Init() error { if len(o.EnabledServices) == 0 { diff --git a/plugins/inputs/openstack/openstack_sample_config.go b/plugins/inputs/openstack/openstack_sample_config.go new file mode 100644 index 0000000000000..7168ea6e24b29 --- /dev/null +++ b/plugins/inputs/openstack/openstack_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package openstack + +func (o *OpenStack) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/opentelemetry/README.md b/plugins/inputs/opentelemetry/README.md index 0f83a469cd59c..f876cf73a84dc 100644 --- a/plugins/inputs/opentelemetry/README.md +++ b/plugins/inputs/opentelemetry/README.md @@ -5,6 +5,7 @@ This plugin receives traces, metrics and logs from [OpenTelemetry](https://opent ## Configuration ```toml +# Receive OpenTelemetry traces, metrics, and logs over gRPC [[inputs.opentelemetry]] ## Override the default (0.0.0.0:4317) destination OpenTelemetry gRPC service ## address:port diff --git a/plugins/inputs/opentelemetry/opentelemetry.go b/plugins/inputs/opentelemetry/opentelemetry.go index 85f32a7695efa..e733b37c9de01 100644 --- a/plugins/inputs/opentelemetry/opentelemetry.go +++ b/plugins/inputs/opentelemetry/opentelemetry.go @@ -30,39 +30,6 @@ type OpenTelemetry struct { wg sync.WaitGroup } -const sampleConfig = ` - ## Override the default (0.0.0.0:4317) destination OpenTelemetry gRPC service - ## address:port - # service_address = "0.0.0.0:4317" - - ## Override the default (5s) new connection timeout - # timeout = "5s" - - ## Override the default (prometheus-v1) metrics schema. - ## Supports: "prometheus-v1", "prometheus-v2" - ## For more information about the alternatives, read the Prometheus input - ## plugin notes. - # metrics_schema = "prometheus-v1" - - ## Optional TLS Config. - ## For advanced options: https://github.com/influxdata/telegraf/blob/v1.18.3/docs/TLS.md - ## - ## Set one or more allowed client CA certificate file names to - ## enable mutually authenticated TLS connections. - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - ## Add service certificate and key. - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" -` - -func (o *OpenTelemetry) SampleConfig() string { - return sampleConfig -} - -func (o *OpenTelemetry) Description() string { - return "Receive OpenTelemetry traces, metrics, and logs over gRPC" -} - func (o *OpenTelemetry) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/opentelemetry/opentelemetry_sample_config.go b/plugins/inputs/opentelemetry/opentelemetry_sample_config.go new file mode 100644 index 0000000000000..82380c71d9cac --- /dev/null +++ b/plugins/inputs/opentelemetry/opentelemetry_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package opentelemetry + +func (o *OpenTelemetry) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/openweathermap/README.md b/plugins/inputs/openweathermap/README.md index 304c5881163e4..dc2d44a121eae 100644 --- a/plugins/inputs/openweathermap/README.md +++ b/plugins/inputs/openweathermap/README.md @@ -13,6 +13,7 @@ condition ID, icon, and main is at [weather conditions][]. ## Configuration ```toml +# Read current weather and forecasts data from openweathermap.org [[inputs.openweathermap]] ## OpenWeatherMap API key. app_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" diff --git a/plugins/inputs/openweathermap/openweathermap.go b/plugins/inputs/openweathermap/openweathermap.go index cfab0d20e548a..7876d81ddc16c 100644 --- a/plugins/inputs/openweathermap/openweathermap.go +++ b/plugins/inputs/openweathermap/openweathermap.go @@ -42,45 +42,6 @@ type OpenWeatherMap struct { baseParsedURL *url.URL } -var sampleConfig = ` - ## OpenWeatherMap API key. - app_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - - ## City ID's to collect weather data from. - city_id = ["5391959"] - - ## Language of the description field. Can be one of "ar", "bg", - ## "ca", "cz", "de", "el", "en", "fa", "fi", "fr", "gl", "hr", "hu", - ## "it", "ja", "kr", "la", "lt", "mk", "nl", "pl", "pt", "ro", "ru", - ## "se", "sk", "sl", "es", "tr", "ua", "vi", "zh_cn", "zh_tw" - # lang = "en" - - ## APIs to fetch; can contain "weather" or "forecast". - fetch = ["weather", "forecast"] - - ## OpenWeatherMap base URL - # base_url = "https://api.openweathermap.org/" - - ## Timeout for HTTP response. - # response_timeout = "5s" - - ## Preferred unit system for temperature and wind speed. Can be one of - ## "metric", "imperial", or "standard". - # units = "metric" - - ## Query interval; OpenWeatherMap updates their weather data every 10 - ## minutes. - interval = "10m" -` - -func (n *OpenWeatherMap) SampleConfig() string { - return sampleConfig -} - -func (n *OpenWeatherMap) Description() string { - return "Read current weather and forecasts data from openweathermap.org" -} - func (n *OpenWeatherMap) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup var strs []string diff --git a/plugins/inputs/openweathermap/openweathermap_sample_config.go b/plugins/inputs/openweathermap/openweathermap_sample_config.go new file mode 100644 index 0000000000000..e6444a6b1e910 --- /dev/null +++ b/plugins/inputs/openweathermap/openweathermap_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package openweathermap + +func (n *OpenWeatherMap) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/passenger/passenger.go b/plugins/inputs/passenger/passenger.go index fbd016af60a0e..1259b7716b376 100644 --- a/plugins/inputs/passenger/passenger.go +++ b/plugins/inputs/passenger/passenger.go @@ -125,26 +125,6 @@ func (p *process) getUptime() int64 { return uptime } -var sampleConfig = ` - ## Path of passenger-status. - ## - ## Plugin gather metric via parsing XML output of passenger-status - ## More information about the tool: - ## https://www.phusionpassenger.com/library/admin/apache/overall_status_report.html - ## - ## If no path is specified, then the plugin simply execute passenger-status - ## hopefully it can be found in your PATH - command = "passenger-status -v --show=xml" -` - -func (p *passenger) SampleConfig() string { - return sampleConfig -} - -func (p *passenger) Description() string { - return "Read metrics of passenger using passenger-status" -} - func (p *passenger) Gather(acc telegraf.Accumulator) error { if p.Command == "" { p.Command = "passenger-status -v --show=xml" diff --git a/plugins/inputs/passenger/passenger_sample_config.go b/plugins/inputs/passenger/passenger_sample_config.go new file mode 100644 index 0000000000000..7a793b01c313c --- /dev/null +++ b/plugins/inputs/passenger/passenger_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package passenger + +func (p *passenger) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/pf/README.md b/plugins/inputs/pf/README.md index cef92498791e9..8f97af524df18 100644 --- a/plugins/inputs/pf/README.md +++ b/plugins/inputs/pf/README.md @@ -20,7 +20,12 @@ telegraf ALL=(root) NOPASSWD: /sbin/pfctl -s info ## Configuration ```toml - # use sudo to run pfctl +# Gather counters from PF +[[inputs.pf]] + ## PF require root access on most systems. + ## Setting 'use_sudo' to true will make use of sudo to run pfctl. + ## Users must configure sudo to allow telegraf user to run pfctl with no password. + ## pfctl can be restricted to only list command "pfctl -s info". use_sudo = false ``` @@ -54,7 +59,7 @@ telegraf ALL=(root) NOPASSWD: /sbin/pfctl -s info Status: Enabled for 0 days 00:26:05 Debug: Urgent State Table Total Rate - current entries 2 + current entries 2 searches 11325 7.2/s inserts 5 0.0/s removals 3 0.0/s diff --git a/plugins/inputs/pf/pf.go b/plugins/inputs/pf/pf.go index 429169d543ab5..40a8efb4ba523 100644 --- a/plugins/inputs/pf/pf.go +++ b/plugins/inputs/pf/pf.go @@ -23,20 +23,6 @@ type PF struct { infoFunc func() (string, error) } -func (pf *PF) Description() string { - return "Gather counters from PF" -} - -func (pf *PF) SampleConfig() string { - return ` - ## PF require root access on most systems. - ## Setting 'use_sudo' to true will make use of sudo to run pfctl. - ## Users must configure sudo to allow telegraf user to run pfctl with no password. - ## pfctl can be restricted to only list command "pfctl -s info". - use_sudo = false -` -} - // Gather is the entrypoint for the plugin. func (pf *PF) Gather(acc telegraf.Accumulator) error { if pf.PfctlCommand == "" { diff --git a/plugins/inputs/pf/pf_sample_config.go b/plugins/inputs/pf/pf_sample_config.go new file mode 100644 index 0000000000000..ab7663d765b79 --- /dev/null +++ b/plugins/inputs/pf/pf_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package pf + +func (pf *PF) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/pgbouncer/README.md b/plugins/inputs/pgbouncer/README.md index abb7fcd35fde2..4539651cc76c9 100644 --- a/plugins/inputs/pgbouncer/README.md +++ b/plugins/inputs/pgbouncer/README.md @@ -7,9 +7,10 @@ More information about the meaning of these metrics can be found in the - PgBouncer minimum tested version: 1.5 -## Configuration example +## Configuration ```toml +# Read metrics from one or many pgbouncer servers [[inputs.pgbouncer]] ## specify address via a url matching: ## postgres://[pqgotest[:password]]@host:port[/dbname]\ diff --git a/plugins/inputs/pgbouncer/pgbouncer.go b/plugins/inputs/pgbouncer/pgbouncer.go index fead359d2271f..a3d5e10828f4c 100644 --- a/plugins/inputs/pgbouncer/pgbouncer.go +++ b/plugins/inputs/pgbouncer/pgbouncer.go @@ -19,26 +19,6 @@ var ignoredColumns = map[string]bool{"user": true, "database": true, "pool_mode" "avg_req": true, "avg_recv": true, "avg_sent": true, "avg_query": true, } -var sampleConfig = ` - ## specify address via a url matching: - ## postgres://[pqgotest[:password]]@localhost[/dbname]\ - ## ?sslmode=[disable|verify-ca|verify-full] - ## or a simple string: - ## host=localhost user=pqgotest password=... sslmode=... dbname=app_production - ## - ## All connection parameters are optional. - ## - address = "host=localhost user=pgbouncer sslmode=disable" -` - -func (p *PgBouncer) SampleConfig() string { - return sampleConfig -} - -func (p *PgBouncer) Description() string { - return "Read metrics from one or many pgbouncer servers" -} - func (p *PgBouncer) Gather(acc telegraf.Accumulator) error { var ( err error diff --git a/plugins/inputs/pgbouncer/pgbouncer_sample_config.go b/plugins/inputs/pgbouncer/pgbouncer_sample_config.go new file mode 100644 index 0000000000000..6150e515e0114 --- /dev/null +++ b/plugins/inputs/pgbouncer/pgbouncer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package pgbouncer + +func (p *PgBouncer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/phpfpm/phpfpm.go b/plugins/inputs/phpfpm/phpfpm.go index 532567a2486fa..09ebde883dfb4 100644 --- a/plugins/inputs/phpfpm/phpfpm.go +++ b/plugins/inputs/phpfpm/phpfpm.go @@ -46,47 +46,6 @@ type phpfpm struct { client *http.Client } -var sampleConfig = ` - ## An array of addresses to gather stats about. Specify an ip or hostname - ## with optional port and path - ## - ## Plugin can be configured in three modes (either can be used): - ## - http: the URL must start with http:// or https://, ie: - ## "http://localhost/status" - ## "http://192.168.130.1/status?full" - ## - ## - unixsocket: path to fpm socket, ie: - ## "/var/run/php5-fpm.sock" - ## or using a custom fpm status path: - ## "/var/run/php5-fpm.sock:fpm-custom-status-path" - ## - ## - fcgi: the URL must start with fcgi:// or cgi://, and port must be present, ie: - ## "fcgi://10.0.0.12:9000/status" - ## "cgi://10.0.10.12:9001/status" - ## - ## Example of multiple gathering from local socket and remote host - ## urls = ["http://192.168.1.20/status", "/tmp/fpm.sock"] - urls = ["http://localhost/status"] - - ## Duration allowed to complete HTTP requests. - # timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (p *phpfpm) SampleConfig() string { - return sampleConfig -} - -func (p *phpfpm) Description() string { - return "Read metrics of phpfpm, via HTTP status page or socket" -} - func (p *phpfpm) Init() error { tlsCfg, err := p.ClientConfig.TLSConfig() if err != nil { diff --git a/plugins/inputs/phpfpm/phpfpm_sample_config.go b/plugins/inputs/phpfpm/phpfpm_sample_config.go new file mode 100644 index 0000000000000..82460af25b05d --- /dev/null +++ b/plugins/inputs/phpfpm/phpfpm_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package phpfpm + +func (p *phpfpm) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ping/README.md b/plugins/inputs/ping/README.md index 03ab366933678..2d56ae1f69874 100644 --- a/plugins/inputs/ping/README.md +++ b/plugins/inputs/ping/README.md @@ -25,6 +25,7 @@ native Go by the Telegraf process, eliminating the need to execute the system ## Configuration ```toml +# Ping given url(s) and return statistics [[inputs.ping]] ## Hosts to send ping packets to. urls = ["example.org"] diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index 60f3aaf414b74..d2e07df83bbf2 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -97,66 +97,6 @@ type stats struct { roundTripTimeStats } -func (*Ping) Description() string { - return "Ping given url(s) and return statistics" -} - -const sampleConfig = ` - ## Hosts to send ping packets to. - urls = ["example.org"] - - ## Method used for sending pings, can be either "exec" or "native". When set - ## to "exec" the systems ping command will be executed. When set to "native" - ## the plugin will send pings directly. - ## - ## While the default is "exec" for backwards compatibility, new deployments - ## are encouraged to use the "native" method for improved compatibility and - ## performance. - # method = "exec" - - ## Number of ping packets to send per interval. Corresponds to the "-c" - ## option of the ping command. - # count = 1 - - ## Time to wait between sending ping packets in seconds. Operates like the - ## "-i" option of the ping command. - # ping_interval = 1.0 - - ## If set, the time to wait for a ping response in seconds. Operates like - ## the "-W" option of the ping command. - # timeout = 1.0 - - ## If set, the total ping deadline, in seconds. Operates like the -w option - ## of the ping command. - # deadline = 10 - - ## Interface or source address to send ping from. Operates like the -I or -S - ## option of the ping command. - # interface = "" - - ## Percentiles to calculate. This only works with the native method. - # percentiles = [50, 95, 99] - - ## Specify the ping executable binary. - # binary = "ping" - - ## Arguments for ping command. When arguments is not empty, the command from - ## the binary option will be used and other options (ping_interval, timeout, - ## etc) will be ignored. - # arguments = ["-c", "3"] - - ## Use only IPv6 addresses when resolving a hostname. - # ipv6 = false - - ## Number of data bytes to be sent. Corresponds to the "-s" - ## option of the ping command. This only works with the native method. - # size = 56 -` - -func (*Ping) SampleConfig() string { - return sampleConfig -} - func (p *Ping) Gather(acc telegraf.Accumulator) error { for _, host := range p.Urls { p.wg.Add(1) diff --git a/plugins/inputs/ping/ping_sample_config.go b/plugins/inputs/ping/ping_sample_config.go new file mode 100644 index 0000000000000..7fb1867b88954 --- /dev/null +++ b/plugins/inputs/ping/ping_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ping + +func (*Ping) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/postfix/README.md b/plugins/inputs/postfix/README.md index 5d42c881db487..9388a92259d82 100644 --- a/plugins/inputs/postfix/README.md +++ b/plugins/inputs/postfix/README.md @@ -10,6 +10,7 @@ item in seconds). ## Configuration ```toml +# Measure postfix queue statistics [[inputs.postfix]] ## Postfix queue directory. If not provided, telegraf will try to use ## 'postconf -h queue_directory' to determine it. diff --git a/plugins/inputs/postfix/postfix.go b/plugins/inputs/postfix/postfix.go index 444313b7d6885..f4faeff8490a9 100644 --- a/plugins/inputs/postfix/postfix.go +++ b/plugins/inputs/postfix/postfix.go @@ -17,14 +17,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## Postfix queue directory. If not provided, telegraf will try to use - ## 'postconf -h queue_directory' to determine it. - # queue_directory = "/var/spool/postfix" -` - -const description = "Measure postfix queue statistics" - func getQueueDirectory() (string, error) { qd, err := exec.Command("postconf", "-h", "queue_directory").Output() if err != nil { @@ -105,14 +97,6 @@ func (p *Postfix) Gather(acc telegraf.Accumulator) error { return nil } -func (p *Postfix) SampleConfig() string { - return sampleConfig -} - -func (p *Postfix) Description() string { - return description -} - func init() { inputs.Add("postfix", func() telegraf.Input { return &Postfix{ diff --git a/plugins/inputs/postfix/postfix_sample_config.go b/plugins/inputs/postfix/postfix_sample_config.go new file mode 100644 index 0000000000000..8ec9ad99dc4c3 --- /dev/null +++ b/plugins/inputs/postfix/postfix_sample_config.go @@ -0,0 +1,11 @@ +//go:build !windows +// +build !windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package postfix + +func (p *Postfix) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/postgresql/README.md b/plugins/inputs/postgresql/README.md index 6ab44e2b52755..c45b28ba3ea56 100644 --- a/plugins/inputs/postgresql/README.md +++ b/plugins/inputs/postgresql/README.md @@ -32,34 +32,6 @@ More information about the meaning of these metrics can be found in the [Postgre ## Configuration -Specify address via a postgresql connection string: - - `host=localhost port=5432 user=telegraf database=telegraf` - -Or via an url matching: - - `postgres://[pqgotest[:password]]@host:port[/dbname]?sslmode=[disable|verify-ca|verify-full]` - -All connection parameters are optional. Without the dbname parameter, the driver will default to a database with the same name as the user. This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for. - -A list of databases to explicitly ignore. If not specified, metrics for all databases are gathered. Do NOT use with the 'databases' option. - - `ignored_databases = ["postgres", "template0", "template1"]` - -A list of databases to pull metrics about. If not specified, metrics for all databases are gathered. Do NOT use with the 'ignored_databases' option. - - `databases = ["app_production", "testing"]` - -### TLS Configuration - -Add the `sslkey`, `sslcert` and `sslrootcert` options to your DSN: - -```shell -host=localhost user=pgotest dbname=app_production sslmode=require sslkey=/etc/telegraf/key.pem sslcert=/etc/telegraf/cert.pem sslrootcert=/etc/telegraf/ca.pem -``` - -### Configuration example - ```toml [[inputs.postgresql]] ## specify address via a url matching: @@ -98,3 +70,29 @@ host=localhost user=pgotest dbname=app_production sslmode=require sslkey=/etc/te ## with pool_mode set to transaction. prepared_statements = true ``` + +Specify address via a postgresql connection string: + + `host=localhost port=5432 user=telegraf database=telegraf` + +Or via an url matching: + + `postgres://[pqgotest[:password]]@host:port[/dbname]?sslmode=[disable|verify-ca|verify-full]` + +All connection parameters are optional. Without the dbname parameter, the driver will default to a database with the same name as the user. This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for. + +A list of databases to explicitly ignore. If not specified, metrics for all databases are gathered. Do NOT use with the 'databases' option. + + `ignored_databases = ["postgres", "template0", "template1"]` + +A list of databases to pull metrics about. If not specified, metrics for all databases are gathered. Do NOT use with the 'ignored_databases' option. + + `databases = ["app_production", "testing"]` + +### TLS Configuration + +Add the `sslkey`, `sslcert` and `sslrootcert` options to your DSN: + +```shell +host=localhost user=pgotest dbname=app_production sslmode=require sslkey=/etc/telegraf/key.pem sslcert=/etc/telegraf/cert.pem sslrootcert=/etc/telegraf/ca.pem +``` diff --git a/plugins/inputs/postgresql/postgresql.go b/plugins/inputs/postgresql/postgresql.go index b131642ca1176..d7769e7d3dd0d 100644 --- a/plugins/inputs/postgresql/postgresql.go +++ b/plugins/inputs/postgresql/postgresql.go @@ -22,53 +22,6 @@ type Postgresql struct { var ignoredColumns = map[string]bool{"stats_reset": true} -var sampleConfig = ` - ## specify address via a url matching: - ## postgres://[pqgotest[:password]]@localhost[/dbname]\ - ## ?sslmode=[disable|verify-ca|verify-full] - ## or a simple string: - ## host=localhost user=pqgotest password=... sslmode=... dbname=app_production - ## - ## All connection parameters are optional. - ## - ## Without the dbname parameter, the driver will default to a database - ## with the same name as the user. This dbname is just for instantiating a - ## connection with the server and doesn't restrict the databases we are trying - ## to grab metrics for. - ## - address = "host=localhost user=postgres sslmode=disable" - ## A custom name for the database that will be used as the "server" tag in the - ## measurement output. If not specified, a default one generated from - ## the connection address is used. - # outputaddress = "db01" - - ## connection configuration. - ## maxlifetime - specify the maximum lifetime of a connection. - ## default is forever (0s) - max_lifetime = "0s" - - ## A list of databases to explicitly ignore. If not specified, metrics for all - ## databases are gathered. Do NOT use with the 'databases' option. - # ignored_databases = ["postgres", "template0", "template1"] - - ## A list of databases to pull metrics about. If not specified, metrics for all - ## databases are gathered. Do NOT use with the 'ignored_databases' option. - # databases = ["app_production", "testing"] - - ## Whether to use prepared statements when connecting to the database. - ## This should be set to false when connecting through a PgBouncer instance - ## with pool_mode set to transaction. - # prepared_statements = true -` - -func (p *Postgresql) SampleConfig() string { - return sampleConfig -} - -func (p *Postgresql) Description() string { - return "Read metrics from one or many postgresql servers" -} - func (p *Postgresql) IgnoredColumns() map[string]bool { return ignoredColumns } diff --git a/plugins/inputs/postgresql/postgresql_sample_config.go b/plugins/inputs/postgresql/postgresql_sample_config.go new file mode 100644 index 0000000000000..f574107d4b527 --- /dev/null +++ b/plugins/inputs/postgresql/postgresql_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package postgresql + +func (p *Postgresql) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/postgresql_extensible/README.md b/plugins/inputs/postgresql_extensible/README.md index bfba3e5c8eb79..af4813325f73a 100644 --- a/plugins/inputs/postgresql_extensible/README.md +++ b/plugins/inputs/postgresql_extensible/README.md @@ -11,7 +11,10 @@ The example below has two queries are specified, with the following parameters: * The name of the measurement * A list of the columns to be defined as tags +## Configuration + ```toml +# Read metrics from one or many postgresql servers [[inputs.postgresql_extensible]] # specify address via a url matching: # postgres://[pqgotest[:password]]@host:port[/dbname]?sslmode=... @@ -59,7 +62,7 @@ The example below has two queries are specified, with the following parameters: # # The timestamp field is used to override the data points timestamp value. By # default, all rows inserted with current time. By setting a timestamp column, - # the row will be inserted with that column's value. + # the row will be inserted with that column's value. # # Structure : # [[inputs.postgresql_extensible.query]] diff --git a/plugins/inputs/postgresql_extensible/postgresql_extensible.go b/plugins/inputs/postgresql_extensible/postgresql_extensible.go index 61af57e665cd0..7ee05b1045149 100644 --- a/plugins/inputs/postgresql_extensible/postgresql_extensible.go +++ b/plugins/inputs/postgresql_extensible/postgresql_extensible.go @@ -40,87 +40,6 @@ type query []struct { var ignoredColumns = map[string]bool{"stats_reset": true} -var sampleConfig = ` - ## specify address via a url matching: - ## postgres://[pqgotest[:password]]@localhost[/dbname]\ - ## ?sslmode=[disable|verify-ca|verify-full] - ## or a simple string: - ## host=localhost user=pqgotest password=... sslmode=... dbname=app_production - # - ## All connection parameters are optional. # - ## Without the dbname parameter, the driver will default to a database - ## with the same name as the user. This dbname is just for instantiating a - ## connection with the server and doesn't restrict the databases we are trying - ## to grab metrics for. - # - address = "host=localhost user=postgres sslmode=disable" - - ## connection configuration. - ## maxlifetime - specify the maximum lifetime of a connection. - ## default is forever (0s) - max_lifetime = "0s" - - ## Whether to use prepared statements when connecting to the database. - ## This should be set to false when connecting through a PgBouncer instance - ## with pool_mode set to transaction. - # prepared_statements = true - - ## A list of databases to pull metrics about. If not specified, metrics for all - ## databases are gathered. - ## databases = ["app_production", "testing"] - # - ## A custom name for the database that will be used as the "server" tag in the - ## measurement output. If not specified, a default one generated from - ## the connection address is used. - # outputaddress = "db01" - # - ## Define the toml config where the sql queries are stored - ## New queries can be added, if the withdbname is set to true and there is no - ## databases defined in the 'databases field', the sql query is ended by a - ## 'is not null' in order to make the query succeed. - ## Example : - ## The sqlquery : "SELECT * FROM pg_stat_database where datname" become - ## "SELECT * FROM pg_stat_database where datname IN ('postgres', 'pgbench')" - ## because the databases variable was set to ['postgres', 'pgbench' ] and the - ## withdbname was true. Be careful that if the withdbname is set to false you - ## don't have to define the where clause (aka with the dbname) the tagvalue - ## field is used to define custom tags (separated by commas) - ## The optional "measurement" value can be used to override the default - ## output measurement name ("postgresql"). - ## - ## The script option can be used to specify the .sql file path. - ## If script and sqlquery options specified at same time, sqlquery will be used - ## - ## the tagvalue field is used to define custom tags (separated by comas). - ## the query is expected to return columns which match the names of the - ## defined tags. The values in these columns must be of a string-type, - ## a number-type or a blob-type. - ## - ## The timestamp field is used to override the data points timestamp value. By - ## default, all rows inserted with current time. By setting a timestamp column, - ## the row will be inserted with that column's value. - ## - ## Structure : - ## [[inputs.postgresql_extensible.query]] - ## sqlquery string - ## version string - ## withdbname boolean - ## tagvalue string (comma separated) - ## measurement string - ## timestamp string - [[inputs.postgresql_extensible.query]] - sqlquery="SELECT * FROM pg_stat_database" - version=901 - withdbname=false - tagvalue="" - measurement="" - [[inputs.postgresql_extensible.query]] - sqlquery="SELECT * FROM pg_stat_bgwriter" - version=901 - withdbname=false - tagvalue="postgresql.stats" -` - func (p *Postgresql) Init() error { var err error for i := range p.Query { @@ -135,14 +54,6 @@ func (p *Postgresql) Init() error { return nil } -func (p *Postgresql) SampleConfig() string { - return sampleConfig -} - -func (p *Postgresql) Description() string { - return "Read metrics from one or many postgresql servers" -} - func (p *Postgresql) IgnoredColumns() map[string]bool { return ignoredColumns } diff --git a/plugins/inputs/postgresql_extensible/postgresql_extensible_sample_config.go b/plugins/inputs/postgresql_extensible/postgresql_extensible_sample_config.go new file mode 100644 index 0000000000000..34efab6ca43e5 --- /dev/null +++ b/plugins/inputs/postgresql_extensible/postgresql_extensible_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package postgresql_extensible + +func (p *Postgresql) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/powerdns/README.md b/plugins/inputs/powerdns/README.md index 160c3d6d26849..6222bf6cadcb6 100644 --- a/plugins/inputs/powerdns/README.md +++ b/plugins/inputs/powerdns/README.md @@ -5,7 +5,7 @@ The powerdns plugin gathers metrics about PowerDNS using unix socket. ## Configuration ```toml -# Description +# Read metrics from one or many PowerDNS servers [[inputs.powerdns]] # An array of sockets to gather stats about. # Specify a path to unix socket. diff --git a/plugins/inputs/powerdns/powerdns.go b/plugins/inputs/powerdns/powerdns.go index 196b0c12dd49f..04aaca5272fbc 100644 --- a/plugins/inputs/powerdns/powerdns.go +++ b/plugins/inputs/powerdns/powerdns.go @@ -19,22 +19,8 @@ type Powerdns struct { Log telegraf.Logger `toml:"-"` } -var sampleConfig = ` - ## An array of sockets to gather stats about. - ## Specify a path to unix socket. - unix_sockets = ["/var/run/pdns.controlsocket"] -` - var defaultTimeout = 5 * time.Second -func (p *Powerdns) SampleConfig() string { - return sampleConfig -} - -func (p *Powerdns) Description() string { - return "Read metrics from one or many PowerDNS servers" -} - func (p *Powerdns) Gather(acc telegraf.Accumulator) error { if len(p.UnixSockets) == 0 { return p.gatherServer("/var/run/pdns.controlsocket", acc) diff --git a/plugins/inputs/powerdns/powerdns_sample_config.go b/plugins/inputs/powerdns/powerdns_sample_config.go new file mode 100644 index 0000000000000..71409d7acbce9 --- /dev/null +++ b/plugins/inputs/powerdns/powerdns_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package powerdns + +func (p *Powerdns) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/powerdns_recursor/README.md b/plugins/inputs/powerdns_recursor/README.md index 5cb8347f87571..0b713859f6cc9 100644 --- a/plugins/inputs/powerdns_recursor/README.md +++ b/plugins/inputs/powerdns_recursor/README.md @@ -6,6 +6,7 @@ the unix controlsocket. ## Configuration ```toml +# Read metrics from one or many PowerDNS Recursor servers [[inputs.powerdns_recursor]] ## Path to the Recursor control socket. unix_sockets = ["/var/run/pdns_recursor.controlsocket"] diff --git a/plugins/inputs/powerdns_recursor/powerdns_recursor.go b/plugins/inputs/powerdns_recursor/powerdns_recursor.go index bc7ebc5b777f1..ad7cea4ac44a9 100644 --- a/plugins/inputs/powerdns_recursor/powerdns_recursor.go +++ b/plugins/inputs/powerdns_recursor/powerdns_recursor.go @@ -28,25 +28,6 @@ type PowerdnsRecursor struct { var defaultTimeout = 5 * time.Second -var sampleConfig = ` - ## Path to the Recursor control socket. - unix_sockets = ["/var/run/pdns_recursor.controlsocket"] - - ## Directory to create receive socket. This default is likely not writable, - ## please reference the full plugin documentation for a recommended setup. - # socket_dir = "/var/run/" - ## Socket permissions for the receive socket. - # socket_mode = "0666" -` - -func (p *PowerdnsRecursor) SampleConfig() string { - return sampleConfig -} - -func (p *PowerdnsRecursor) Description() string { - return "Read metrics from one or many PowerDNS Recursor servers" -} - func (p *PowerdnsRecursor) Init() error { if p.SocketMode != "" { mode, err := strconv.ParseUint(p.SocketMode, 8, 32) diff --git a/plugins/inputs/powerdns_recursor/powerdns_recursor_sample_config.go b/plugins/inputs/powerdns_recursor/powerdns_recursor_sample_config.go new file mode 100644 index 0000000000000..7f3e28320f334 --- /dev/null +++ b/plugins/inputs/powerdns_recursor/powerdns_recursor_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package powerdns_recursor + +func (p *PowerdnsRecursor) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/processes/processes.go b/plugins/inputs/processes/processes.go index 9ee583dbacecf..5f0a008e08acd 100644 --- a/plugins/inputs/processes/processes.go +++ b/plugins/inputs/processes/processes.go @@ -1,7 +1 @@ package processes - -func (p *Processes) Description() string { - return "Get the number of processes and group them by status" -} - -func (p *Processes) SampleConfig() string { return "" } diff --git a/plugins/inputs/processes/processes_sample_config.go b/plugins/inputs/processes/processes_sample_config.go new file mode 100644 index 0000000000000..2ee5d74062a48 --- /dev/null +++ b/plugins/inputs/processes/processes_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package processes + +func (p *Processes) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/procstat/README.md b/plugins/inputs/procstat/README.md index 60d213cd0c50d..5dd673cfd8564 100644 --- a/plugins/inputs/procstat/README.md +++ b/plugins/inputs/procstat/README.md @@ -30,7 +30,7 @@ Processes can be selected for monitoring using one of several methods: ## Systemd unit name, supports globs when include_systemd_children is set to true # systemd_unit = "nginx.service" # include_systemd_children = false - ## CGroup name or path + ## CGroup name or path, supports globs # cgroup = "systemd/system.slice/nginx.service" ## Windows service name diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index 915a1b13f44b4..e2027053475ed 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -48,60 +48,6 @@ type Procstat struct { createProcess func(PID) (Process, error) } -var sampleConfig = ` - ## PID file to monitor process - pid_file = "/var/run/nginx.pid" - ## executable name (ie, pgrep ) - # exe = "nginx" - ## pattern as argument for pgrep (ie, pgrep -f ) - # pattern = "nginx" - ## user as argument for pgrep (ie, pgrep -u ) - # user = "nginx" - ## Systemd unit name, supports globs when include_systemd_children is set to true - # systemd_unit = "nginx.service" - # include_systemd_children = false - ## CGroup name or path, supports globs - # cgroup = "systemd/system.slice/nginx.service" - - ## Windows service name - # win_service = "" - - ## override for process_name - ## This is optional; default is sourced from /proc//status - # process_name = "bar" - - ## Field name prefix - # prefix = "" - - ## When true add the full cmdline as a tag. - # cmdline_tag = false - - ## Mode to use when calculating CPU usage. Can be one of 'solaris' or 'irix'. - # mode = "irix" - - ## Add the PID as a tag instead of as a field. When collecting multiple - ## processes with otherwise matching tags this setting should be enabled to - ## ensure each process has a unique identity. - ## - ## Enabling this option may result in a large number of series, especially - ## when processes have a short lifetime. - # pid_tag = false - - ## Method to use when finding process IDs. Can be one of 'pgrep', or - ## 'native'. The pgrep finder calls the pgrep executable in the PATH while - ## the native finder performs the search directly in a manor dependent on the - ## platform. Default is 'pgrep' - # pid_finder = "pgrep" -` - -func (p *Procstat) SampleConfig() string { - return sampleConfig -} - -func (p *Procstat) Description() string { - return "Monitor process cpu and memory usage" -} - type PidsTags struct { PIDS []PID Tags map[string]string diff --git a/plugins/inputs/procstat/procstat_sample_config.go b/plugins/inputs/procstat/procstat_sample_config.go new file mode 100644 index 0000000000000..ae39ee2ba97f9 --- /dev/null +++ b/plugins/inputs/procstat/procstat_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package procstat + +func (p *Procstat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go index de14449ab4462..93d56e7e41c9a 100644 --- a/plugins/inputs/prometheus/prometheus.go +++ b/plugins/inputs/prometheus/prometheus.go @@ -91,104 +91,6 @@ type Prometheus struct { consulServices map[string]URLAndAddress } -var sampleConfig = ` - ## An array of urls to scrape metrics from. - urls = ["http://localhost:9100/metrics"] - - ## Metric version controls the mapping from Prometheus metrics into - ## Telegraf metrics. When using the prometheus_client output, use the same - ## value in both plugins to ensure metrics are round-tripped without - ## modification. - ## - ## example: metric_version = 1; - ## metric_version = 2; recommended version - # metric_version = 1 - - ## Url tag name (tag containing scrapped url. optional, default is "url") - # url_tag = "url" - - ## Whether the timestamp of the scraped metrics will be ignored. - ## If set to true, the gather time will be used. - # ignore_timestamp = false - - ## An array of Kubernetes services to scrape metrics from. - # kubernetes_services = ["http://my-service-dns.my-namespace:9100/metrics"] - - ## Kubernetes config file to create client from. - # kube_config = "/path/to/kubernetes.config" - - ## Scrape Kubernetes pods for the following prometheus annotations: - ## - prometheus.io/scrape: Enable scraping for this pod - ## - prometheus.io/scheme: If the metrics endpoint is secured then you will need to - ## set this to 'https' & most likely set the tls config. - ## - prometheus.io/path: If the metrics path is not /metrics, define it with this annotation. - ## - prometheus.io/port: If port is not 9102 use this annotation - # monitor_kubernetes_pods = true - ## Get the list of pods to scrape with either the scope of - ## - cluster: the kubernetes watch api (default, no need to specify) - ## - node: the local cadvisor api; for scalability. Note that the config node_ip or the environment variable NODE_IP must be set to the host IP. - # pod_scrape_scope = "cluster" - ## Only for node scrape scope: node IP of the node that telegraf is running on. - ## Either this config or the environment variable NODE_IP must be set. - # node_ip = "10.180.1.1" - ## Only for node scrape scope: interval in seconds for how often to get updated pod list for scraping. - ## Default is 60 seconds. - # pod_scrape_interval = 60 - ## Restricts Kubernetes monitoring to a single namespace - ## ex: monitor_kubernetes_pods_namespace = "default" - # monitor_kubernetes_pods_namespace = "" - # label selector to target pods which have the label - # kubernetes_label_selector = "env=dev,app=nginx" - # field selector to target pods - # eg. To scrape pods on a specific node - # kubernetes_field_selector = "spec.nodeName=$HOSTNAME" - - # cache refresh interval to set the interval for re-sync of pods list. - # Default is 60 minutes. - # cache_refresh_interval = 60 - - ## Scrape Services available in Consul Catalog - # [inputs.prometheus.consul] - # enabled = true - # agent = "http://localhost:8500" - # query_interval = "5m" - - # [[inputs.prometheus.consul.query]] - # name = "a service name" - # tag = "a service tag" - # url = 'http://{{if ne .ServiceAddress ""}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}' - # [inputs.prometheus.consul.query.tags] - # host = "{{.Node}}" - - ## Use bearer token for authorization. ('bearer_token' takes priority) - # bearer_token = "/path/to/bearer/token" - ## OR - # bearer_token_string = "abc_123" - - ## HTTP Basic Authentication username and password. ('bearer_token' and - ## 'bearer_token_string' take priority) - # username = "" - # password = "" - - ## Specify timeout duration for slower prometheus clients (default is 3s) - # response_timeout = "3s" - - ## Optional TLS Config - # tls_ca = /path/to/cafile - # tls_cert = /path/to/certfile - # tls_key = /path/to/keyfile - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (p *Prometheus) SampleConfig() string { - return sampleConfig -} - -func (p *Prometheus) Description() string { - return "Read metrics from one or many prometheus clients" -} - func (p *Prometheus) Init() error { // Config processing for node scrape scope for monitor_kubernetes_pods p.isNodeScrapeScope = strings.EqualFold(p.PodScrapeScope, "node") diff --git a/plugins/inputs/prometheus/prometheus_sample_config.go b/plugins/inputs/prometheus/prometheus_sample_config.go new file mode 100644 index 0000000000000..b5811d89583ac --- /dev/null +++ b/plugins/inputs/prometheus/prometheus_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package prometheus + +func (p *Prometheus) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/proxmox/README.md b/plugins/inputs/proxmox/README.md index 4b76ce5c326a3..9387474507a30 100644 --- a/plugins/inputs/proxmox/README.md +++ b/plugins/inputs/proxmox/README.md @@ -7,6 +7,7 @@ Telegraf minimum version: Telegraf 1.16.0 ## Configuration ```toml +# Provides metrics from Proxmox nodes (Proxmox Virtual Environment > 6.2). [[inputs.proxmox]] ## API connection configuration. The API token was introduced in Proxmox v6.2. Required permissions for user and token: PVEAuditor role on /. base_url = "https://localhost:8006/api2/json" diff --git a/plugins/inputs/proxmox/proxmox.go b/plugins/inputs/proxmox/proxmox.go index c8234a6d8e75c..f4d9d2be9ad0f 100644 --- a/plugins/inputs/proxmox/proxmox.go +++ b/plugins/inputs/proxmox/proxmox.go @@ -14,32 +14,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -var sampleConfig = ` - ## API connection configuration. The API token was introduced in Proxmox v6.2. Required permissions for user and token: PVEAuditor role on /. - base_url = "https://localhost:8006/api2/json" - api_token = "USER@REALM!TOKENID=UUID" - ## Node name, defaults to OS hostname - # node_name = "" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - insecure_skip_verify = false - - # HTTP response timeout (default: 5s) - response_timeout = "5s" -` - -func (px *Proxmox) SampleConfig() string { - return sampleConfig -} - -func (px *Proxmox) Description() string { - return "Provides metrics from Proxmox nodes (Proxmox Virtual Environment > 6.2)." -} - func (px *Proxmox) Gather(acc telegraf.Accumulator) error { err := getNodeSearchDomain(px) if err != nil { diff --git a/plugins/inputs/proxmox/proxmox_sample_config.go b/plugins/inputs/proxmox/proxmox_sample_config.go new file mode 100644 index 0000000000000..9b832a557536b --- /dev/null +++ b/plugins/inputs/proxmox/proxmox_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package proxmox + +func (px *Proxmox) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/puppetagent/README.md b/plugins/inputs/puppetagent/README.md index db85dfe94a589..153dfc9efcede 100644 --- a/plugins/inputs/puppetagent/README.md +++ b/plugins/inputs/puppetagent/README.md @@ -77,6 +77,15 @@ jcross@pit-devops-02 ~ >sudo ./telegraf_linux_amd64 --input-filter puppetagent - > [] puppetagent_version_puppet value=3.7.5 ``` +## Configuration + +```toml +# Reads last_run_summary.yaml file and converts to measurements +[[inputs.puppetagent]] + ## Location of puppet last run summary file + location = "/var/lib/puppet/state/last_run_summary.yaml" +``` + ## Measurements ### PuppetAgent int64 measurements diff --git a/plugins/inputs/puppetagent/puppetagent.go b/plugins/inputs/puppetagent/puppetagent.go index f31e03d327817..712498e91d786 100644 --- a/plugins/inputs/puppetagent/puppetagent.go +++ b/plugins/inputs/puppetagent/puppetagent.go @@ -17,11 +17,6 @@ type PuppetAgent struct { Location string } -var sampleConfig = ` - ## Location of puppet last run summary file - location = "/var/lib/puppet/state/last_run_summary.yaml" -` - type State struct { Events event Resources resource @@ -82,16 +77,6 @@ type version struct { Puppet string `yaml:"puppet"` } -// SampleConfig returns sample configuration message -func (pa *PuppetAgent) SampleConfig() string { - return sampleConfig -} - -// Description returns description of PuppetAgent plugin -func (pa *PuppetAgent) Description() string { - return `Reads last_run_summary.yaml file and converts to measurements` -} - // Gather reads stats from all configured servers accumulates stats func (pa *PuppetAgent) Gather(acc telegraf.Accumulator) error { if len(pa.Location) == 0 { diff --git a/plugins/inputs/puppetagent/puppetagent_sample_config.go b/plugins/inputs/puppetagent/puppetagent_sample_config.go new file mode 100644 index 0000000000000..0de8ef4fe2fb1 --- /dev/null +++ b/plugins/inputs/puppetagent/puppetagent_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package puppetagent + +func (pa *PuppetAgent) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/rabbitmq/README.md b/plugins/inputs/rabbitmq/README.md index 8e2bcd16ab494..2205a1e5728b0 100644 --- a/plugins/inputs/rabbitmq/README.md +++ b/plugins/inputs/rabbitmq/README.md @@ -10,6 +10,7 @@ For additional details reference the [RabbitMQ Management HTTP Stats][management ## Configuration ```toml +# Reads metrics from RabbitMQ servers via the Management Plugin [[inputs.rabbitmq]] ## Management Plugin url. (default: http://localhost:15672) # url = "http://localhost:15672" diff --git a/plugins/inputs/rabbitmq/rabbitmq.go b/plugins/inputs/rabbitmq/rabbitmq.go index 9516f9b2eb017..c7fe985664db4 100644 --- a/plugins/inputs/rabbitmq/rabbitmq.go +++ b/plugins/inputs/rabbitmq/rabbitmq.go @@ -269,59 +269,6 @@ var gatherFunctions = map[string]gatherFunc{ "queue": gatherQueues, } -var sampleConfig = ` - ## Management Plugin url. (default: http://localhost:15672) - # url = "http://localhost:15672" - ## Credentials - # username = "guest" - # password = "guest" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Optional request timeouts - ## - ## ResponseHeaderTimeout, if non-zero, specifies the amount of time to wait - ## for a server's response headers after fully writing the request. - # header_timeout = "3s" - ## - ## client_timeout specifies a time limit for requests made by this client. - ## Includes connection time, any redirects, and reading the response body. - # client_timeout = "4s" - - ## A list of nodes to gather as the rabbitmq_node measurement. If not - ## specified, metrics for all nodes are gathered. - # nodes = ["rabbit@node1", "rabbit@node2"] - - ## A list of exchanges to gather as the rabbitmq_exchange measurement. If not - ## specified, metrics for all exchanges are gathered. - # exchanges = ["telegraf"] - - ## Metrics to include and exclude. Globs accepted. - ## Note that an empty array for both will include all metrics - ## Currently the following metrics are supported: "exchange", "federation", "node", "overview", "queue" - # metric_include = [] - # metric_exclude = [] - - ## Queues to include and exclude. Globs accepted. - ## Note that an empty array for both will include all queues - queue_name_include = [] - queue_name_exclude = [] - - ## Federation upstreams include and exclude when gathering the rabbitmq_federation measurement. - ## If neither are specified, metrics for all federation upstreams are gathered. - ## Federation link metrics will only be gathered for queues and exchanges - ## whose non-federation metrics will be collected (e.g a queue excluded - ## by the 'queue_name_exclude' option will also be excluded from federation). - ## Globs accepted. - # federation_upstream_include = ["dataCentre-*"] - # federation_upstream_exclude = [] -` - func boolToInt(b bool) int64 { if b { return 1 @@ -329,16 +276,6 @@ func boolToInt(b bool) int64 { return 0 } -// SampleConfig ... -func (r *RabbitMQ) SampleConfig() string { - return sampleConfig -} - -// Description ... -func (r *RabbitMQ) Description() string { - return "Reads metrics from RabbitMQ servers via the Management Plugin" -} - func (r *RabbitMQ) Init() error { var err error diff --git a/plugins/inputs/rabbitmq/rabbitmq_sample_config.go b/plugins/inputs/rabbitmq/rabbitmq_sample_config.go new file mode 100644 index 0000000000000..0a147aaaa26a1 --- /dev/null +++ b/plugins/inputs/rabbitmq/rabbitmq_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package rabbitmq + +func (r *RabbitMQ) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/raindrops/README.md b/plugins/inputs/raindrops/README.md index c380310513e0f..0e06fa1eefaa6 100644 --- a/plugins/inputs/raindrops/README.md +++ b/plugins/inputs/raindrops/README.md @@ -6,8 +6,9 @@ specified raindops [middleware](http://raindrops.bogomips.org/Raindrops/Middlewa ## Configuration ```toml -# Read raindrops stats +# Read raindrops stats (raindrops - real-time stats for preforking Rack servers) [[inputs.raindrops]] + ## An array of raindrops middleware URI to gather stats. urls = ["http://localhost:8080/_raindrops"] ``` diff --git a/plugins/inputs/raindrops/raindrops.go b/plugins/inputs/raindrops/raindrops.go index cf1db2d1f6f98..4084602cec6f9 100644 --- a/plugins/inputs/raindrops/raindrops.go +++ b/plugins/inputs/raindrops/raindrops.go @@ -20,19 +20,6 @@ type Raindrops struct { httpClient *http.Client } -var sampleConfig = ` - ## An array of raindrops middleware URI to gather stats. - urls = ["http://localhost:8080/_raindrops"] -` - -func (r *Raindrops) SampleConfig() string { - return sampleConfig -} - -func (r *Raindrops) Description() string { - return "Read raindrops stats (raindrops - real-time stats for preforking Rack servers)" -} - func (r *Raindrops) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/raindrops/raindrops_sample_config.go b/plugins/inputs/raindrops/raindrops_sample_config.go new file mode 100644 index 0000000000000..e09b38f04a89c --- /dev/null +++ b/plugins/inputs/raindrops/raindrops_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package raindrops + +func (r *Raindrops) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ras/ras.go b/plugins/inputs/ras/ras.go index e3f35b06e0c8d..1f83c1aaa9312 100644 --- a/plugins/inputs/ras/ras.go +++ b/plugins/inputs/ras/ras.go @@ -42,7 +42,7 @@ type metricCounters map[string]int64 const ( mceQuery = ` - SELECT + SELECT id, timestamp, error_msg, mcistatus_msg, socketid FROM mce_record WHERE timestamp > ? @@ -68,20 +68,6 @@ const ( unclassifiedMCEBase = "unclassified_mce_errors" ) -// SampleConfig returns sample configuration for this plugin. -func (r *Ras) SampleConfig() string { - return ` - ## Optional path to RASDaemon sqlite3 database. - ## Default: /var/lib/rasdaemon/ras-mc_event.db - # db_path = "" -` -} - -// Description returns the plugin description. -func (r *Ras) Description() string { - return "RAS plugin exposes counter metrics for Machine Check Errors provided by RASDaemon (sqlite3 output is required)." -} - // Start initializes connection to DB, metrics are gathered in Gather func (r *Ras) Start(telegraf.Accumulator) error { err := validateDbPath(r.DBPath) diff --git a/plugins/inputs/ras/ras_sample_config.go b/plugins/inputs/ras/ras_sample_config.go new file mode 100644 index 0000000000000..de986d86b1bd7 --- /dev/null +++ b/plugins/inputs/ras/ras_sample_config.go @@ -0,0 +1,12 @@ +//go:build linux && (386 || amd64 || arm || arm64) +// +build linux +// +build 386 amd64 arm arm64 + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ras + +func (r *Ras) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ravendb/README.md b/plugins/inputs/ravendb/README.md index 82911eab1e8a2..978416162682b 100644 --- a/plugins/inputs/ravendb/README.md +++ b/plugins/inputs/ravendb/README.md @@ -9,6 +9,7 @@ Requires RavenDB Server 5.2+. The following is an example config for RavenDB. **Note:** The client certificate used should have `Operator` permissions on the cluster. ```toml +# Reads metrics from RavenDB servers via the Monitoring Endpoints [[inputs.ravendb]] ## Node URL and port that RavenDB is listening on. By default, ## attempts to connect securely over HTTPS, however, if the user @@ -17,20 +18,20 @@ The following is an example config for RavenDB. **Note:** The client certificate url = "https://localhost:4433" ## RavenDB X509 client certificate setup - tls_cert = "/etc/telegraf/raven.crt" - tls_key = "/etc/telegraf/raven.key" + # tls_cert = "/etc/telegraf/raven.crt" + # tls_key = "/etc/telegraf/raven.key" ## Optional request timeout ## ## Timeout, specifies the amount of time to wait - ## for a server's response headers after fully writing the request and + ## for a server's response headers after fully writing the request and ## time limit for requests made by this client # timeout = "5s" ## List of statistics which are collected # At least one is required # Allowed values: server, databases, indexes, collections - # + # # stats_include = ["server", "databases", "indexes", "collections"] ## List of db where database stats are collected @@ -40,7 +41,7 @@ The following is an example config for RavenDB. **Note:** The client certificate ## List of db where index status are collected ## If empty, all indexes from all db are concerned # index_stats_dbs = [] - + ## List of db where collection status are collected ## If empty, all collections from all db are concerned # collection_stats_dbs = [] @@ -53,7 +54,7 @@ The following is an example config for RavenDB. **Note:** The client certificate - url - node_tag - cluster_id - - public_server_url (optional) + - public_server_url (optional) - fields: - backup_current_number_of_running_backups - backup_max_number_of_concurrent_backups @@ -87,7 +88,7 @@ The following is an example config for RavenDB. **Note:** The client certificate - license_max_cores - license_type - license_utilized_cpu_cores - - memory_allocated_in_mb + - memory_allocated_in_mb - memory_installed_in_mb - memory_low_memory_severity - 0 -> None @@ -108,7 +109,7 @@ The following is an example config for RavenDB. **Note:** The client certificate - server_process_id - server_version - uptime_in_sec - + - ravendb_databases - tags: - url diff --git a/plugins/inputs/ravendb/ravendb.go b/plugins/inputs/ravendb/ravendb.go index 47f1e6f035ee9..594c453dcb288 100644 --- a/plugins/inputs/ravendb/ravendb.go +++ b/plugins/inputs/ravendb/ravendb.go @@ -46,51 +46,6 @@ type RavenDB struct { requestURLCollection string } -var sampleConfig = ` - ## Node URL and port that RavenDB is listening on. By default, - ## attempts to connect securely over HTTPS, however, if the user - ## is running a local unsecure development cluster users can use - ## HTTP via a URL like "http://localhost:8080" - url = "https://localhost:4433" - - ## RavenDB X509 client certificate setup - # tls_cert = "/etc/telegraf/raven.crt" - # tls_key = "/etc/telegraf/raven.key" - - ## Optional request timeout - ## - ## Timeout, specifies the amount of time to wait - ## for a server's response headers after fully writing the request and - ## time limit for requests made by this client - # timeout = "5s" - - ## List of statistics which are collected - # At least one is required - # Allowed values: server, databases, indexes, collections - # - # stats_include = ["server", "databases", "indexes", "collections"] - - ## List of db where database stats are collected - ## If empty, all db are concerned - # db_stats_dbs = [] - - ## List of db where index status are collected - ## If empty, all indexes from all db are concerned - # index_stats_dbs = [] - - ## List of db where collection status are collected - ## If empty, all collections from all db are concerned - # collection_stats_dbs = [] -` - -func (r *RavenDB) SampleConfig() string { - return sampleConfig -} - -func (r *RavenDB) Description() string { - return "Reads metrics from RavenDB servers via the Monitoring Endpoints" -} - func (r *RavenDB) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/ravendb/ravendb_sample_config.go b/plugins/inputs/ravendb/ravendb_sample_config.go new file mode 100644 index 0000000000000..c709d3f089528 --- /dev/null +++ b/plugins/inputs/ravendb/ravendb_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ravendb + +func (r *RavenDB) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md index a033493e605a1..bf106b9738dbc 100644 --- a/plugins/inputs/redfish/README.md +++ b/plugins/inputs/redfish/README.md @@ -7,6 +7,7 @@ Telegraf minimum version: Telegraf 1.15.0 ## Configuration ```toml +# Read CPU, Fans, Powersupply and Voltage metrics of hardware server through redfish APIs [[inputs.redfish]] ## Redfish API Base URL. address = "https://127.0.0.1:5000" diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index bda0779c941b6..abf1d65e2d561 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -16,29 +16,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const description = "Read CPU, Fans, Powersupply and Voltage metrics of hardware server through redfish APIs" -const sampleConfig = ` - ## Server url - address = "https://127.0.0.1:5000" - - ## Username, Password for hardware server - username = "root" - password = "password123456" - - ## ComputerSystemId - computer_system_id="2M220100SL" - - ## Amount of time allowed to complete the HTTP request - # timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - type Redfish struct { Address string `toml:"address"` Username string `toml:"username"` @@ -133,14 +110,6 @@ type Status struct { Health string } -func (r *Redfish) Description() string { - return description -} - -func (r *Redfish) SampleConfig() string { - return sampleConfig -} - func (r *Redfish) Init() error { if r.Address == "" { return fmt.Errorf("did not provide IP") diff --git a/plugins/inputs/redfish/redfish_sample_config.go b/plugins/inputs/redfish/redfish_sample_config.go new file mode 100644 index 0000000000000..d1be463cb8f3b --- /dev/null +++ b/plugins/inputs/redfish/redfish_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package redfish + +func (r *Redfish) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/redis/README.md b/plugins/inputs/redis/README.md index eff031bab7cfd..63aac629c1ce2 100644 --- a/plugins/inputs/redis/README.md +++ b/plugins/inputs/redis/README.md @@ -3,7 +3,7 @@ ## Configuration ```toml -# Read Redis's basic status information +# Read metrics from one or many redis servers [[inputs.redis]] ## specify servers via a url matching: ## [protocol://][:password]@address[:port] @@ -18,7 +18,7 @@ ## Optional. Specify redis commands to retrieve values # [[inputs.redis.commands]] - # # The command to run where each argument is a separate element + # # The command to run where each argument is a separate element # command = ["get", "sample-key"] # # The field to store the result in # field = "sample-key-value" diff --git a/plugins/inputs/redis/redis.go b/plugins/inputs/redis/redis.go index b66d4ea41d36b..d65724d3d9c7a 100644 --- a/plugins/inputs/redis/redis.go +++ b/plugins/inputs/redis/redis.go @@ -187,47 +187,6 @@ func (r *RedisClient) BaseTags() map[string]string { var replicationSlaveMetricPrefix = regexp.MustCompile(`^slave\d+`) -var sampleConfig = ` - ## specify servers via a url matching: - ## [protocol://][:password]@address[:port] - ## e.g. - ## tcp://localhost:6379 - ## tcp://:password@192.168.99.100 - ## unix:///var/run/redis.sock - ## - ## If no servers are specified, then localhost is used as the host. - ## If no port is specified, 6379 is used - servers = ["tcp://localhost:6379"] - - ## Optional. Specify redis commands to retrieve values - # [[inputs.redis.commands]] - # # The command to run where each argument is a separate element - # command = ["get", "sample-key"] - # # The field to store the result in - # field = "sample-key-value" - # # The type of the result - # # Can be "string", "integer", or "float" - # type = "string" - - ## specify server password - # password = "s#cr@t%" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = true -` - -func (r *Redis) SampleConfig() string { - return sampleConfig -} - -func (r *Redis) Description() string { - return "Read metrics from one or many redis servers" -} - var Tracking = map[string]string{ "uptime_in_seconds": "uptime", "connected_clients": "clients", diff --git a/plugins/inputs/redis/redis_sample_config.go b/plugins/inputs/redis/redis_sample_config.go new file mode 100644 index 0000000000000..8039df2f3fd5d --- /dev/null +++ b/plugins/inputs/redis/redis_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package redis + +func (r *Redis) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/redis_sentinel/README.md b/plugins/inputs/redis_sentinel/README.md index 777e57a2d8ac8..793e68df5c42e 100644 --- a/plugins/inputs/redis_sentinel/README.md +++ b/plugins/inputs/redis_sentinel/README.md @@ -6,13 +6,14 @@ monitoring multiple Redis servers and replicas. ## Configuration ```toml -# Read Redis Sentinel's basic status information +# Read metrics from one or many redis-sentinel servers [[inputs.redis_sentinel]] ## specify servers via a url matching: ## [protocol://][:password]@address[:port] ## e.g. ## tcp://localhost:26379 ## tcp://:password@192.168.99.100 + ## unix:///var/run/redis-sentinel.sock ## ## If no servers are specified, then localhost is used as the host. ## If no port is specified, 26379 is used diff --git a/plugins/inputs/redis_sentinel/redis_sentinel.go b/plugins/inputs/redis_sentinel/redis_sentinel.go index 8e627d0328b4f..be80ebe2ba69b 100644 --- a/plugins/inputs/redis_sentinel/redis_sentinel.go +++ b/plugins/inputs/redis_sentinel/redis_sentinel.go @@ -39,32 +39,6 @@ func init() { }) } -func (r *RedisSentinel) SampleConfig() string { - return ` - ## specify servers via a url matching: - ## [protocol://][:password]@address[:port] - ## e.g. - ## tcp://localhost:26379 - ## tcp://:password@192.168.99.100 - ## unix:///var/run/redis-sentinel.sock - ## - ## If no servers are specified, then localhost is used as the host. - ## If no port is specified, 26379 is used - # servers = ["tcp://localhost:26379"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = true -` -} - -func (r *RedisSentinel) Description() string { - return "Read metrics from one or many redis-sentinel servers" -} - func (r *RedisSentinel) Init() error { if len(r.Servers) == 0 { r.Servers = []string{"tcp://localhost:26379"} diff --git a/plugins/inputs/redis_sentinel/redis_sentinel_sample_config.go b/plugins/inputs/redis_sentinel/redis_sentinel_sample_config.go new file mode 100644 index 0000000000000..69003d726acae --- /dev/null +++ b/plugins/inputs/redis_sentinel/redis_sentinel_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package redis_sentinel + +func (r *RedisSentinel) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/rethinkdb/README.md b/plugins/inputs/rethinkdb/README.md index 852da8318e704..3368d5c899a56 100644 --- a/plugins/inputs/rethinkdb/README.md +++ b/plugins/inputs/rethinkdb/README.md @@ -8,6 +8,7 @@ This section contains the default TOML to configure the plugin. You can generate it using `telegraf --usage rethinkdb`. ```toml +# Read metrics from one or many RethinkDB servers [[inputs.rethinkdb]] ## An array of URI to gather stats about. Specify an ip or hostname ## with optional port add password. ie, diff --git a/plugins/inputs/rethinkdb/rethinkdb.go b/plugins/inputs/rethinkdb/rethinkdb.go index a0108acf64df5..8cab237213818 100644 --- a/plugins/inputs/rethinkdb/rethinkdb.go +++ b/plugins/inputs/rethinkdb/rethinkdb.go @@ -15,31 +15,6 @@ type RethinkDB struct { Servers []string } -var sampleConfig = ` - ## An array of URI to gather stats about. Specify an ip or hostname - ## with optional port add password. ie, - ## rethinkdb://user:auth_key@10.10.3.30:28105, - ## rethinkdb://10.10.3.33:18832, - ## 10.0.0.1:10000, etc. - servers = ["127.0.0.1:28015"] - ## - ## If you use actual rethinkdb of > 2.3.0 with username/password authorization, - ## protocol have to be named "rethinkdb2" - it will use 1_0 H. - # servers = ["rethinkdb2://username:password@127.0.0.1:28015"] - ## - ## If you use older versions of rethinkdb (<2.2) with auth_key, protocol - ## have to be named "rethinkdb". - # servers = ["rethinkdb://username:auth_key@127.0.0.1:28015"] -` - -func (r *RethinkDB) SampleConfig() string { - return sampleConfig -} - -func (r *RethinkDB) Description() string { - return "Read metrics from one or many RethinkDB servers" -} - var localhost = &Server{URL: &url.URL{Host: "127.0.0.1:28015"}} // Reads stats from all configured servers accumulates stats. diff --git a/plugins/inputs/rethinkdb/rethinkdb_sample_config.go b/plugins/inputs/rethinkdb/rethinkdb_sample_config.go new file mode 100644 index 0000000000000..5386eb0622a17 --- /dev/null +++ b/plugins/inputs/rethinkdb/rethinkdb_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package rethinkdb + +func (r *RethinkDB) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/riak/README.md b/plugins/inputs/riak/README.md index f1a46af336ff9..7a7d682bfc7da 100644 --- a/plugins/inputs/riak/README.md +++ b/plugins/inputs/riak/README.md @@ -5,7 +5,7 @@ The Riak plugin gathers metrics from one or more riak instances. ## Configuration ```toml -# Description +# Read metrics one or many Riak servers [[inputs.riak]] # Specify a list of one or more riak http servers servers = ["http://localhost:8098"] diff --git a/plugins/inputs/riak/riak.go b/plugins/inputs/riak/riak.go index 6a1a98e4586a1..c67cf4faae85e 100644 --- a/plugins/inputs/riak/riak.go +++ b/plugins/inputs/riak/riak.go @@ -79,22 +79,6 @@ type riakStats struct { ReadRepairsTotal int64 `json:"read_repairs_total"` } -// A sample configuration to only gather stats from localhost, default port. -const sampleConfig = ` - # Specify a list of one or more riak http servers - servers = ["http://localhost:8098"] -` - -// Returns a sample configuration for the plugin -func (r *Riak) SampleConfig() string { - return sampleConfig -} - -// Returns a description of the plugin -func (r *Riak) Description() string { - return "Read metrics one or many Riak servers" -} - // Reads stats from all configured servers. func (r *Riak) Gather(acc telegraf.Accumulator) error { // Default to a single server at localhost (default port) if none specified diff --git a/plugins/inputs/riak/riak_sample_config.go b/plugins/inputs/riak/riak_sample_config.go new file mode 100644 index 0000000000000..aa7730eab5fbb --- /dev/null +++ b/plugins/inputs/riak/riak_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package riak + +func (r *Riak) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/riemann_listener/README.md b/plugins/inputs/riemann_listener/README.md index 9110a5f1eb147..338bac2bc958d 100644 --- a/plugins/inputs/riemann_listener/README.md +++ b/plugins/inputs/riemann_listener/README.md @@ -8,6 +8,7 @@ client that use riemann clients using riemann-protobuff format. This is a sample configuration for the plugin. ```toml +# Riemann protobuff listener [[inputs.rimann_listener]] ## URL to listen on ## Default is "tcp://:5555" diff --git a/plugins/inputs/riemann_listener/riemann_listener.go b/plugins/inputs/riemann_listener/riemann_listener.go index 597e2b8847714..1f2290ad2b903 100644 --- a/plugins/inputs/riemann_listener/riemann_listener.go +++ b/plugins/inputs/riemann_listener/riemann_listener.go @@ -265,40 +265,6 @@ func (rsl *riemannListener) riemannReturnErrorResponse(conn net.Conn, errorMessa } } -func (rsl *RiemannSocketListener) Description() string { - return "Riemann protobuff listener." -} - -func (rsl *RiemannSocketListener) SampleConfig() string { - return ` - ## URL to listen on. - ## Default is "tcp://:5555" - # service_address = "tcp://:8094" - # service_address = "tcp://127.0.0.1:http" - # service_address = "tcp4://:8094" - # service_address = "tcp6://:8094" - # service_address = "tcp6://[2001:db8::1]:8094" - - ## Maximum number of concurrent connections. - ## 0 (default) is unlimited. - # max_connections = 1024 - ## Read timeout. - ## 0 (default) is unlimited. - # read_timeout = "30s" - ## Optional TLS configuration. - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Enables client authentication if set. - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - ## Maximum socket buffer size (in bytes when no unit specified). - # read_buffer_size = "64KiB" - ## Period between keep alive probes. - ## 0 disables keep alive probes. - ## Defaults to the OS configuration. - # keep_alive_period = "5m" -` -} - func (rsl *RiemannSocketListener) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/riemann_listener/riemann_listener_sample_config.go b/plugins/inputs/riemann_listener/riemann_listener_sample_config.go new file mode 100644 index 0000000000000..d6930162d2c41 --- /dev/null +++ b/plugins/inputs/riemann_listener/riemann_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package riemann_listener + +func (rsl *RiemannSocketListener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/salesforce/README.md b/plugins/inputs/salesforce/README.md index 26668212acce7..b0bebf68f16ff 100644 --- a/plugins/inputs/salesforce/README.md +++ b/plugins/inputs/salesforce/README.md @@ -6,16 +6,23 @@ It fetches its data from the [limits endpoint](https://developer.salesforce.com/ ## Configuration ```toml -# Gather Metrics about Salesforce limits and remaining usage +# Read API usage and limits for a Salesforce organisation [[inputs.salesforce]] + ## specify your credentials + ## username = "your_username" password = "your_password" - ## (Optional) security token - security_token = "your_security_token" - ## (Optional) environment type (sandbox or production) + ## + ## (optional) security token + # security_token = "your_security_token" + ## + ## (optional) environment type (sandbox or production) ## default is: production + ## # environment = "production" - ## (Optional) API version (default: "39.0") + ## + ## (optional) API version (default: "39.0") + ## # version = "39.0" ``` diff --git a/plugins/inputs/salesforce/salesforce.go b/plugins/inputs/salesforce/salesforce.go index f7c321d7ae978..fd6922eb27864 100644 --- a/plugins/inputs/salesforce/salesforce.go +++ b/plugins/inputs/salesforce/salesforce.go @@ -16,25 +16,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -var sampleConfig = ` - ## specify your credentials - ## - username = "your_username" - password = "your_password" - ## - ## (optional) security token - # security_token = "your_security_token" - ## - ## (optional) environment type (sandbox or production) - ## default is: production - ## - # environment = "production" - ## - ## (optional) API version (default: "39.0") - ## - # version = "39.0" -` - type limit struct { Max int Remaining int @@ -73,14 +54,6 @@ func NewSalesforce() *Salesforce { Environment: defaultEnvironment} } -func (s *Salesforce) SampleConfig() string { - return sampleConfig -} - -func (s *Salesforce) Description() string { - return "Read API usage and limits for a Salesforce organisation" -} - // Reads limits values from Salesforce API func (s *Salesforce) Gather(acc telegraf.Accumulator) error { limits, err := s.fetchLimits() diff --git a/plugins/inputs/salesforce/salesforce_sample_config.go b/plugins/inputs/salesforce/salesforce_sample_config.go new file mode 100644 index 0000000000000..83ae1c520e3e3 --- /dev/null +++ b/plugins/inputs/salesforce/salesforce_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package salesforce + +func (s *Salesforce) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/sensors/sensors.go b/plugins/inputs/sensors/sensors.go index f2590c105272a..82aaf20d265fd 100644 --- a/plugins/inputs/sensors/sensors.go +++ b/plugins/inputs/sensors/sensors.go @@ -30,21 +30,6 @@ type Sensors struct { path string } -func (*Sensors) Description() string { - return "Monitor sensors, requires lm-sensors package" -} - -func (*Sensors) SampleConfig() string { - return ` - ## Remove numbers from field names. - ## If true, a field name like 'temp1_input' will be changed to 'temp_input'. - # remove_numbers = true - - ## Timeout is the maximum amount of time that the sensors command can run. - # timeout = "5s" -` -} - func (s *Sensors) Gather(acc telegraf.Accumulator) error { if len(s.path) == 0 { return errors.New("sensors not found: verify that lm-sensors package is installed and that sensors is in your PATH") diff --git a/plugins/inputs/sensors/sensors_sample_config.go b/plugins/inputs/sensors/sensors_sample_config.go new file mode 100644 index 0000000000000..aadc20de8f9c9 --- /dev/null +++ b/plugins/inputs/sensors/sensors_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package sensors + +func (*Sensors) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/sflow/sflow.go b/plugins/inputs/sflow/sflow.go index 3b18409c13a77..7579b34571919 100644 --- a/plugins/inputs/sflow/sflow.go +++ b/plugins/inputs/sflow/sflow.go @@ -14,18 +14,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## Address to listen for sFlow packets. - ## example: service_address = "udp://:6343" - ## service_address = "udp4://:6343" - ## service_address = "udp6://:6343" - service_address = "udp://:6343" - - ## Set the size of the operating system's receive buffer. - ## example: read_buffer_size = "64KiB" - # read_buffer_size = "" -` - const ( maxPacketSize = 64 * 1024 ) @@ -42,16 +30,6 @@ type SFlow struct { wg sync.WaitGroup } -// Description answers a description of this input plugin -func (s *SFlow) Description() string { - return "SFlow V5 Protocol Listener" -} - -// SampleConfig answers a sample configuration -func (s *SFlow) SampleConfig() string { - return sampleConfig -} - func (s *SFlow) Init() error { s.decoder = NewDecoder() s.decoder.Log = s.Log diff --git a/plugins/inputs/sflow/sflow_sample_config.go b/plugins/inputs/sflow/sflow_sample_config.go new file mode 100644 index 0000000000000..92a18f8f17a5c --- /dev/null +++ b/plugins/inputs/sflow/sflow_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package sflow + +func (s *SFlow) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/smart/smart.go b/plugins/inputs/smart/smart.go index 71bd681a29c81..d8f8917506cc7 100644 --- a/plugins/inputs/smart/smart.go +++ b/plugins/inputs/smart/smart.go @@ -347,56 +347,6 @@ type nvmeDevice struct { serialNumber string } -var sampleConfig = ` - ## Optionally specify the path to the smartctl executable - # path_smartctl = "/usr/bin/smartctl" - - ## Optionally specify the path to the nvme-cli executable - # path_nvme = "/usr/bin/nvme" - - ## Optionally specify if vendor specific attributes should be propagated for NVMe disk case - ## ["auto-on"] - automatically find and enable additional vendor specific disk info - ## ["vendor1", "vendor2", ...] - e.g. "Intel" enable additional Intel specific disk info - # enable_extensions = ["auto-on"] - - ## On most platforms used cli utilities requires root access. - ## Setting 'use_sudo' to true will make use of sudo to run smartctl or nvme-cli. - ## Sudo must be configured to allow the telegraf user to run smartctl or nvme-cli - ## without a password. - # use_sudo = false - - ## Skip checking disks in this power mode. Defaults to - ## "standby" to not wake up disks that have stopped rotating. - ## See --nocheck in the man pages for smartctl. - ## smartctl version 5.41 and 5.42 have faulty detection of - ## power mode and might require changing this value to - ## "never" depending on your disks. - # nocheck = "standby" - - ## Gather all returned S.M.A.R.T. attribute metrics and the detailed - ## information from each drive into the 'smart_attribute' measurement. - # attributes = false - - ## Optionally specify devices to exclude from reporting if disks auto-discovery is performed. - # excludes = [ "/dev/pass6" ] - - ## Optionally specify devices and device type, if unset - ## a scan (smartctl --scan and smartctl --scan -d nvme) for S.M.A.R.T. devices will be done - ## and all found will be included except for the excluded in excludes. - # devices = [ "/dev/ada0 -d atacam", "/dev/nvme0"] - - ## Timeout for the cli command to complete. - # timeout = "30s" - - ## Optionally call smartctl and nvme-cli with a specific concurrency policy. - ## By default, smartctl and nvme-cli are called in separate threads (goroutines) to gather disk attributes. - ## Some devices (e.g. disks in RAID arrays) may have access limitations that require sequential reading of - ## SMART data - one individual array drive at the time. In such case please set this configuration option - ## to "sequential" to get readings for all drives. - ## valid options: concurrent, sequential - # read_method = "concurrent" -` - func newSmart() *Smart { return &Smart{ Timeout: config.Duration(time.Second * 30), @@ -404,16 +354,6 @@ func newSmart() *Smart { } } -// SampleConfig returns sample configuration for this plugin. -func (m *Smart) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description. -func (m *Smart) Description() string { - return "Read metrics from storage devices supporting S.M.A.R.T." -} - // Init performs one time setup of the plugin and returns an error if the configuration is invalid. func (m *Smart) Init() error { //if deprecated `path` (to smartctl binary) is provided in config and `path_smartctl` override does not exist diff --git a/plugins/inputs/smart/smart_sample_config.go b/plugins/inputs/smart/smart_sample_config.go new file mode 100644 index 0000000000000..4d4f1fb568012 --- /dev/null +++ b/plugins/inputs/smart/smart_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package smart + +func (m *Smart) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/snmp/README.md b/plugins/inputs/snmp/README.md index 7d4457916f5e2..a517e510690ff 100644 --- a/plugins/inputs/snmp/README.md +++ b/plugins/inputs/snmp/README.md @@ -12,10 +12,11 @@ path onto the global path variable ## Configuration ```toml +# Retrieves SNMP values from remote agents [[inputs.snmp]] ## Agent addresses to retrieve values from. ## format: agents = [":"] - ## scheme: optional, either udp, udp4, udp6, tcp, tcp4, tcp6. + ## scheme: optional, either udp, udp4, udp6, tcp, tcp4, tcp6. ## default is udp ## port: optional ## example: agents = ["udp://127.0.0.1:161"] @@ -59,7 +60,7 @@ path onto the global path variable ## Context Name. # context_name = "" ## Privacy protocol used for encrypted messages; one of "DES", "AES", "AES192", "AES192C", "AES256", "AES256C", or "". - ### Protocols "AES192", "AES192", "AES256", and "AES256C" require the underlying net-snmp tools + ### Protocols "AES192", "AES192", "AES256", and "AES256C" require the underlying net-snmp tools ### to be compiled with --enable-blumenthal-aes (http://www.net-snmp.org/docs/INSTALL.html) # priv_protocol = "" ## Privacy password used for encrypted messages. @@ -131,7 +132,7 @@ option operate similar to the `snmpget` utility. ## or hextoint:BigEndian:uint32. Valid options for the Endian are: ## BigEndian and LittleEndian. For the bit size: uint16, uint32 ## and uint64. - ## + ## # conversion = "" ``` @@ -198,17 +199,17 @@ One [metric][] is created for each row of the SNMP table. ## Specifies if the value of given field should be snmptranslated ## by default no field values are translated # translate = true - + ## Secondary index table allows to merge data from two tables with ## different index that this filed will be used to join them. There can ## be only one secondary index table. # secondary_index_table = false - + ## This field is using secondary index, and will be later merged with ## primary index using SecondaryIndexTable. SecondaryIndexTable and ## SecondaryIndexUse are exclusive. # secondary_index_use = false - + ## Controls if entries from secondary table should be added or not ## if joining index is present or not. I set to true, means that join ## is outer, and index is prepended with "Secondary." for missing values diff --git a/plugins/inputs/snmp/snmp.go b/plugins/inputs/snmp/snmp.go index 23a872ca692c8..eecc4ec47b12e 100644 --- a/plugins/inputs/snmp/snmp.go +++ b/plugins/inputs/snmp/snmp.go @@ -19,63 +19,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const description = `Retrieves SNMP values from remote agents` -const sampleConfig = ` - ## Agent addresses to retrieve values from. - ## format: agents = [":"] - ## scheme: optional, either udp, udp4, udp6, tcp, tcp4, tcp6. - ## default is udp - ## port: optional - ## example: agents = ["udp://127.0.0.1:161"] - ## agents = ["tcp://127.0.0.1:161"] - ## agents = ["udp4://v4only-snmp-agent"] - agents = ["udp://127.0.0.1:161"] - - ## Timeout for each request. - # timeout = "5s" - - ## SNMP version; can be 1, 2, or 3. - # version = 2 - - ## Path to mib files - ## Used by the gosmi translator. - ## To add paths when translating with netsnmp, use the MIBDIRS environment variable - # path = ["/usr/share/snmp/mibs"] - - ## Agent host tag; the tag used to reference the source host - # agent_host_tag = "agent_host" - - ## SNMP community string. - # community = "public" - - ## Number of retries to attempt. - # retries = 3 - - ## The GETBULK max-repetitions parameter. - # max_repetitions = 10 - - ## SNMPv3 authentication and encryption options. - ## - ## Security Name. - # sec_name = "myuser" - ## Authentication protocol; one of "MD5", "SHA", "SHA224", "SHA256", "SHA384", "SHA512" or "". - # auth_protocol = "MD5" - ## Authentication password. - # auth_password = "pass" - ## Security Level; one of "noAuthNoPriv", "authNoPriv", or "authPriv". - # sec_level = "authNoPriv" - ## Context Name. - # context_name = "" - ## Privacy protocol used for encrypted messages; one of "DES", "AES" or "". - # priv_protocol = "" - ## Privacy password used for encrypted messages. - # priv_password = "" - - ## Add fields and tables defining the variables you wish to collect. This - ## example collects the system uptime and interface variables. Reference the - ## full plugin documentation for configuration details. -` - type Translator interface { SnmpTranslate(oid string) ( mibName string, oidNum string, oidText string, @@ -364,16 +307,6 @@ func init() { }) } -// SampleConfig returns the default configuration of the input. -func (s *Snmp) SampleConfig() string { - return sampleConfig -} - -// Description returns a one-sentence description on the input. -func (s *Snmp) Description() string { - return description -} - // Gather retrieves all the configured fields and tables. // Any error encountered does not halt the process. The errors are accumulated // and returned at the end. diff --git a/plugins/inputs/snmp/snmp_sample_config.go b/plugins/inputs/snmp/snmp_sample_config.go new file mode 100644 index 0000000000000..77f9a1e68044d --- /dev/null +++ b/plugins/inputs/snmp/snmp_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package snmp + +func (s *Snmp) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/snmp/snmp_test.go b/plugins/inputs/snmp/snmp_test.go index 65e1e73b055c3..b944e0ddbb376 100644 --- a/plugins/inputs/snmp/snmp_test.go +++ b/plugins/inputs/snmp/snmp_test.go @@ -12,9 +12,7 @@ import ( "github.com/gosnmp/gosnmp" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal/snmp" - "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/testutil" - "github.com/influxdata/toml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -93,27 +91,6 @@ var tsc = &testSNMPConnection{ }, } -func TestSampleConfig(t *testing.T) { - conf := inputs.Inputs["snmp"]() - err := toml.Unmarshal([]byte(conf.SampleConfig()), conf) - require.NoError(t, err) - - expected := &Snmp{ - Agents: []string{"udp://127.0.0.1:161"}, - AgentHostTag: "", - ClientConfig: snmp.ClientConfig{ - Timeout: config.Duration(5 * time.Second), - Version: 2, - Path: []string{"/usr/share/snmp/mibs"}, - Community: "public", - MaxRepetitions: 10, - Retries: 3, - }, - Name: "snmp", - } - require.Equal(t, expected, conf) -} - func TestFieldInit(t *testing.T) { translations := []struct { inputOid string diff --git a/plugins/inputs/snmp_legacy/README.md b/plugins/inputs/snmp_legacy/README.md index e4a91080704e6..8a7bf6cac3571 100644 --- a/plugins/inputs/snmp_legacy/README.md +++ b/plugins/inputs/snmp_legacy/README.md @@ -6,25 +6,101 @@ The SNMP input plugin gathers metrics from SNMP agents ## Configuration -### Very simple example - In this example, the plugin will gather value of OIDS: - `.1.3.6.1.2.1.2.2.1.4.1` ```toml -# Very Simple Example -[[inputs.snmp]] - +[[inputs.snmp_legacy]] + ## Use 'oids.txt' file to translate oids to names + ## To generate 'oids.txt' you need to run: + ## snmptranslate -m all -Tz -On | sed -e 's/"//g' > /tmp/oids.txt + ## Or if you have an other MIB folder with custom MIBs + ## snmptranslate -M /mycustommibfolder -Tz -On -m all | sed -e 's/"//g' > oids.txt + snmptranslate_file = "/tmp/oids.txt" [[inputs.snmp.host]] - address = "127.0.0.1:161" + address = "192.168.2.2:161" # SNMP community community = "public" # default public # SNMP version (1, 2 or 3) # Version 3 not supported yet version = 2 # default 2 + # SNMP response timeout + timeout = 2.0 # default 2.0 + # SNMP request retries + retries = 2 # default 2 + # Which get/bulk do you want to collect for this host + collect = ["mybulk", "sysservices", "sysdescr"] # Simple list of OIDs to get, in addition to "collect" - get_oids = [".1.3.6.1.2.1.2.2.1.4.1"] + get_oids = [] + [[inputs.snmp.host]] + address = "192.168.2.3:161" + community = "public" + version = 2 + timeout = 2.0 + retries = 2 + collect = ["mybulk"] + get_oids = [ + "ifNumber", + ".1.3.6.1.2.1.1.3.0", + ] + [[inputs.snmp.get]] + name = "ifnumber" + oid = "ifNumber" + [[inputs.snmp.get]] + name = "interface_speed" + oid = "ifSpeed" + instance = "0" + [[inputs.snmp.get]] + name = "sysuptime" + oid = ".1.3.6.1.2.1.1.3.0" + unit = "second" + [[inputs.snmp.bulk]] + name = "mybulk" + max_repetition = 127 + oid = ".1.3.6.1.2.1.1" + [[inputs.snmp.bulk]] + name = "ifoutoctets" + max_repetition = 127 + oid = "ifOutOctets" + [[inputs.snmp.host]] + address = "192.168.2.13:161" + #address = "127.0.0.1:161" + community = "public" + version = 2 + timeout = 2.0 + retries = 2 + #collect = ["mybulk", "sysservices", "sysdescr", "systype"] + collect = ["sysuptime" ] + [[inputs.snmp.host.table]] + name = "iftable3" + include_instances = ["enp5s0", "eth1"] + # SNMP TABLEs + # table without mapping neither subtables + [[inputs.snmp.table]] + name = "iftable1" + oid = ".1.3.6.1.2.1.31.1.1.1" + # table without mapping but with subtables + [[inputs.snmp.table]] + name = "iftable2" + oid = ".1.3.6.1.2.1.31.1.1.1" + sub_tables = [".1.3.6.1.2.1.2.2.1.13"] + # table with mapping but without subtables + [[inputs.snmp.table]] + name = "iftable3" + oid = ".1.3.6.1.2.1.31.1.1.1" + # if empty. get all instances + mapping_table = ".1.3.6.1.2.1.31.1.1.1.1" + # if empty, get all subtables + # table with both mapping and subtables + [[inputs.snmp.table]] + name = "iftable4" + oid = ".1.3.6.1.2.1.31.1.1.1" + # if empty get all instances + mapping_table = ".1.3.6.1.2.1.31.1.1.1.1" + # if empty get all subtables + # sub_tables could be not "real subtables" + sub_tables=[".1.3.6.1.2.1.2.2.1.13", "bytes_recv", "bytes_send"] ``` ### Simple example @@ -478,7 +554,7 @@ Note: the plugin will add instance name as tag *instance* # if empty get all instances mapping_table = ".1.3.6.1.2.1.31.1.1.1.1" # if empty get all subtables - # sub_tables could be not "real subtables" + # sub_tables could be not "real subtables" sub_tables=[".1.3.6.1.2.1.2.2.1.13", "bytes_recv", "bytes_send"] # note # oid attribute is useless diff --git a/plugins/inputs/snmp_legacy/snmp_legacy.go b/plugins/inputs/snmp_legacy/snmp_legacy.go index ce454cbfbad36..9071b7ee6c4c7 100644 --- a/plugins/inputs/snmp_legacy/snmp_legacy.go +++ b/plugins/inputs/snmp_legacy/snmp_legacy.go @@ -117,119 +117,6 @@ type Node struct { subnodes map[string]Node } -var sampleConfig = ` - ## Use 'oids.txt' file to translate oids to names - ## To generate 'oids.txt' you need to run: - ## snmptranslate -m all -Tz -On | sed -e 's/"//g' > /tmp/oids.txt - ## Or if you have an other MIB folder with custom MIBs - ## snmptranslate -M /mycustommibfolder -Tz -On -m all | sed -e 's/"//g' > oids.txt - snmptranslate_file = "/tmp/oids.txt" - [[inputs.snmp.host]] - address = "192.168.2.2:161" - # SNMP community - community = "public" # default public - # SNMP version (1, 2 or 3) - # Version 3 not supported yet - version = 2 # default 2 - # SNMP response timeout - timeout = 2.0 # default 2.0 - # SNMP request retries - retries = 2 # default 2 - # Which get/bulk do you want to collect for this host - collect = ["mybulk", "sysservices", "sysdescr"] - # Simple list of OIDs to get, in addition to "collect" - get_oids = [] - - [[inputs.snmp.host]] - address = "192.168.2.3:161" - community = "public" - version = 2 - timeout = 2.0 - retries = 2 - collect = ["mybulk"] - get_oids = [ - "ifNumber", - ".1.3.6.1.2.1.1.3.0", - ] - - [[inputs.snmp.get]] - name = "ifnumber" - oid = "ifNumber" - - [[inputs.snmp.get]] - name = "interface_speed" - oid = "ifSpeed" - instance = "0" - - [[inputs.snmp.get]] - name = "sysuptime" - oid = ".1.3.6.1.2.1.1.3.0" - unit = "second" - - [[inputs.snmp.bulk]] - name = "mybulk" - max_repetition = 127 - oid = ".1.3.6.1.2.1.1" - - [[inputs.snmp.bulk]] - name = "ifoutoctets" - max_repetition = 127 - oid = "ifOutOctets" - - [[inputs.snmp.host]] - address = "192.168.2.13:161" - #address = "127.0.0.1:161" - community = "public" - version = 2 - timeout = 2.0 - retries = 2 - #collect = ["mybulk", "sysservices", "sysdescr", "systype"] - collect = ["sysuptime" ] - [[inputs.snmp.host.table]] - name = "iftable3" - include_instances = ["enp5s0", "eth1"] - - # SNMP TABLEs - # table without mapping neither subtables - [[inputs.snmp.table]] - name = "iftable1" - oid = ".1.3.6.1.2.1.31.1.1.1" - - # table without mapping but with subtables - [[inputs.snmp.table]] - name = "iftable2" - oid = ".1.3.6.1.2.1.31.1.1.1" - sub_tables = [".1.3.6.1.2.1.2.2.1.13"] - - # table with mapping but without subtables - [[inputs.snmp.table]] - name = "iftable3" - oid = ".1.3.6.1.2.1.31.1.1.1" - # if empty. get all instances - mapping_table = ".1.3.6.1.2.1.31.1.1.1.1" - # if empty, get all subtables - - # table with both mapping and subtables - [[inputs.snmp.table]] - name = "iftable4" - oid = ".1.3.6.1.2.1.31.1.1.1" - # if empty get all instances - mapping_table = ".1.3.6.1.2.1.31.1.1.1.1" - # if empty get all subtables - # sub_tables could be not "real subtables" - sub_tables=[".1.3.6.1.2.1.2.2.1.13", "bytes_recv", "bytes_send"] -` - -// SampleConfig returns sample configuration message -func (s *Snmp) SampleConfig() string { - return sampleConfig -} - -// Description returns description of Zookeeper plugin -func (s *Snmp) Description() string { - return `DEPRECATED! PLEASE USE inputs.snmp INSTEAD.` -} - func fillnode(parentNode Node, oidName string, ids []string) { // ids = ["1", "3", "6", ...] id, ids := ids[0], ids[1:] diff --git a/plugins/inputs/snmp_legacy/snmp_legacy_sample_config.go b/plugins/inputs/snmp_legacy/snmp_legacy_sample_config.go new file mode 100644 index 0000000000000..8ec292634e607 --- /dev/null +++ b/plugins/inputs/snmp_legacy/snmp_legacy_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package snmp_legacy + +func (s *Snmp) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/snmp_trap/snmp_trap.go b/plugins/inputs/snmp_trap/snmp_trap.go index a197f757c4f71..94d46ef9e1b4d 100644 --- a/plugins/inputs/snmp_trap/snmp_trap.go +++ b/plugins/inputs/snmp_trap/snmp_trap.go @@ -49,45 +49,6 @@ type SnmpTrap struct { translator translator //nolint:revive } -var sampleConfig = ` - ## Transport, local address, and port to listen on. Transport must - ## be "udp://". Omit local address to listen on all interfaces. - ## example: "udp://127.0.0.1:1234" - ## - ## Special permissions may be required to listen on a port less than - ## 1024. See README.md for details - ## - # service_address = "udp://:162" - ## - ## Path to mib files - # path = ["/usr/share/snmp/mibs"] - ## - ## Snmp version, defaults to 2c - # version = "2c" - ## SNMPv3 authentication and encryption options. - ## - ## Security Name. - # sec_name = "myuser" - ## Authentication protocol; one of "MD5", "SHA" or "". - # auth_protocol = "MD5" - ## Authentication password. - # auth_password = "pass" - ## Security Level; one of "noAuthNoPriv", "authNoPriv", or "authPriv". - # sec_level = "authNoPriv" - ## Privacy protocol used for encrypted messages; one of "DES", "AES", "AES192", "AES192C", "AES256", "AES256C" or "". - # priv_protocol = "" - ## Privacy password used for encrypted messages. - # priv_password = "" -` - -func (s *SnmpTrap) SampleConfig() string { - return sampleConfig -} - -func (s *SnmpTrap) Description() string { - return "Receive SNMP traps" -} - func (s *SnmpTrap) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/snmp_trap/snmp_trap_sample_config.go b/plugins/inputs/snmp_trap/snmp_trap_sample_config.go new file mode 100644 index 0000000000000..ad0a5d999d6b0 --- /dev/null +++ b/plugins/inputs/snmp_trap/snmp_trap_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package snmp_trap + +func (s *SnmpTrap) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/socket_listener/socket_listener.go b/plugins/inputs/socket_listener/socket_listener.go index 362316ee5c468..8e77002538820 100644 --- a/plugins/inputs/socket_listener/socket_listener.go +++ b/plugins/inputs/socket_listener/socket_listener.go @@ -212,72 +212,6 @@ type SocketListener struct { io.Closer } -func (sl *SocketListener) Description() string { - return "Generic socket listener capable of handling multiple socket types." -} - -func (sl *SocketListener) SampleConfig() string { - return ` - ## URL to listen on - # service_address = "tcp://:8094" - # service_address = "tcp://127.0.0.1:http" - # service_address = "tcp4://:8094" - # service_address = "tcp6://:8094" - # service_address = "tcp6://[2001:db8::1]:8094" - # service_address = "udp://:8094" - # service_address = "udp4://:8094" - # service_address = "udp6://:8094" - # service_address = "unix:///tmp/telegraf.sock" - # service_address = "unixgram:///tmp/telegraf.sock" - - ## Change the file mode bits on unix sockets. These permissions may not be - ## respected by some platforms, to safely restrict write permissions it is best - ## to place the socket into a directory that has previously been created - ## with the desired permissions. - ## ex: socket_mode = "777" - # socket_mode = "" - - ## Maximum number of concurrent connections. - ## Only applies to stream sockets (e.g. TCP). - ## 0 (default) is unlimited. - # max_connections = 1024 - - ## Read timeout. - ## Only applies to stream sockets (e.g. TCP). - ## 0 (default) is unlimited. - # read_timeout = "30s" - - ## Optional TLS configuration. - ## Only applies to stream sockets (e.g. TCP). - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Enables client authentication if set. - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - - ## Maximum socket buffer size (in bytes when no unit specified). - ## For stream sockets, once the buffer fills up, the sender will start backing up. - ## For datagram sockets, once the buffer fills up, metrics will start dropping. - ## Defaults to the OS default. - # read_buffer_size = "64KiB" - - ## Period between keep alive probes. - ## Only applies to TCP sockets. - ## 0 disables keep alive probes. - ## Defaults to the OS configuration. - # keep_alive_period = "5m" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - # data_format = "influx" - - ## Content encoding for message payloads, can be set to "gzip" to or - ## "identity" to apply no encoding. - # content_encoding = "identity" -` -} - func (sl *SocketListener) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/socket_listener/socket_listener_sample_config.go b/plugins/inputs/socket_listener/socket_listener_sample_config.go new file mode 100644 index 0000000000000..27c3372995c46 --- /dev/null +++ b/plugins/inputs/socket_listener/socket_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package socket_listener + +func (sl *SocketListener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/socketstat/README.md b/plugins/inputs/socketstat/README.md index 833e861bfa50e..c9cff9a52ab93 100644 --- a/plugins/inputs/socketstat/README.md +++ b/plugins/inputs/socketstat/README.md @@ -9,6 +9,7 @@ The `ss` command does not require specific privileges. ## Configuration ```toml +# Gather indicators from established connections, using iproute2's ss command. [[inputs.socketstat]] ## ss can display information about tcp, udp, raw, unix, packet, dccp and sctp sockets ## Specify here the types you want to gather diff --git a/plugins/inputs/socketstat/socketstat.go b/plugins/inputs/socketstat/socketstat.go index 3140c6ad552ab..d987884d67505 100644 --- a/plugins/inputs/socketstat/socketstat.go +++ b/plugins/inputs/socketstat/socketstat.go @@ -37,22 +37,6 @@ type Socketstat struct { type socketLister func(cmdName string, proto string, timeout config.Duration) (*bytes.Buffer, error) -// Description returns a short description of the plugin -func (ss *Socketstat) Description() string { - return "Gather indicators from established connections, using iproute2's `ss` command." -} - -// SampleConfig returns sample configuration options -func (ss *Socketstat) SampleConfig() string { - return ` - ## ss can display information about tcp, udp, raw, unix, packet, dccp and sctp sockets - ## List of protocol types to collect - # protocols = [ "tcp", "udp" ] - ## The default timeout of 1s for ss execution can be overridden here: - # timeout = "1s" -` -} - // Gather gathers indicators from established connections func (ss *Socketstat) Gather(acc telegraf.Accumulator) error { // best effort : we continue through the protocols even if an error is encountered, diff --git a/plugins/inputs/socketstat/socketstat_sample_config.go b/plugins/inputs/socketstat/socketstat_sample_config.go new file mode 100644 index 0000000000000..f059f8cde4e0b --- /dev/null +++ b/plugins/inputs/socketstat/socketstat_sample_config.go @@ -0,0 +1,11 @@ +//go:build !windows +// +build !windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package socketstat + +func (ss *Socketstat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/solr/README.md b/plugins/inputs/solr/README.md index c9d1a6f36ba11..93763ae029221 100644 --- a/plugins/inputs/solr/README.md +++ b/plugins/inputs/solr/README.md @@ -10,6 +10,7 @@ Tested from 3.5 to 7.* ## Configuration ```toml +# Read stats from one or more Solr servers or cores [[inputs.solr]] ## specify a list of one or more Solr servers servers = ["http://localhost:8983"] diff --git a/plugins/inputs/solr/solr.go b/plugins/inputs/solr/solr.go index c74c3bcf6b09e..ae2e5c7d079e2 100644 --- a/plugins/inputs/solr/solr.go +++ b/plugins/inputs/solr/solr.go @@ -19,18 +19,6 @@ import ( const mbeansPath = "/admin/mbeans?stats=true&wt=json&cat=CORE&cat=QUERYHANDLER&cat=UPDATEHANDLER&cat=CACHE" const adminCoresPath = "/solr/admin/cores?action=STATUS&wt=json" -const sampleConfig = ` - ## specify a list of one or more Solr servers - servers = ["http://localhost:8983"] - - ## specify a list of one or more Solr cores (default - all) - # cores = ["main"] - - ## Optional HTTP Basic Auth Credentials - # username = "username" - # password = "pa$$word" -` - // Solr is a plugin to read stats from one or many Solr servers type Solr struct { Local bool @@ -126,16 +114,6 @@ func NewSolr() *Solr { } } -// SampleConfig returns sample configuration for this plugin. -func (s *Solr) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description. -func (s *Solr) Description() string { - return "Read stats from one or more Solr servers or cores" -} - // Gather reads the stats from Solr and writes it to the // Accumulator. func (s *Solr) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/solr/solr_sample_config.go b/plugins/inputs/solr/solr_sample_config.go new file mode 100644 index 0000000000000..655f502f2aef8 --- /dev/null +++ b/plugins/inputs/solr/solr_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package solr + +func (s *Solr) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/sql/sql.go b/plugins/inputs/sql/sql.go index 87227663bb4d0..9e4bca99c9d6f 100644 --- a/plugins/inputs/sql/sql.go +++ b/plugins/inputs/sql/sql.go @@ -19,84 +19,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## Database Driver - ## See https://github.com/influxdata/telegraf/blob/master/docs/SQL_DRIVERS_INPUT.md for - ## a list of supported drivers. - driver = "mysql" - - ## Data source name for connecting - ## The syntax and supported options depends on selected driver. - dsn = "username:password@mysqlserver:3307/dbname?param=value" - - ## Timeout for any operation - ## Note that the timeout for queries is per query not per gather. - # timeout = "5s" - - ## Connection time limits - ## By default the maximum idle time and maximum lifetime of a connection is unlimited, i.e. the connections - ## will not be closed automatically. If you specify a positive time, the connections will be closed after - ## idleing or existing for at least that amount of time, respectively. - # connection_max_idle_time = "0s" - # connection_max_life_time = "0s" - - ## Connection count limits - ## By default the number of open connections is not limited and the number of maximum idle connections - ## will be inferred from the number of queries specified. If you specify a positive number for any of the - ## two options, connections will be closed when reaching the specified limit. The number of idle connections - ## will be clipped to the maximum number of connections limit if any. - # connection_max_open = 0 - # connection_max_idle = auto - - [[inputs.sql.query]] - ## Query to perform on the server - query="SELECT user,state,latency,score FROM Scoreboard WHERE application > 0" - ## Alternatively to specifying the query directly you can select a file here containing the SQL query. - ## Only one of 'query' and 'query_script' can be specified! - # query_script = "/path/to/sql/script.sql" - - ## Name of the measurement - ## In case both measurement and 'measurement_col' are given, the latter takes precedence. - # measurement = "sql" - - ## Column name containing the name of the measurement - ## If given, this will take precedence over the 'measurement' setting. In case a query result - ## does not contain the specified column, we fall-back to the 'measurement' setting. - # measurement_column = "" - - ## Column name containing the time of the measurement - ## If ommited, the time of the query will be used. - # time_column = "" - - ## Format of the time contained in 'time_col' - ## The time must be 'unix', 'unix_ms', 'unix_us', 'unix_ns', or a golang time format. - ## See https://golang.org/pkg/time/#Time.Format for details. - # time_format = "unix" - - ## Column names containing tags - ## An empty include list will reject all columns and an empty exclude list will not exclude any column. - ## I.e. by default no columns will be returned as tag and the tags are empty. - # tag_columns_include = [] - # tag_columns_exclude = [] - - ## Column names containing fields (explicit types) - ## Convert the given columns to the corresponding type. Explicit type conversions take precedence over - ## the automatic (driver-based) conversion below. - ## NOTE: Columns should not be specified for multiple types or the resulting type is undefined. - # field_columns_float = [] - # field_columns_int = [] - # field_columns_uint = [] - # field_columns_bool = [] - # field_columns_string = [] - - ## Column names containing fields (automatic types) - ## An empty include list is equivalent to '[*]' and all returned columns will be accepted. An empty - ## exclude list will not exclude any column. I.e. by default all columns will be returned as fields. - ## NOTE: We rely on the database driver to perform automatic datatype conversion. - # field_columns_include = [] - # field_columns_exclude = [] -` - const magicIdleCount int = (-int(^uint(0) >> 1)) type Query struct { @@ -288,14 +210,6 @@ type SQL struct { db *dbsql.DB } -func (s *SQL) Description() string { - return `Read metrics from SQL queries` -} - -func (s *SQL) SampleConfig() string { - return sampleConfig -} - func (s *SQL) Init() error { // Option handling if s.Driver == "" { diff --git a/plugins/inputs/sql/sql_sample_config.go b/plugins/inputs/sql/sql_sample_config.go new file mode 100644 index 0000000000000..66e52ca4202da --- /dev/null +++ b/plugins/inputs/sql/sql_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package sql + +func (s *SQL) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/sqlserver/sqlserver.go b/plugins/inputs/sqlserver/sqlserver.go index 52aab4a864d7b..e7aa900c7c7c6 100644 --- a/plugins/inputs/sqlserver/sqlserver.go +++ b/plugins/inputs/sqlserver/sqlserver.go @@ -72,61 +72,6 @@ const ( // resource id for Azure SQL Database const sqlAzureResourceID = "https://database.windows.net/" -const sampleConfig = ` -## Specify instances to monitor with a list of connection strings. -## All connection parameters are optional. -## By default, the host is localhost, listening on default port, TCP 1433. -## for Windows, the user is the currently running AD user (SSO). -## See https://github.com/denisenkom/go-mssqldb for detailed connection -## parameters, in particular, tls connections can be created like so: -## "encrypt=true;certificate=;hostNameInCertificate=" -servers = [ - "Server=192.168.1.10;Port=1433;User Id=;Password=;app name=telegraf;log=1;", -] - -## Authentication method -## valid methods: "connection_string", "AAD" -# auth_method = "connection_string" - -## "database_type" enables a specific set of queries depending on the database type. -## In the config file, the sql server plugin section should be repeated each with a set of servers for a specific database_type. -## Possible values for database_type are - "SQLServer" or "AzureSQLDB" or "AzureSQLManagedInstance" or "AzureSQLPool" - -database_type = "SQLServer" - -## A list of queries to include. If not specified, all the below listed queries are used. -include_query = [] - -## A list of queries to explicitly ignore. -exclude_query = ["SQLServerAvailabilityReplicaStates", "SQLServerDatabaseReplicaStates"] - -## Queries enabled by default for database_type = "SQLServer" are - -## SQLServerPerformanceCounters, SQLServerWaitStatsCategorized, SQLServerDatabaseIO, SQLServerProperties, SQLServerMemoryClerks, -## SQLServerSchedulers, SQLServerRequests, SQLServerVolumeSpace, SQLServerCpu, SQLServerAvailabilityReplicaStates, SQLServerDatabaseReplicaStates - -## Queries enabled by default for database_type = "AzureSQLDB" are - -## AzureSQLDBResourceStats, AzureSQLDBResourceGovernance, AzureSQLDBWaitStats, AzureSQLDBDatabaseIO, AzureSQLDBServerProperties, -## AzureSQLDBOsWaitstats, AzureSQLDBMemoryClerks, AzureSQLDBPerformanceCounters, AzureSQLDBRequests, AzureSQLDBSchedulers - -## Queries enabled by default for database_type = "AzureSQLManagedInstance" are - -## AzureSQLMIResourceStats, AzureSQLMIResourceGovernance, AzureSQLMIDatabaseIO, AzureSQLMIServerProperties, AzureSQLMIOsWaitstats, -## AzureSQLMIMemoryClerks, AzureSQLMIPerformanceCounters, AzureSQLMIRequests, AzureSQLMISchedulers - -## Queries enabled by default for database_type = "AzureSQLPool" are - -## AzureSQLPoolResourceStats, AzureSQLPoolResourceGovernance, AzureSQLPoolDatabaseIO, AzureSQLPoolWaitStats, -## AzureSQLPoolMemoryClerks, AzureSQLPoolPerformanceCounters, AzureSQLPoolSchedulers -` - -// SampleConfig return the sample configuration -func (s *SQLServer) SampleConfig() string { - return sampleConfig -} - -// Description return plugin description -func (s *SQLServer) Description() string { - return "Read metrics from Microsoft SQL Server" -} - type scanner interface { Scan(dest ...interface{}) error } diff --git a/plugins/inputs/sqlserver/sqlserver_sample_config.go b/plugins/inputs/sqlserver/sqlserver_sample_config.go new file mode 100644 index 0000000000000..2e85f1373f30a --- /dev/null +++ b/plugins/inputs/sqlserver/sqlserver_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package sqlserver + +func (s *SQLServer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/stackdriver/README.md b/plugins/inputs/stackdriver/README.md index 7f706f2d13096..9426ced7abbf4 100644 --- a/plugins/inputs/stackdriver/README.md +++ b/plugins/inputs/stackdriver/README.md @@ -9,6 +9,7 @@ costs. ## Configuration ```toml +# Gather timeseries from Google Cloud Platform v3 monitoring API [[inputs.stackdriver]] ## GCP Project project = "erudite-bloom-151019" diff --git a/plugins/inputs/stackdriver/stackdriver.go b/plugins/inputs/stackdriver/stackdriver.go index 648e82624a1ea..9236e48b0ccdf 100644 --- a/plugins/inputs/stackdriver/stackdriver.go +++ b/plugins/inputs/stackdriver/stackdriver.go @@ -27,85 +27,6 @@ import ( const ( defaultRateLimit = 14 - description = "Gather timeseries from Google Cloud Platform v3 monitoring API" - sampleConfig = ` - ## GCP Project - project = "erudite-bloom-151019" - - ## Include timeseries that start with the given metric type. - metric_type_prefix_include = [ - "compute.googleapis.com/", - ] - - ## Exclude timeseries that start with the given metric type. - # metric_type_prefix_exclude = [] - - ## Many metrics are updated once per minute; it is recommended to override - ## the agent level interval with a value of 1m or greater. - interval = "1m" - - ## Maximum number of API calls to make per second. The quota for accounts - ## varies, it can be viewed on the API dashboard: - ## https://cloud.google.com/monitoring/quotas#quotas_and_limits - # rate_limit = 14 - - ## The delay and window options control the number of points selected on - ## each gather. When set, metrics are gathered between: - ## start: now() - delay - window - ## end: now() - delay - # - ## Collection delay; if set too low metrics may not yet be available. - # delay = "5m" - # - ## If unset, the window will start at 1m and be updated dynamically to span - ## the time between calls (approximately the length of the plugin interval). - # window = "1m" - - ## TTL for cached list of metric types. This is the maximum amount of time - ## it may take to discover new metrics. - # cache_ttl = "1h" - - ## If true, raw bucket counts are collected for distribution value types. - ## For a more lightweight collection, you may wish to disable and use - ## distribution_aggregation_aligners instead. - # gather_raw_distribution_buckets = true - - ## Aggregate functions to be used for metrics whose value type is - ## distribution. These aggregate values are recorded in in addition to raw - ## bucket counts; if they are enabled. - ## - ## For a list of aligner strings see: - ## https://cloud.google.com/monitoring/api/ref_v3/rpc/google.monitoring.v3#aligner - # distribution_aggregation_aligners = [ - # "ALIGN_PERCENTILE_99", - # "ALIGN_PERCENTILE_95", - # "ALIGN_PERCENTILE_50", - # ] - - ## Filters can be added to reduce the number of time series matched. All - ## functions are supported: starts_with, ends_with, has_substring, and - ## one_of. Only the '=' operator is supported. - ## - ## The logical operators when combining filters are defined statically using - ## the following values: - ## filter ::= {AND } - ## resource_labels ::= {OR } - ## metric_labels ::= {OR } - ## - ## For more details, see https://cloud.google.com/monitoring/api/v3/filters - # - ## Resource labels refine the time series selection with the following expression: - ## resource.labels. = - # [[inputs.stackdriver.filter.resource_labels]] - # key = "instance_name" - # value = 'starts_with("localhost")' - # - ## Metric labels refine the time series selection with the following expression: - ## metric.labels. = - # [[inputs.stackdriver.filter.metric_labels]] - # key = "device_name" - # value = 'one_of("sda", "sdb")' -` ) var ( @@ -264,16 +185,6 @@ func (smc *stackdriverMetricClient) Close() error { return smc.conn.Close() } -// Description implements telegraf.Input interface -func (s *Stackdriver) Description() string { - return description -} - -// SampleConfig implements telegraf.Input interface -func (s *Stackdriver) SampleConfig() string { - return sampleConfig -} - // Gather implements telegraf.Input interface func (s *Stackdriver) Gather(acc telegraf.Accumulator) error { ctx := context.Background() diff --git a/plugins/inputs/stackdriver/stackdriver_sample_config.go b/plugins/inputs/stackdriver/stackdriver_sample_config.go new file mode 100644 index 0000000000000..5d3123e340fdb --- /dev/null +++ b/plugins/inputs/stackdriver/stackdriver_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package stackdriver + +func (s *Stackdriver) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/statsd/statsd.go b/plugins/inputs/statsd/statsd.go index c1f43d7e9137b..c21cc11c5e5a7 100644 --- a/plugins/inputs/statsd/statsd.go +++ b/plugins/inputs/statsd/statsd.go @@ -219,88 +219,6 @@ type cacheddistributions struct { tags map[string]string } -func (s *Statsd) Description() string { - return "Statsd UDP/TCP Server" -} - -const sampleConfig = ` - ## Protocol, must be "tcp", "udp", "udp4" or "udp6" (default=udp) - protocol = "udp" - - ## MaxTCPConnection - applicable when protocol is set to tcp (default=250) - max_tcp_connections = 250 - - ## Enable TCP keep alive probes (default=false) - tcp_keep_alive = false - - ## Specifies the keep-alive period for an active network connection. - ## Only applies to TCP sockets and will be ignored if tcp_keep_alive is false. - ## Defaults to the OS configuration. - # tcp_keep_alive_period = "2h" - - ## Address and port to host UDP listener on - service_address = ":8125" - - ## The following configuration options control when telegraf clears it's cache - ## of previous values. If set to false, then telegraf will only clear it's - ## cache when the daemon is restarted. - ## Reset gauges every interval (default=true) - delete_gauges = true - ## Reset counters every interval (default=true) - delete_counters = true - ## Reset sets every interval (default=true) - delete_sets = true - ## Reset timings & histograms every interval (default=true) - delete_timings = true - - ## Percentiles to calculate for timing & histogram stats - percentiles = [50.0, 90.0, 99.0, 99.9, 99.95, 100.0] - - ## separator to use between elements of a statsd metric - metric_separator = "_" - - ## Parses tags in the datadog statsd format - ## http://docs.datadoghq.com/guides/dogstatsd/ - parse_data_dog_tags = false - - ## Parses datadog extensions to the statsd format - datadog_extensions = false - - ## Parses distributions metric as specified in the datadog statsd format - ## https://docs.datadoghq.com/developers/metrics/types/?tab=distribution#definition - datadog_distributions = false - - ## Statsd data translation templates, more info can be read here: - ## https://github.com/influxdata/telegraf/blob/master/docs/TEMPLATE_PATTERN.md - # templates = [ - # "cpu.* measurement*" - # ] - - ## Number of UDP messages allowed to queue up, once filled, - ## the statsd server will start dropping packets - allowed_pending_messages = 10000 - - ## Number of timing/histogram values to track per-measurement in the - ## calculation of percentiles. Raising this limit increases the accuracy - ## of percentiles but also increases the memory usage and cpu time. - percentile_limit = 1000 - - ## Max duration (TTL) for each metric to stay cached/reported without being updated. - #max_ttl = "1000h" - - ## Sanitize name method - ## By default, telegraf will pass names directly as they are received. - ## However, upstream statsd now does sanitization of names which can be - ## enabled by using the "upstream" method option. This option will a) replace - ## white space with '_', replace '/' with '-', and remove charachters not - ## matching 'a-zA-Z_\-0-9\.;='. - #sanitize_name_method = "" -` - -func (s *Statsd) SampleConfig() string { - return sampleConfig -} - func (s *Statsd) Gather(acc telegraf.Accumulator) error { s.Lock() defer s.Unlock() diff --git a/plugins/inputs/statsd/statsd_sample_config.go b/plugins/inputs/statsd/statsd_sample_config.go new file mode 100644 index 0000000000000..42c2a045208bd --- /dev/null +++ b/plugins/inputs/statsd/statsd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package statsd + +func (s *Statsd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/suricata/suricata.go b/plugins/inputs/suricata/suricata.go index 5e1dc384478b7..8186e545dfbc1 100644 --- a/plugins/inputs/suricata/suricata.go +++ b/plugins/inputs/suricata/suricata.go @@ -35,31 +35,6 @@ type Suricata struct { wg sync.WaitGroup } -// Description returns the plugin description. -func (s *Suricata) Description() string { - return "Suricata stats and alerts plugin" -} - -const sampleConfig = ` - ## Data sink for Suricata stats and alerts logs - # This is expected to be a filename of a - # unix socket to be created for listening. - source = "/var/run/suricata-stats.sock" - - # Delimiter for flattening field keys, e.g. subitem "alert" of "detect" - # becomes "detect_alert" when delimiter is "_". - delimiter = "_" - - ## Detect alert logs - # alerts = false -` - -// SampleConfig returns a sample TOML section to illustrate configuration -// options. -func (s *Suricata) SampleConfig() string { - return sampleConfig -} - // Start initiates background collection of JSON data from the socket // provided to Suricata. func (s *Suricata) Start(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/suricata/suricata_sample_config.go b/plugins/inputs/suricata/suricata_sample_config.go new file mode 100644 index 0000000000000..7974abde535d1 --- /dev/null +++ b/plugins/inputs/suricata/suricata_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package suricata + +func (s *Suricata) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/swap/swap.go b/plugins/inputs/swap/swap.go index c7c614c1ba83b..cd05786d91110 100644 --- a/plugins/inputs/swap/swap.go +++ b/plugins/inputs/swap/swap.go @@ -12,12 +12,6 @@ type SwapStats struct { ps system.PS } -func (ss *SwapStats) Description() string { - return "Read metrics about swap memory usage" -} - -func (ss *SwapStats) SampleConfig() string { return "" } - func (ss *SwapStats) Gather(acc telegraf.Accumulator) error { swap, err := ss.ps.SwapStat() if err != nil { diff --git a/plugins/inputs/swap/swap_sample_config.go b/plugins/inputs/swap/swap_sample_config.go new file mode 100644 index 0000000000000..0964ef4f86294 --- /dev/null +++ b/plugins/inputs/swap/swap_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package swap + +func (ss *SwapStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/synproxy/README.md b/plugins/inputs/synproxy/README.md index 117ee02e8fa97..70ce577056f2c 100644 --- a/plugins/inputs/synproxy/README.md +++ b/plugins/inputs/synproxy/README.md @@ -8,6 +8,7 @@ The use of synproxy is documented in `man iptables-extensions` under the SYNPROX The synproxy plugin does not need any configuration ```toml +# Get synproxy counter statistics from procfs [[inputs.synproxy]] # no configuration ``` diff --git a/plugins/inputs/synproxy/synproxy.go b/plugins/inputs/synproxy/synproxy.go index 6a5b2b3239ed9..3cd363cca17c0 100644 --- a/plugins/inputs/synproxy/synproxy.go +++ b/plugins/inputs/synproxy/synproxy.go @@ -15,14 +15,6 @@ type Synproxy struct { statFile string } -func (k *Synproxy) Description() string { - return "Get synproxy counter statistics from procfs" -} - -func (k *Synproxy) SampleConfig() string { - return "" -} - func getHostProc() string { procPath := "/proc" if os.Getenv("HOST_PROC") != "" { diff --git a/plugins/inputs/synproxy/synproxy_sample_config.go b/plugins/inputs/synproxy/synproxy_sample_config.go new file mode 100644 index 0000000000000..abdf8040736ad --- /dev/null +++ b/plugins/inputs/synproxy/synproxy_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package synproxy + +func (k *Synproxy) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/syslog/syslog.go b/plugins/inputs/syslog/syslog.go index bfc6f9283990c..39c2bf1cf53da 100644 --- a/plugins/inputs/syslog/syslog.go +++ b/plugins/inputs/syslog/syslog.go @@ -61,70 +61,6 @@ type Syslog struct { udpListener net.PacketConn } -var sampleConfig = ` - ## Specify an ip or hostname with port - eg., tcp://localhost:6514, tcp://10.0.0.1:6514 - ## Protocol, address and port to host the syslog receiver. - ## If no host is specified, then localhost is used. - ## If no port is specified, 6514 is used (RFC5425#section-4.1). - server = "tcp://:6514" - - ## TLS Config - # tls_allowed_cacerts = ["/etc/telegraf/ca.pem"] - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## Period between keep alive probes. - ## 0 disables keep alive probes. - ## Defaults to the OS configuration. - ## Only applies to stream sockets (e.g. TCP). - # keep_alive_period = "5m" - - ## Maximum number of concurrent connections (default = 0). - ## 0 means unlimited. - ## Only applies to stream sockets (e.g. TCP). - # max_connections = 1024 - - ## Read timeout is the maximum time allowed for reading a single message (default = 5s). - ## 0 means unlimited. - # read_timeout = "5s" - - ## The framing technique with which it is expected that messages are transported (default = "octet-counting"). - ## Whether the messages come using the octect-counting (RFC5425#section-4.3.1, RFC6587#section-3.4.1), - ## or the non-transparent framing technique (RFC6587#section-3.4.2). - ## Must be one of "octet-counting", "non-transparent". - # framing = "octet-counting" - - ## The trailer to be expected in case of non-transparent framing (default = "LF"). - ## Must be one of "LF", or "NUL". - # trailer = "LF" - - ## Whether to parse in best effort mode or not (default = false). - ## By default best effort parsing is off. - # best_effort = false - - ## The RFC standard to use for message parsing - ## By default RFC5424 is used. RFC3164 only supports UDP transport (no streaming support) - ## Must be one of "RFC5424", or "RFC3164". - # syslog_standard = "RFC5424" - - ## Character to prepend to SD-PARAMs (default = "_"). - ## A syslog message can contain multiple parameters and multiple identifiers within structured data section. - ## Eg., [id1 name1="val1" name2="val2"][id2 name1="val1" nameA="valA"] - ## For each combination a field is created. - ## Its name is created concatenating identifier, sdparam_separator, and parameter name. - # sdparam_separator = "_" -` - -// SampleConfig returns sample configuration message -func (s *Syslog) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description -func (s *Syslog) Description() string { - return "Accepts syslog messages following RFC5424 format with transports as per RFC5426, RFC5425, or RFC6587" -} - // Gather ... func (s *Syslog) Gather(_ telegraf.Accumulator) error { return nil diff --git a/plugins/inputs/syslog/syslog_sample_config.go b/plugins/inputs/syslog/syslog_sample_config.go new file mode 100644 index 0000000000000..002c39f0e6822 --- /dev/null +++ b/plugins/inputs/syslog/syslog_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package syslog + +func (s *Syslog) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/sysstat/README.md b/plugins/inputs/sysstat/README.md index 5c055a3c51af4..c10bc78e186a0 100644 --- a/plugins/inputs/sysstat/README.md +++ b/plugins/inputs/sysstat/README.md @@ -13,8 +13,10 @@ the created binary data file with the `sadf` utility. [[inputs.sysstat]] ## Path to the sadc command. # - ## On Debian and Arch Linux the default path is /usr/lib/sa/sadc whereas - ## on RHEL and CentOS the default path is /usr/lib64/sa/sadc + ## Common Defaults: + ## Debian/Ubuntu: /usr/lib/sysstat/sadc + ## Arch: /usr/lib/sa/sadc + ## RHEL/CentOS: /usr/lib64/sa/sadc sadc_path = "/usr/lib/sa/sadc" # required ## Path to the sadf command, if it is not in PATH @@ -38,20 +40,20 @@ the created binary data file with the `sadf` utility. ## ## Run 'sar -h' or 'man sar' to find out the supported options for your sysstat version. [inputs.sysstat.options] - -C = "cpu" - -B = "paging" - -b = "io" - -d = "disk" # requires DISK activity - "-n ALL" = "network" - "-P ALL" = "per_cpu" - -q = "queue" - -R = "mem" - -r = "mem_util" - -S = "swap_util" - -u = "cpu_util" - -v = "inode" - -W = "swap" - -w = "task" + -C = "cpu" + -B = "paging" + -b = "io" + -d = "disk" # requires DISK activity + "-n ALL" = "network" + "-P ALL" = "per_cpu" + -q = "queue" + -R = "mem" + -r = "mem_util" + -S = "swap_util" + -u = "cpu_util" + -v = "inode" + -W = "swap" + -w = "task" # -H = "hugepages" # only available for newer linux distributions # "-I ALL" = "interrupts" # requires INT activity diff --git a/plugins/inputs/sysstat/sysstat.go b/plugins/inputs/sysstat/sysstat.go index 3796aeb19ac58..a5c67cded573f 100644 --- a/plugins/inputs/sysstat/sysstat.go +++ b/plugins/inputs/sysstat/sysstat.go @@ -70,70 +70,6 @@ type Sysstat struct { Log telegraf.Logger } -func (*Sysstat) Description() string { - return "Sysstat metrics collector" -} - -var sampleConfig = ` - ## Path to the sadc command. - # - ## Common Defaults: - ## Debian/Ubuntu: /usr/lib/sysstat/sadc - ## Arch: /usr/lib/sa/sadc - ## RHEL/CentOS: /usr/lib64/sa/sadc - sadc_path = "/usr/lib/sa/sadc" # required - - ## Path to the sadf command, if it is not in PATH - # sadf_path = "/usr/bin/sadf" - - ## Activities is a list of activities, that are passed as argument to the - ## sadc collector utility (e.g: DISK, SNMP etc...) - ## The more activities that are added, the more data is collected. - # activities = ["DISK"] - - ## Group metrics to measurements. - ## - ## If group is false each metric will be prefixed with a description - ## and represents itself a measurement. - ## - ## If Group is true, corresponding metrics are grouped to a single measurement. - # group = true - - ## Options for the sadf command. The values on the left represent the sadf - ## options and the values on the right their description (which are used for - ## grouping and prefixing metrics). - ## - ## Run 'sar -h' or 'man sar' to find out the supported options for your - ## sysstat version. - [inputs.sysstat.options] - -C = "cpu" - -B = "paging" - -b = "io" - -d = "disk" # requires DISK activity - "-n ALL" = "network" - "-P ALL" = "per_cpu" - -q = "queue" - -R = "mem" - -r = "mem_util" - -S = "swap_util" - -u = "cpu_util" - -v = "inode" - -W = "swap" - -w = "task" - # -H = "hugepages" # only available for newer linux distributions - # "-I ALL" = "interrupts" # requires INT activity - - ## Device tags can be used to add additional tags for devices. - ## For example the configuration below adds a tag vg with value rootvg for - ## all metrics with sda devices. - # [[inputs.sysstat.device_tags.sda]] - # vg = "rootvg" -` - -func (*Sysstat) SampleConfig() string { - return sampleConfig -} - func (s *Sysstat) Gather(acc telegraf.Accumulator) error { if time.Duration(s.SadcInterval) != 0 { // Collect interval is calculated as interval - parseInterval diff --git a/plugins/inputs/sysstat/sysstat_sample_config.go b/plugins/inputs/sysstat/sysstat_sample_config.go new file mode 100644 index 0000000000000..2cff2c07d9254 --- /dev/null +++ b/plugins/inputs/sysstat/sysstat_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package sysstat + +func (*Sysstat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/system/system.go b/plugins/inputs/system/system.go index 7bf3c154e72a1..2eda2e3bb4f0e 100644 --- a/plugins/inputs/system/system.go +++ b/plugins/inputs/system/system.go @@ -19,17 +19,6 @@ type SystemStats struct { Log telegraf.Logger } -func (*SystemStats) Description() string { - return "Read metrics about system load & uptime" -} - -func (*SystemStats) SampleConfig() string { - return ` - ## Uncomment to remove deprecated metrics. - # fielddrop = ["uptime_format"] -` -} - func (s *SystemStats) Gather(acc telegraf.Accumulator) error { loadavg, err := load.Avg() if err != nil && !strings.Contains(err.Error(), "not implemented") { diff --git a/plugins/inputs/system/system_sample_config.go b/plugins/inputs/system/system_sample_config.go new file mode 100644 index 0000000000000..e67118438ca8d --- /dev/null +++ b/plugins/inputs/system/system_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package system + +func (*SystemStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/systemd_units/README.md b/plugins/inputs/systemd_units/README.md index 65344d0367629..75b317193e688 100644 --- a/plugins/inputs/systemd_units/README.md +++ b/plugins/inputs/systemd_units/README.md @@ -15,6 +15,7 @@ see `systemctl list-units --all --type help` for possible options. ## Configuration ```toml +# Gather systemd units state [[inputs.systemd_units]] ## Set timeout for systemctl execution # timeout = "1s" diff --git a/plugins/inputs/systemd_units/systemd_units_linux.go b/plugins/inputs/systemd_units/systemd_units.go similarity index 87% rename from plugins/inputs/systemd_units/systemd_units_linux.go rename to plugins/inputs/systemd_units/systemd_units.go index e41c64752977e..e9ac1a9182d6f 100644 --- a/plugins/inputs/systemd_units/systemd_units_linux.go +++ b/plugins/inputs/systemd_units/systemd_units.go @@ -119,31 +119,6 @@ var ( defaultPattern = "" ) -// Description returns a short description of the plugin -func (s *SystemdUnits) Description() string { - return "Gather systemd units state" -} - -// SampleConfig returns sample configuration options. -func (s *SystemdUnits) SampleConfig() string { - return ` - ## Set timeout for systemctl execution - # timeout = "1s" - # - ## Filter for a specific unit type, default is "service", other possible - ## values are "socket", "target", "device", "mount", "automount", "swap", - ## "timer", "path", "slice" and "scope ": - # unittype = "service" - # - ## Filter for a specific pattern, default is "" (i.e. all), other possible - ## values are valid pattern for systemctl, e.g. "a*" for all units with - ## names starting with "a" - # pattern = "" - ## pattern = "telegraf* influxdb*" - ## pattern = "a*" -` -} - // Gather parses systemctl outputs and adds counters to the Accumulator func (s *SystemdUnits) Gather(acc telegraf.Accumulator) error { out, err := s.systemctl(s.Timeout, s.UnitType, s.Pattern) diff --git a/plugins/inputs/systemd_units/systemd_units_sample_config.go b/plugins/inputs/systemd_units/systemd_units_sample_config.go new file mode 100644 index 0000000000000..a728a763b61c5 --- /dev/null +++ b/plugins/inputs/systemd_units/systemd_units_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package systemd_units + +func (s *SystemdUnits) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/systemd_units/systemd_units_linux_test.go b/plugins/inputs/systemd_units/systemd_units_test.go similarity index 100% rename from plugins/inputs/systemd_units/systemd_units_linux_test.go rename to plugins/inputs/systemd_units/systemd_units_test.go diff --git a/plugins/inputs/tail/tail.go b/plugins/inputs/tail/tail.go index f5f29256423dd..e27f6ad90f1f3 100644 --- a/plugins/inputs/tail/tail.go +++ b/plugins/inputs/tail/tail.go @@ -80,85 +80,6 @@ func NewTail() *Tail { } } -const sampleConfig = ` - ## File names or a pattern to tail. - ## These accept standard unix glob matching rules, but with the addition of - ## ** as a "super asterisk". ie: - ## "/var/log/**.log" -> recursively find all .log files in /var/log - ## "/var/log/*/*.log" -> find all .log files with a parent dir in /var/log - ## "/var/log/apache.log" -> just tail the apache log file - ## "/var/log/log[!1-2]* -> tail files without 1-2 - ## "/var/log/log[^1-2]* -> identical behavior as above - ## See https://github.com/gobwas/glob for more examples - ## - files = ["/var/mymetrics.out"] - - ## Read file from beginning. - # from_beginning = false - - ## Whether file is a named pipe - # pipe = false - - ## Method used to watch for file updates. Can be either "inotify" or "poll". - # watch_method = "inotify" - - ## Maximum lines of the file to process that have not yet be written by the - ## output. For best throughput set based on the number of metrics on each - ## line and the size of the output's metric_batch_size. - # max_undelivered_lines = 1000 - - ## Character encoding to use when interpreting the file contents. Invalid - ## characters are replaced using the unicode replacement character. When set - ## to the empty string the data is not decoded to text. - ## ex: character_encoding = "utf-8" - ## character_encoding = "utf-16le" - ## character_encoding = "utf-16be" - ## character_encoding = "" - # character_encoding = "" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" - - ## Set the tag that will contain the path of the tailed file. If you don't want this tag, set it to an empty string. - # path_tag = "path" - - ## Filters to apply to files before generating metrics - ## "ansi_color" removes ANSI colors - # filters = [] - - ## multiline parser/codec - ## https://www.elastic.co/guide/en/logstash/2.4/plugins-filters-multiline.html - #[inputs.tail.multiline] - ## The pattern should be a regexp which matches what you believe to be an - ## indicator that the field is part of an event consisting of multiple lines of log data. - #pattern = "^\s" - - ## This field must be either "previous" or "next". - ## If a line matches the pattern, "previous" indicates that it belongs to the previous line, - ## whereas "next" indicates that the line belongs to the next one. - #match_which_line = "previous" - - ## The invert_match field can be true or false (defaults to false). - ## If true, a message not matching the pattern will constitute a match of the multiline - ## filter and the what will be applied. (vice-versa is also true) - #invert_match = false - - ## After the specified timeout, this plugin sends a multiline event even if no new pattern - ## is found to start a new event. The default timeout is 5s. - #timeout = 5s -` - -func (t *Tail) SampleConfig() string { - return sampleConfig -} - -func (t *Tail) Description() string { - return "Parse the new lines appended to a file" -} - func (t *Tail) Init() error { if t.MaxUndeliveredLines == 0 { return errors.New("max_undelivered_lines must be positive") diff --git a/plugins/inputs/tail/tail_sample_config.go b/plugins/inputs/tail/tail_sample_config.go new file mode 100644 index 0000000000000..75f9dee0b7afa --- /dev/null +++ b/plugins/inputs/tail/tail_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package tail + +func (t *Tail) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/tcp_listener/README.md b/plugins/inputs/tcp_listener/README.md index aeb29e2b49d35..0b3bf8a914a8b 100644 --- a/plugins/inputs/tcp_listener/README.md +++ b/plugins/inputs/tcp_listener/README.md @@ -2,3 +2,12 @@ > DEPRECATED: As of version 1.3 the TCP listener plugin has been deprecated in favor of the > [socket_listener plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener) + +## Configuration + +```toml +# Generic TCP listener +[[inputs.tcp_listener]] + # socket_listener plugin + # see https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener +``` diff --git a/plugins/inputs/tcp_listener/tcp_listener.go b/plugins/inputs/tcp_listener/tcp_listener.go index 8eeaa9cff8091..e70cad17ecf5f 100644 --- a/plugins/inputs/tcp_listener/tcp_listener.go +++ b/plugins/inputs/tcp_listener/tcp_listener.go @@ -58,20 +58,6 @@ var dropwarn = "tcp_listener message queue full. " + var malformedwarn = "tcp_listener has received %d malformed packets" + " thus far." -const sampleConfig = ` - # DEPRECATED: the TCP listener plugin has been deprecated in favor of the - # socket_listener plugin - # see https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener -` - -func (t *TCPListener) SampleConfig() string { - return sampleConfig -} - -func (t *TCPListener) Description() string { - return "Generic TCP listener" -} - // All the work is done in the Start() function, so this is just a dummy // function. func (t *TCPListener) Gather(_ telegraf.Accumulator) error { diff --git a/plugins/inputs/tcp_listener/tcp_listener_sample_config.go b/plugins/inputs/tcp_listener/tcp_listener_sample_config.go new file mode 100644 index 0000000000000..ef0e6a4811ef9 --- /dev/null +++ b/plugins/inputs/tcp_listener/tcp_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package tcp_listener + +func (t *TCPListener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/teamspeak/teamspeak.go b/plugins/inputs/teamspeak/teamspeak.go index e6861f03e25af..deda4b04df9e2 100644 --- a/plugins/inputs/teamspeak/teamspeak.go +++ b/plugins/inputs/teamspeak/teamspeak.go @@ -3,9 +3,10 @@ package teamspeak import ( "github.com/multiplay/go-ts3" + "strconv" + "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" - "strconv" ) type Teamspeak struct { @@ -18,25 +19,6 @@ type Teamspeak struct { connected bool } -func (ts *Teamspeak) Description() string { - return "Reads metrics from a Teamspeak 3 Server via ServerQuery" -} - -const sampleConfig = ` - ## Server address for Teamspeak 3 ServerQuery - # server = "127.0.0.1:10011" - ## Username for ServerQuery - username = "serverqueryuser" - ## Password for ServerQuery - password = "secret" - ## Array of virtual servers - # virtual_servers = [1] -` - -func (ts *Teamspeak) SampleConfig() string { - return sampleConfig -} - func (ts *Teamspeak) Gather(acc telegraf.Accumulator) error { var err error diff --git a/plugins/inputs/teamspeak/teamspeak_sample_config.go b/plugins/inputs/teamspeak/teamspeak_sample_config.go new file mode 100644 index 0000000000000..5147f9e9d18f2 --- /dev/null +++ b/plugins/inputs/teamspeak/teamspeak_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package teamspeak + +func (ts *Teamspeak) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/temp/README.md b/plugins/inputs/temp/README.md index 5c55fa4b0d328..e0c01788d0004 100644 --- a/plugins/inputs/temp/README.md +++ b/plugins/inputs/temp/README.md @@ -8,6 +8,7 @@ Currently supports Linux and Windows. ## Configuration ```toml +# Read metrics about temperature [[inputs.temp]] # no configuration ``` diff --git a/plugins/inputs/temp/temp.go b/plugins/inputs/temp/temp.go index baf647b590e0c..f7c75982fb984 100644 --- a/plugins/inputs/temp/temp.go +++ b/plugins/inputs/temp/temp.go @@ -13,16 +13,6 @@ type Temperature struct { ps system.PS } -func (t *Temperature) Description() string { - return "Read metrics about temperature" -} - -const sampleConfig = "" - -func (t *Temperature) SampleConfig() string { - return sampleConfig -} - func (t *Temperature) Gather(acc telegraf.Accumulator) error { temps, err := t.ps.Temperature() if err != nil { diff --git a/plugins/inputs/temp/temp_sample_config.go b/plugins/inputs/temp/temp_sample_config.go new file mode 100644 index 0000000000000..fa8a0d8dad82c --- /dev/null +++ b/plugins/inputs/temp/temp_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package temp + +func (t *Temperature) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/tengine/tengine.go b/plugins/inputs/tengine/tengine.go index 1787354c22cff..4399569d6a692 100644 --- a/plugins/inputs/tengine/tengine.go +++ b/plugins/inputs/tengine/tengine.go @@ -27,29 +27,6 @@ type Tengine struct { client *http.Client } -var sampleConfig = ` - # An array of Tengine reqstat module URI to gather stats. - urls = ["http://127.0.0.1/us"] - - # HTTP response timeout (default: 5s) - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.cer" - # tls_key = "/etc/telegraf/key.key" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (n *Tengine) SampleConfig() string { - return sampleConfig -} - -func (n *Tengine) Description() string { - return "Read Tengine's basic status information (ngx_http_reqstat_module)" -} - func (n *Tengine) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/tengine/tengine_sample_config.go b/plugins/inputs/tengine/tengine_sample_config.go new file mode 100644 index 0000000000000..baa207d2da831 --- /dev/null +++ b/plugins/inputs/tengine/tengine_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package tengine + +func (n *Tengine) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/tomcat/tomcat.go b/plugins/inputs/tomcat/tomcat.go index 5b869fb4d8c76..a63391cada81e 100644 --- a/plugins/inputs/tomcat/tomcat.go +++ b/plugins/inputs/tomcat/tomcat.go @@ -70,33 +70,6 @@ type Tomcat struct { request *http.Request } -var sampleconfig = ` - ## URL of the Tomcat server status - # url = "http://127.0.0.1:8080/manager/status/all?XML=true" - - ## HTTP Basic Auth Credentials - # username = "tomcat" - # password = "s3cret" - - ## Request timeout - # timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (s *Tomcat) Description() string { - return "Gather metrics from the Tomcat server status page." -} - -func (s *Tomcat) SampleConfig() string { - return sampleconfig -} - func (s *Tomcat) Gather(acc telegraf.Accumulator) error { if s.client == nil { client, err := s.createHTTPClient() diff --git a/plugins/inputs/tomcat/tomcat_sample_config.go b/plugins/inputs/tomcat/tomcat_sample_config.go new file mode 100644 index 0000000000000..2d67bc9be8372 --- /dev/null +++ b/plugins/inputs/tomcat/tomcat_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package tomcat + +func (s *Tomcat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/trig/trig.go b/plugins/inputs/trig/trig.go index 647794f0a022d..40613607270c2 100644 --- a/plugins/inputs/trig/trig.go +++ b/plugins/inputs/trig/trig.go @@ -12,19 +12,6 @@ type Trig struct { Amplitude float64 } -var TrigConfig = ` - ## Set the amplitude - amplitude = 10.0 -` - -func (s *Trig) SampleConfig() string { - return TrigConfig -} - -func (s *Trig) Description() string { - return "Inserts sine and cosine waves for demonstration purposes" -} - func (s *Trig) Gather(acc telegraf.Accumulator) error { sinner := math.Sin((s.x*math.Pi)/5.0) * s.Amplitude cosinner := math.Cos((s.x*math.Pi)/5.0) * s.Amplitude diff --git a/plugins/inputs/trig/trig_sample_config.go b/plugins/inputs/trig/trig_sample_config.go new file mode 100644 index 0000000000000..0c089b92251cc --- /dev/null +++ b/plugins/inputs/trig/trig_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package trig + +func (s *Trig) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/twemproxy/twemproxy.go b/plugins/inputs/twemproxy/twemproxy.go index c629c37ff809b..60c7ed9022934 100644 --- a/plugins/inputs/twemproxy/twemproxy.go +++ b/plugins/inputs/twemproxy/twemproxy.go @@ -16,21 +16,6 @@ type Twemproxy struct { Pools []string } -var sampleConfig = ` - ## Twemproxy stats address and port (no scheme) - addr = "localhost:22222" - ## Monitor pool name - pools = ["redis_pool", "mc_pool"] -` - -func (t *Twemproxy) SampleConfig() string { - return sampleConfig -} - -func (t *Twemproxy) Description() string { - return "Read Twemproxy stats data" -} - // Gather data from all Twemproxy instances func (t *Twemproxy) Gather(acc telegraf.Accumulator) error { conn, err := net.DialTimeout("tcp", t.Addr, 1*time.Second) diff --git a/plugins/inputs/twemproxy/twemproxy_sample_config.go b/plugins/inputs/twemproxy/twemproxy_sample_config.go new file mode 100644 index 0000000000000..ab2539415be9c --- /dev/null +++ b/plugins/inputs/twemproxy/twemproxy_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package twemproxy + +func (t *Twemproxy) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/udp_listener/README.md b/plugins/inputs/udp_listener/README.md index 921e8dbf1eac3..36892d4a5340f 100644 --- a/plugins/inputs/udp_listener/README.md +++ b/plugins/inputs/udp_listener/README.md @@ -2,3 +2,11 @@ > DEPRECATED: As of version 1.3 the UDP listener plugin has been deprecated in favor of the > [socket_listener plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener) + +## Configuration + +```toml +# Generic UDP listener +[[inputs.udp_listener]] + # see https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener +``` diff --git a/plugins/inputs/udp_listener/udp_listener.go b/plugins/inputs/udp_listener/udp_listener.go index 39fef79ce1b98..5fe91e9602226 100644 --- a/plugins/inputs/udp_listener/udp_listener.go +++ b/plugins/inputs/udp_listener/udp_listener.go @@ -67,20 +67,6 @@ var dropwarn = "udp_listener message queue full. " + var malformedwarn = "udp_listener has received %d malformed packets" + " thus far." -const sampleConfig = ` - # DEPRECATED: the TCP listener plugin has been deprecated in favor of the - # socket_listener plugin - # see https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener -` - -func (u *UDPListener) SampleConfig() string { - return sampleConfig -} - -func (u *UDPListener) Description() string { - return "Generic UDP listener" -} - // All the work is done in the Start() function, so this is just a dummy // function. func (u *UDPListener) Gather(_ telegraf.Accumulator) error { diff --git a/plugins/inputs/udp_listener/udp_listener_sample_config.go b/plugins/inputs/udp_listener/udp_listener_sample_config.go new file mode 100644 index 0000000000000..607be1209fc55 --- /dev/null +++ b/plugins/inputs/udp_listener/udp_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package udp_listener + +func (u *UDPListener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/unbound/unbound.go b/plugins/inputs/unbound/unbound.go index 72a9e4db5965d..d5592e45878de 100644 --- a/plugins/inputs/unbound/unbound.go +++ b/plugins/inputs/unbound/unbound.go @@ -35,41 +35,6 @@ type Unbound struct { var defaultBinary = "/usr/sbin/unbound-control" var defaultTimeout = config.Duration(time.Second) -var sampleConfig = ` - ## Address of server to connect to, read from unbound conf default, optionally ':port' - ## Will lookup IP if given a hostname - server = "127.0.0.1:8953" - - ## If running as a restricted user you can prepend sudo for additional access: - # use_sudo = false - - ## The default location of the unbound-control binary can be overridden with: - # binary = "/usr/sbin/unbound-control" - - ## The default location of the unbound config file can be overridden with: - # config_file = "/etc/unbound/unbound.conf" - - ## The default timeout of 1s can be overridden with: - # timeout = "1s" - - ## When set to true, thread metrics are tagged with the thread id. - ## - ## The default is false for backwards compatibility, and will be changed to - ## true in a future version. It is recommended to set to true on new - ## deployments. - thread_as_tag = false -` - -// Description displays what this plugin is about -func (s *Unbound) Description() string { - return "A plugin to collect stats from the Unbound DNS resolver" -} - -// SampleConfig displays configuration instructions -func (s *Unbound) SampleConfig() string { - return sampleConfig -} - // Shell out to unbound_stat and return the output func unboundRunner(unbound Unbound) (*bytes.Buffer, error) { cmdArgs := []string{"stats_noreset"} diff --git a/plugins/inputs/unbound/unbound_sample_config.go b/plugins/inputs/unbound/unbound_sample_config.go new file mode 100644 index 0000000000000..64032afb9b6d4 --- /dev/null +++ b/plugins/inputs/unbound/unbound_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package unbound + +func (s *Unbound) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/uwsgi/README.md b/plugins/inputs/uwsgi/README.md index 2c99b04be6d13..4f385cedbe69b 100644 --- a/plugins/inputs/uwsgi/README.md +++ b/plugins/inputs/uwsgi/README.md @@ -5,6 +5,7 @@ The uWSGI input plugin gathers metrics about uWSGI using its [Stats Server](http ## Configuration ```toml +# Read uWSGI metrics. [[inputs.uwsgi]] ## List with urls of uWSGI Stats servers. Url must match pattern: ## scheme://address[:port] diff --git a/plugins/inputs/uwsgi/uwsgi.go b/plugins/inputs/uwsgi/uwsgi.go index 9e260a5fe6974..cdf3f326b7291 100644 --- a/plugins/inputs/uwsgi/uwsgi.go +++ b/plugins/inputs/uwsgi/uwsgi.go @@ -27,26 +27,6 @@ type Uwsgi struct { client *http.Client } -// Description returns the plugin description -func (u *Uwsgi) Description() string { - return "Read uWSGI metrics." -} - -// SampleConfig returns the sample configuration -func (u *Uwsgi) SampleConfig() string { - return ` - ## List with urls of uWSGI Stats servers. URL must match pattern: - ## scheme://address[:port] - ## - ## For example: - ## servers = ["tcp://localhost:5050", "http://localhost:1717", "unix:///tmp/statsock"] - servers = ["tcp://127.0.0.1:1717"] - - ## General connection timeout - # timeout = "5s" -` -} - // Gather collect data from uWSGI Server func (u *Uwsgi) Gather(acc telegraf.Accumulator) error { if u.client == nil { diff --git a/plugins/inputs/uwsgi/uwsgi_sample_config.go b/plugins/inputs/uwsgi/uwsgi_sample_config.go new file mode 100644 index 0000000000000..923bbbe1b90ec --- /dev/null +++ b/plugins/inputs/uwsgi/uwsgi_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package uwsgi + +func (u *Uwsgi) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/varnish/README.md b/plugins/inputs/varnish/README.md index 4d42a168da16f..dd684a2511460 100644 --- a/plugins/inputs/varnish/README.md +++ b/plugins/inputs/varnish/README.md @@ -5,43 +5,44 @@ This plugin gathers stats from [Varnish HTTP Cache](https://varnish-cache.org/) ## Configuration ```toml +# A plugin to collect stats from Varnish HTTP Cache [[inputs.varnish]] -## If running as a restricted user you can prepend sudo for additional access: -#use_sudo = false + ## If running as a restricted user you can prepend sudo for additional access: + #use_sudo = false -## The default location of the varnishstat binary can be overridden with: -binary = "/usr/bin/varnishstat" + ## The default location of the varnishstat binary can be overridden with: + binary = "/usr/bin/varnishstat" -## Additional custom arguments for the varnishstat command -# binary_args = ["-f", "MAIN.*"] + ## Additional custom arguments for the varnishstat command + # binary_args = ["-f", "MAIN.*"] -## The default location of the varnishadm binary can be overridden with: -adm_binary = "/usr/bin/varnishadm" + ## The default location of the varnishadm binary can be overridden with: + adm_binary = "/usr/bin/varnishadm" -## Custom arguments for the varnishadm command -# adm_binary_args = [""] + ## Custom arguments for the varnishadm command + # adm_binary_args = [""] -## Metric version defaults to metric_version=1, use metric_version=2 for removal of nonactive vcls -## Varnish 6.0.2 and newer is required for metric_version=2. -metric_version = 1 + ## Metric version defaults to metric_version=1, use metric_version=2 for removal of nonactive vcls + ## Varnish 6.0.2 and newer is required for metric_version=2. + metric_version = 1 -## Additional regexps to override builtin conversion of varnish metrics into telegraf metrics. -## Regexp group "_vcl" is used for extracting the VCL name. Metrics that contain nonactive VCL's are skipped. -## Regexp group "_field" overrides the field name. Other named regexp groups are used as tags. -# regexps = ['^XCNT\.(?P<_vcl>[\w\-]*)(\.)*(?P[\w\-.+]*)\.(?P<_field>[\w\-.+]*)\.val'] + ## Additional regexps to override builtin conversion of varnish metrics into telegraf metrics. + ## Regexp group "_vcl" is used for extracting the VCL name. Metrics that contain nonactive VCL's are skipped. + ## Regexp group "_field" overrides the field name. Other named regexp groups are used as tags. + # regexps = ['^XCNT\.(?P<_vcl>[\w\-]*)(\.)*(?P[\w\-.+]*)\.(?P<_field>[\w\-.+]*)\.val'] -## By default, telegraf gather stats for 3 metric points. -## Setting stats will override the defaults shown below. -## Glob matching can be used, ie, stats = ["MAIN.*"] -## stats may also be set to ["*"], which will collect all stats -stats = ["MAIN.cache_hit", "MAIN.cache_miss", "MAIN.uptime"] + ## By default, telegraf gather stats for 3 metric points. + ## Setting stats will override the defaults shown below. + ## Glob matching can be used, ie, stats = ["MAIN.*"] + ## stats may also be set to ["*"], which will collect all stats + stats = ["MAIN.cache_hit", "MAIN.cache_miss", "MAIN.uptime"] -## Optional name for the varnish instance (or working directory) to query -## Usually append after -n in varnish cli -# instance_name = instanceName + ## Optional name for the varnish instance (or working directory) to query + ## Usually append after -n in varnish cli + # instance_name = instanceName -## Timeout for varnishstat command -# timeout = "1s" + ## Timeout for varnishstat command + # timeout = "1s" ``` ### Measurements & Fields (metric_version=1) @@ -367,7 +368,7 @@ are excluded from monitoring. ### Requirements - Varnish 6.0.2+ is required (older versions do not support JSON output from CLI tools) - + #### Examples Varnish counter: diff --git a/plugins/inputs/varnish/varnish.go b/plugins/inputs/varnish/varnish.go index 9c6dee6ee1548..db5a72ba89a1d 100644 --- a/plugins/inputs/varnish/varnish.go +++ b/plugins/inputs/varnish/varnish.go @@ -70,53 +70,6 @@ type Varnish struct { regexpsCompiled []*regexp.Regexp } -var sampleConfig = ` - ## If running as a restricted user you can prepend sudo for additional access: - #use_sudo = false - - ## The default location of the varnishstat binary can be overridden with: - binary = "/usr/bin/varnishstat" - - ## Additional custom arguments for the varnishstat command - # binary_args = ["-f", "MAIN.*"] - - ## The default location of the varnishadm binary can be overriden with: - adm_binary = "/usr/bin/varnishadm" - - ## Custom arguments for the varnishadm command - # adm_binary_args = [""] - - ## Metric version defaults to metric_version=1, use metric_version=2 for removal of nonactive vcls. - metric_version = 1 - - ## Additional regexps to override builtin conversion of varnish metrics into telegraf metrics. - ## Regexp group "_vcl" is used for extracting the VCL name. Metrics that contains nonactive VCL's are skipped. - ## Regexp group "_field" overrides field name. Other named regexp groups are used as tags. - # regexps = ['XCNT\.(?P<_vcl>[\w\-]*)\.(?P[\w\-.+]*)\.(?P<_field>[\w\-.+]*)\.val'] - - ## By default, telegraf gather stats for 3 metric points. - ## Setting stats will override the defaults shown below. - ## Glob matching can be used, ie, stats = ["MAIN.*"] - ## stats may also be set to ["*"], which will collect all stats - stats = ["MAIN.cache_hit", "MAIN.cache_miss", "MAIN.uptime"] - - ## Optional name for the varnish instance (or working directory) to query - ## Usually append after -n in varnish cli - # instance_name = instanceName - - ## Timeout for varnishstat command - # timeout = "1s" -` - -func (s *Varnish) Description() string { - return "A plugin to collect stats from Varnish HTTP Cache" -} - -// SampleConfig displays configuration instructions -func (s *Varnish) SampleConfig() string { - return sampleConfig -} - // Shell out to varnish cli and return the output func varnishRunner(cmdName string, useSudo bool, cmdArgs []string, timeout config.Duration) (*bytes.Buffer, error) { cmd := exec.Command(cmdName, cmdArgs...) diff --git a/plugins/inputs/varnish/varnish_sample_config.go b/plugins/inputs/varnish/varnish_sample_config.go new file mode 100644 index 0000000000000..664f613f83cf1 --- /dev/null +++ b/plugins/inputs/varnish/varnish_sample_config.go @@ -0,0 +1,11 @@ +//go:build !windows +// +build !windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package varnish + +func (s *Varnish) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/varnish/varnish_test.go b/plugins/inputs/varnish/varnish_test.go index 7b119c8e37de0..058e68ce50dd4 100644 --- a/plugins/inputs/varnish/varnish_test.go +++ b/plugins/inputs/varnish/varnish_test.go @@ -531,7 +531,6 @@ func TestV2ParseVarnishNames(t *testing.T) { func TestVersions(t *testing.T) { server := &Varnish{regexpsCompiled: defaultRegexps} require.NoError(t, server.Init()) - require.Equal(t, "A plugin to collect stats from Varnish HTTP Cache", server.Description()) acc := &testutil.Accumulator{} require.Equal(t, 0, len(acc.Metrics)) diff --git a/plugins/inputs/vault/README.md b/plugins/inputs/vault/README.md index 0261efe6c1c34..03e6b2d41a61f 100644 --- a/plugins/inputs/vault/README.md +++ b/plugins/inputs/vault/README.md @@ -7,8 +7,9 @@ The Vault plugin could grab metrics from every Vault agent of the cluster. Teleg ## Configuration ```toml +# Read metrics from the Vault API [[inputs.vault]] - ## URL for the vault agent + ## URL for the Vault agent # url = "http://127.0.0.1:8200" ## Use Vault token for authorization. diff --git a/plugins/inputs/vault/vault.go b/plugins/inputs/vault/vault.go index 04524c78ab28d..0bd4748a3f111 100644 --- a/plugins/inputs/vault/vault.go +++ b/plugins/inputs/vault/vault.go @@ -31,26 +31,6 @@ type Vault struct { const timeLayout = "2006-01-02 15:04:05 -0700 MST" -const sampleConfig = ` - ## URL for the Vault agent - # url = "http://127.0.0.1:8200" - - ## Use Vault token for authorization. - ## Vault token configuration is mandatory. - ## If both are empty or both are set, an error is thrown. - # token_file = "/path/to/auth/token" - ## OR - token = "s.CDDrgg5zPv5ssI0Z2P4qxJj2" - - ## Set response_timeout (default 5 seconds) - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = /path/to/cafile - # tls_cert = /path/to/certfile - # tls_key = /path/to/keyfile -` - func init() { inputs.Add("vault", func() telegraf.Input { return &Vault{ @@ -59,16 +39,6 @@ func init() { }) } -// SampleConfig returns a sample config -func (n *Vault) SampleConfig() string { - return sampleConfig -} - -// Description returns a description of the plugin -func (n *Vault) Description() string { - return "Read metrics from the Vault API" -} - func (n *Vault) Init() error { if n.URL == "" { n.URL = "http://127.0.0.1:8200" diff --git a/plugins/inputs/vault/vault_sample_config.go b/plugins/inputs/vault/vault_sample_config.go new file mode 100644 index 0000000000000..0b1000bc1c916 --- /dev/null +++ b/plugins/inputs/vault/vault_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package vault + +func (n *Vault) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/vsphere/vsphere.go b/plugins/inputs/vsphere/vsphere.go index 9b71d86736508..6dfa6ab1e5162 100644 --- a/plugins/inputs/vsphere/vsphere.go +++ b/plugins/inputs/vsphere/vsphere.go @@ -68,206 +68,6 @@ type VSphere struct { Log telegraf.Logger } -var sampleConfig = ` - ## List of vCenter URLs to be monitored. These three lines must be uncommented - ## and edited for the plugin to work. - vcenters = [ "https://vcenter.local/sdk" ] - username = "user@corp.local" - password = "secret" - - ## VMs - ## Typical VM metrics (if omitted or empty, all metrics are collected) - # vm_include = [ "/*/vm/**"] # Inventory path to VMs to collect (by default all are collected) - # vm_exclude = [] # Inventory paths to exclude - vm_metric_include = [ - "cpu.demand.average", - "cpu.idle.summation", - "cpu.latency.average", - "cpu.readiness.average", - "cpu.ready.summation", - "cpu.run.summation", - "cpu.usagemhz.average", - "cpu.used.summation", - "cpu.wait.summation", - "mem.active.average", - "mem.granted.average", - "mem.latency.average", - "mem.swapin.average", - "mem.swapinRate.average", - "mem.swapout.average", - "mem.swapoutRate.average", - "mem.usage.average", - "mem.vmmemctl.average", - "net.bytesRx.average", - "net.bytesTx.average", - "net.droppedRx.summation", - "net.droppedTx.summation", - "net.usage.average", - "power.power.average", - "virtualDisk.numberReadAveraged.average", - "virtualDisk.numberWriteAveraged.average", - "virtualDisk.read.average", - "virtualDisk.readOIO.latest", - "virtualDisk.throughput.usage.average", - "virtualDisk.totalReadLatency.average", - "virtualDisk.totalWriteLatency.average", - "virtualDisk.write.average", - "virtualDisk.writeOIO.latest", - "sys.uptime.latest", - ] - # vm_metric_exclude = [] ## Nothing is excluded by default - # vm_instances = true ## true by default - - ## Hosts - ## Typical host metrics (if omitted or empty, all metrics are collected) - # host_include = [ "/*/host/**"] # Inventory path to hosts to collect (by default all are collected) - # host_exclude [] # Inventory paths to exclude - host_metric_include = [ - "cpu.coreUtilization.average", - "cpu.costop.summation", - "cpu.demand.average", - "cpu.idle.summation", - "cpu.latency.average", - "cpu.readiness.average", - "cpu.ready.summation", - "cpu.swapwait.summation", - "cpu.usage.average", - "cpu.usagemhz.average", - "cpu.used.summation", - "cpu.utilization.average", - "cpu.wait.summation", - "disk.deviceReadLatency.average", - "disk.deviceWriteLatency.average", - "disk.kernelReadLatency.average", - "disk.kernelWriteLatency.average", - "disk.numberReadAveraged.average", - "disk.numberWriteAveraged.average", - "disk.read.average", - "disk.totalReadLatency.average", - "disk.totalWriteLatency.average", - "disk.write.average", - "mem.active.average", - "mem.latency.average", - "mem.state.latest", - "mem.swapin.average", - "mem.swapinRate.average", - "mem.swapout.average", - "mem.swapoutRate.average", - "mem.totalCapacity.average", - "mem.usage.average", - "mem.vmmemctl.average", - "net.bytesRx.average", - "net.bytesTx.average", - "net.droppedRx.summation", - "net.droppedTx.summation", - "net.errorsRx.summation", - "net.errorsTx.summation", - "net.usage.average", - "power.power.average", - "storageAdapter.numberReadAveraged.average", - "storageAdapter.numberWriteAveraged.average", - "storageAdapter.read.average", - "storageAdapter.write.average", - "sys.uptime.latest", - ] - ## Collect IP addresses? Valid values are "ipv4" and "ipv6" - # ip_addresses = ["ipv6", "ipv4" ] - - # host_metric_exclude = [] ## Nothing excluded by default - # host_instances = true ## true by default - - - ## Clusters - # cluster_include = [ "/*/host/**"] # Inventory path to clusters to collect (by default all are collected) - # cluster_exclude = [] # Inventory paths to exclude - # cluster_metric_include = [] ## if omitted or empty, all metrics are collected - # cluster_metric_exclude = [] ## Nothing excluded by default - # cluster_instances = false ## false by default - - ## Datastores - # datastore_include = [ "/*/datastore/**"] # Inventory path to datastores to collect (by default all are collected) - # datastore_exclude = [] # Inventory paths to exclude - # datastore_metric_include = [] ## if omitted or empty, all metrics are collected - # datastore_metric_exclude = [] ## Nothing excluded by default - # datastore_instances = false ## false by default - - ## Datacenters - # datacenter_include = [ "/*/host/**"] # Inventory path to clusters to collect (by default all are collected) - # datacenter_exclude = [] # Inventory paths to exclude - datacenter_metric_include = [] ## if omitted or empty, all metrics are collected - datacenter_metric_exclude = [ "*" ] ## Datacenters are not collected by default. - # datacenter_instances = false ## false by default - - ## Plugin Settings - ## separator character to use for measurement and field names (default: "_") - # separator = "_" - - ## number of objects to retrieve per query for realtime resources (vms and hosts) - ## set to 64 for vCenter 5.5 and 6.0 (default: 256) - # max_query_objects = 256 - - ## number of metrics to retrieve per query for non-realtime resources (clusters and datastores) - ## set to 64 for vCenter 5.5 and 6.0 (default: 256) - # max_query_metrics = 256 - - ## number of go routines to use for collection and discovery of objects and metrics - # collect_concurrency = 1 - # discover_concurrency = 1 - - ## the interval before (re)discovering objects subject to metrics collection (default: 300s) - # object_discovery_interval = "300s" - - ## timeout applies to any of the api request made to vcenter - # timeout = "60s" - - ## When set to true, all samples are sent as integers. This makes the output - ## data types backwards compatible with Telegraf 1.9 or lower. Normally all - ## samples from vCenter, with the exception of percentages, are integer - ## values, but under some conditions, some averaging takes place internally in - ## the plugin. Setting this flag to "false" will send values as floats to - ## preserve the full precision when averaging takes place. - # use_int_samples = true - - ## Custom attributes from vCenter can be very useful for queries in order to slice the - ## metrics along different dimension and for forming ad-hoc relationships. They are disabled - ## by default, since they can add a considerable amount of tags to the resulting metrics. To - ## enable, simply set custom_attribute_exclude to [] (empty set) and use custom_attribute_include - ## to select the attributes you want to include. - ## By default, since they can add a considerable amount of tags to the resulting metrics. To - ## enable, simply set custom_attribute_exclude to [] (empty set) and use custom_attribute_include - ## to select the attributes you want to include. - # custom_attribute_include = [] - # custom_attribute_exclude = ["*"] - - ## The number of vSphere 5 minute metric collection cycles to look back for non-realtime metrics. In - ## some versions (6.7, 7.0 and possible more), certain metrics, such as cluster metrics, may be reported - ## with a significant delay (>30min). If this happens, try increasing this number. Please note that increasing - ## it too much may cause performance issues. - # metric_lookback = 3 - - ## Optional SSL Config - # ssl_ca = "/path/to/cafile" - # ssl_cert = "/path/to/certfile" - # ssl_key = "/path/to/keyfile" - ## Use SSL but skip chain & host verification - # insecure_skip_verify = false - - ## The Historical Interval value must match EXACTLY the interval in the daily - # "Interval Duration" found on the VCenter server under Configure > General > Statistics > Statistic intervals - # historical_interval = "5m" -` - -// SampleConfig returns a set of default configuration to be used as a boilerplate when setting up -// Telegraf. -func (v *VSphere) SampleConfig() string { - return sampleConfig -} - -// Description returns a short textual description of the plugin -func (v *VSphere) Description() string { - return "Read metrics from VMware vCenter" -} - // Start is called from telegraf core when a plugin is started and allows it to // perform initialization tasks. func (v *VSphere) Start(_ telegraf.Accumulator) error { diff --git a/plugins/inputs/vsphere/vsphere_sample_config.go b/plugins/inputs/vsphere/vsphere_sample_config.go new file mode 100644 index 0000000000000..211d52dd1a675 --- /dev/null +++ b/plugins/inputs/vsphere/vsphere_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package vsphere + +func (v *VSphere) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/webhooks/webhooks.go b/plugins/inputs/webhooks/webhooks.go index f468d35eb937a..5f74964361f3c 100644 --- a/plugins/inputs/webhooks/webhooks.go +++ b/plugins/inputs/webhooks/webhooks.go @@ -45,60 +45,6 @@ func NewWebhooks() *Webhooks { return &Webhooks{} } -func (wb *Webhooks) SampleConfig() string { - return ` - ## Address and port to host Webhook listener on - service_address = ":1619" - - [inputs.webhooks.filestack] - path = "/filestack" - - ## HTTP basic auth - #username = "" - #password = "" - - [inputs.webhooks.github] - path = "/github" - # secret = "" - - ## HTTP basic auth - #username = "" - #password = "" - - [inputs.webhooks.mandrill] - path = "/mandrill" - - ## HTTP basic auth - #username = "" - #password = "" - - [inputs.webhooks.rollbar] - path = "/rollbar" - - ## HTTP basic auth - #username = "" - #password = "" - - [inputs.webhooks.papertrail] - path = "/papertrail" - - ## HTTP basic auth - #username = "" - #password = "" - - [inputs.webhooks.particle] - path = "/particle" - - ## HTTP basic auth - #username = "" - #password = "" -` -} - -func (wb *Webhooks) Description() string { - return "A Webhooks Event collector" -} - func (wb *Webhooks) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/webhooks/webhooks_sample_config.go b/plugins/inputs/webhooks/webhooks_sample_config.go new file mode 100644 index 0000000000000..882ce3944e1ce --- /dev/null +++ b/plugins/inputs/webhooks/webhooks_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package webhooks + +func (wb *Webhooks) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/win_eventlog/win_eventlog.go b/plugins/inputs/win_eventlog/win_eventlog.go index 2ee303d483530..552f727f7598d 100644 --- a/plugins/inputs/win_eventlog/win_eventlog.go +++ b/plugins/inputs/win_eventlog/win_eventlog.go @@ -21,84 +21,6 @@ import ( "golang.org/x/sys/windows" ) -var sampleConfig = ` - ## Telegraf should have Administrator permissions to subscribe for some Windows Events channels - ## (System log, for example) - - ## LCID (Locale ID) for event rendering - ## 1033 to force English language - ## 0 to use default Windows locale - # locale = 0 - - ## Name of eventlog, used only if xpath_query is empty - ## Example: "Application" - # eventlog_name = "" - - ## xpath_query can be in defined short form like "Event/System[EventID=999]" - ## or you can form a XML Query. Refer to the Consuming Events article: - ## https://docs.microsoft.com/en-us/windows/win32/wes/consuming-events - ## XML query is the recommended form, because it is most flexible - ## You can create or debug XML Query by creating Custom View in Windows Event Viewer - ## and then copying resulting XML here - xpath_query = ''' - - - - *[System[( (EventID >= 5152 and EventID <= 5158) or EventID=5379 or EventID=4672)]] - - - - - - - - - - - - - - - ''' - - ## System field names: - ## "Source", "EventID", "Version", "Level", "Task", "Opcode", "Keywords", "TimeCreated", - ## "EventRecordID", "ActivityID", "RelatedActivityID", "ProcessID", "ThreadID", "ProcessName", - ## "Channel", "Computer", "UserID", "UserName", "Message", "LevelText", "TaskText", "OpcodeText" - - ## In addition to System, Data fields can be unrolled from additional XML nodes in event. - ## Human-readable representation of those nodes is formatted into event Message field, - ## but XML is more machine-parsable - - # Process UserData XML to fields, if this node exists in Event XML - process_userdata = true - - # Process EventData XML to fields, if this node exists in Event XML - process_eventdata = true - - ## Separator character to use for unrolled XML Data field names - separator = "_" - - ## Get only first line of Message field. For most events first line is usually more than enough - only_first_line_of_message = true - - ## Parse timestamp from TimeCreated.SystemTime event field. - ## Will default to current time of telegraf processing on parsing error or if set to false - timestamp_from_event = true - - ## Fields to include as tags. Globbing supported ("Level*" for both "Level" and "LevelText") - event_tags = ["Source", "EventID", "Level", "LevelText", "Task", "TaskText", "Opcode", "OpcodeText", "Keywords", "Channel", "Computer"] - - ## Default list of fields to send. All fields are sent by default. Globbing supported - event_fields = ["*"] - - ## Fields to exclude. Also applied to data fields. Globbing supported - exclude_fields = ["TimeCreated", "Binary", "Data_Address*"] - - ## Skip those tags or fields if their value is empty or equals to zero. Globbing supported - exclude_empty = ["*ActivityID", "UserID"] -` - // WinEventLog config type WinEventLog struct { Locale uint32 `toml:"locale"` @@ -122,16 +44,6 @@ var bufferSize = 1 << 14 var description = "Input plugin to collect Windows Event Log messages" -// Description for win_eventlog -func (w *WinEventLog) Description() string { - return description -} - -// SampleConfig for win_eventlog -func (w *WinEventLog) SampleConfig() string { - return sampleConfig -} - // Gather Windows Event Log entries func (w *WinEventLog) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/win_eventlog/win_eventlog_sample_config.go b/plugins/inputs/win_eventlog/win_eventlog_sample_config.go new file mode 100644 index 0000000000000..d2e93d0e05735 --- /dev/null +++ b/plugins/inputs/win_eventlog/win_eventlog_sample_config.go @@ -0,0 +1,11 @@ +//go:build windows +// +build windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package win_eventlog + +func (w *WinEventLog) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/win_perf_counters/README.md b/plugins/inputs/win_perf_counters/README.md index 36ad348a4edf3..7c300309141c9 100644 --- a/plugins/inputs/win_perf_counters/README.md +++ b/plugins/inputs/win_perf_counters/README.md @@ -223,7 +223,146 @@ It is a simple bool. If it is not set to true or included this is treated as fal If this is set to true, the plugin will abort and end prematurely if any of the combinations of ObjectName/Instances/Counters are invalid. -## Examples +## Configuration + +```toml +# # Input plugin to counterPath Performance Counters on Windows operating systems +# [[inputs.win_perf_counters]] +# ## By default this plugin returns basic CPU and Disk statistics. +# ## See the README file for more examples. +# ## Uncomment examples below or write your own as you see fit. If the system +# ## being polled for data does not have the Object at startup of the Telegraf +# ## agent, it will not be gathered. +# ## Settings: +# # PrintValid = false # Print All matching performance counters +# # Whether request a timestamp along with the PerfCounter data or just use current time +# # UsePerfCounterTime=true +# # If UseWildcardsExpansion params is set to true, wildcards (partial wildcards in instance names and wildcards in counters names) in configured counter paths will be expanded +# # and in case of localized Windows, counter paths will be also localized. It also returns instance indexes in instance names. +# # If false, wildcards (not partial) in instance names will still be expanded, but instance indexes will not be returned in instance names. +# #UseWildcardsExpansion = false +# # When running on a localized version of Windows and with UseWildcardsExpansion = true, Windows will +# # localize object and counter names. When LocalizeWildcardsExpansion = false, use the names in object.Counters instead +# # of the localized names. Only Instances can have wildcards in this case. ObjectName and Counters must not have wildcards when this +# # setting is false. +# #LocalizeWildcardsExpansion = true +# # Period after which counters will be reread from configuration and wildcards in counter paths expanded +# CountersRefreshInterval="1m" +# ## Accepts a list of PDH error codes which are defined in pdh.go, if this error is encountered it will be ignored +# ## For example, you can provide "PDH_NO_DATA" to ignore performance counters with no instances +# ## By default no errors are ignored +# ## You can find the list here: https://github.com/influxdata/telegraf/blob/master/plugins/inputs/win_perf_counters/pdh.go +# ## e.g.: IgnoredErrors = ["PDH_NO_DATA"] +# # IgnoredErrors = [] +# +# [[inputs.win_perf_counters.object]] +# # Processor usage, alternative to native, reports on a per core. +# ObjectName = "Processor" +# Instances = ["*"] +# Counters = [ +# "% Idle Time", +# "% Interrupt Time", +# "% Privileged Time", +# "% User Time", +# "% Processor Time", +# "% DPC Time", +# ] +# Measurement = "win_cpu" +# # Set to true to include _Total instance when querying for all (*). +# # IncludeTotal=false +# # Print out when the performance counter is missing from object, counter or instance. +# # WarnOnMissing = false +# # Gather raw values instead of formatted. Raw value is stored in the field name with the "_Raw" suffix, e.g. "Disk_Read_Bytes_sec_Raw". +# # UseRawValues = true +# +# [[inputs.win_perf_counters.object]] +# # Disk times and queues +# ObjectName = "LogicalDisk" +# Instances = ["*"] +# Counters = [ +# "% Idle Time", +# "% Disk Time", +# "% Disk Read Time", +# "% Disk Write Time", +# "% User Time", +# "% Free Space", +# "Current Disk Queue Length", +# "Free Megabytes", +# ] +# Measurement = "win_disk" +# +# [[inputs.win_perf_counters.object]] +# ObjectName = "PhysicalDisk" +# Instances = ["*"] +# Counters = [ +# "Disk Read Bytes/sec", +# "Disk Write Bytes/sec", +# "Current Disk Queue Length", +# "Disk Reads/sec", +# "Disk Writes/sec", +# "% Disk Time", +# "% Disk Read Time", +# "% Disk Write Time", +# ] +# Measurement = "win_diskio" +# +# [[inputs.win_perf_counters.object]] +# ObjectName = "Network Interface" +# Instances = ["*"] +# Counters = [ +# "Bytes Received/sec", +# "Bytes Sent/sec", +# "Packets Received/sec", +# "Packets Sent/sec", +# "Packets Received Discarded", +# "Packets Outbound Discarded", +# "Packets Received Errors", +# "Packets Outbound Errors", +# ] +# Measurement = "win_net" +# +# +# [[inputs.win_perf_counters.object]] +# ObjectName = "System" +# Counters = [ +# "Context Switches/sec", +# "System Calls/sec", +# "Processor Queue Length", +# "System Up Time", +# ] +# Instances = ["------"] +# Measurement = "win_system" +# +# [[inputs.win_perf_counters.object]] +# # Example counterPath where the Instance portion must be removed to get data back, +# # such as from the Memory object. +# ObjectName = "Memory" +# Counters = [ +# "Available Bytes", +# "Cache Faults/sec", +# "Demand Zero Faults/sec", +# "Page Faults/sec", +# "Pages/sec", +# "Transition Faults/sec", +# "Pool Nonpaged Bytes", +# "Pool Paged Bytes", +# "Standby Cache Reserve Bytes", +# "Standby Cache Normal Priority Bytes", +# "Standby Cache Core Bytes", +# ] +# Instances = ["------"] # Use 6 x - to remove the Instance bit from the counterPath. +# Measurement = "win_mem" +# +# [[inputs.win_perf_counters.object]] +# # Example query where the Instance portion must be removed to get data back, +# # such as from the Paging File object. +# ObjectName = "Paging File" +# Counters = [ +# "% Usage", +# ] +# Instances = ["_Total"] +# Measurement = "win_swap" +``` ### Generic Queries diff --git a/plugins/inputs/win_perf_counters/win_perf_counters.go b/plugins/inputs/win_perf_counters/win_perf_counters.go index 05031671d834f..763ccc1ba959e 100644 --- a/plugins/inputs/win_perf_counters/win_perf_counters.go +++ b/plugins/inputs/win_perf_counters/win_perf_counters.go @@ -14,143 +14,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -var sampleConfig = ` - ## By default this plugin returns basic CPU and Disk statistics. - ## See the README file for more examples. - ## Uncomment examples below or write your own as you see fit. If the system - ## being polled for data does not have the Object at startup of the Telegraf - ## agent, it will not be gathered. - ## Settings: - # PrintValid = false # Print All matching performance counters - # Whether request a timestamp along with the PerfCounter data or just use current time - # UsePerfCounterTime=true - # If UseWildcardsExpansion params is set to true, wildcards (partial wildcards in instance names and wildcards in counters names) in configured counter paths will be expanded - # and in case of localized Windows, counter paths will be also localized. It also returns instance indexes in instance names. - # If false, wildcards (not partial) in instance names will still be expanded, but instance indexes will not be returned in instance names. - #UseWildcardsExpansion = false - # When running on a localized version of Windows and with UseWildcardsExpansion = true, Windows will - # localize object and counter names. When LocalizeWildcardsExpansion = false, use the names in object.Counters instead - # of the localized names. Only Instances can have wildcards in this case. ObjectName and Counters must not have wildcards when this - # setting is false. - #LocalizeWildcardsExpansion = true - # Period after which counters will be reread from configuration and wildcards in counter paths expanded - CountersRefreshInterval="1m" - ## Accepts a list of PDH error codes which are defined in pdh.go, if this error is encountered it will be ignored - ## For example, you can provide "PDH_NO_DATA" to ignore performance counters with no instances - ## By default no errors are ignored - ## You can find the list here: https://github.com/influxdata/telegraf/blob/master/plugins/inputs/win_perf_counters/pdh.go - ## e.g.: IgnoredErrors = ["PDH_NO_DATA"] - # IgnoredErrors = [] - - [[inputs.win_perf_counters.object]] - # Processor usage, alternative to native, reports on a per core. - ObjectName = "Processor" - Instances = ["*"] - Counters = [ - "% Idle Time", - "% Interrupt Time", - "% Privileged Time", - "% User Time", - "% Processor Time", - "% DPC Time", - ] - Measurement = "win_cpu" - # Set to true to include _Total instance when querying for all (*). - # IncludeTotal=false - # Print out when the performance counter is missing from object, counter or instance. - # WarnOnMissing = false - # Gather raw values instead of formatted. Raw value is stored in the field name with the "_Raw" suffix, e.g. "Disk_Read_Bytes_sec_Raw". - # UseRawValues = true - - [[inputs.win_perf_counters.object]] - # Disk times and queues - ObjectName = "LogicalDisk" - Instances = ["*"] - Counters = [ - "% Idle Time", - "% Disk Time", - "% Disk Read Time", - "% Disk Write Time", - "% User Time", - "% Free Space", - "Current Disk Queue Length", - "Free Megabytes", - ] - Measurement = "win_disk" - - [[inputs.win_perf_counters.object]] - ObjectName = "PhysicalDisk" - Instances = ["*"] - Counters = [ - "Disk Read Bytes/sec", - "Disk Write Bytes/sec", - "Current Disk Queue Length", - "Disk Reads/sec", - "Disk Writes/sec", - "% Disk Time", - "% Disk Read Time", - "% Disk Write Time", - ] - Measurement = "win_diskio" - - [[inputs.win_perf_counters.object]] - ObjectName = "Network Interface" - Instances = ["*"] - Counters = [ - "Bytes Received/sec", - "Bytes Sent/sec", - "Packets Received/sec", - "Packets Sent/sec", - "Packets Received Discarded", - "Packets Outbound Discarded", - "Packets Received Errors", - "Packets Outbound Errors", - ] - Measurement = "win_net" - - - [[inputs.win_perf_counters.object]] - ObjectName = "System" - Counters = [ - "Context Switches/sec", - "System Calls/sec", - "Processor Queue Length", - "System Up Time", - ] - Instances = ["------"] - Measurement = "win_system" - - [[inputs.win_perf_counters.object]] - # Example counterPath where the Instance portion must be removed to get data back, - # such as from the Memory object. - ObjectName = "Memory" - Counters = [ - "Available Bytes", - "Cache Faults/sec", - "Demand Zero Faults/sec", - "Page Faults/sec", - "Pages/sec", - "Transition Faults/sec", - "Pool Nonpaged Bytes", - "Pool Paged Bytes", - "Standby Cache Reserve Bytes", - "Standby Cache Normal Priority Bytes", - "Standby Cache Core Bytes", - ] - Instances = ["------"] # Use 6 x - to remove the Instance bit from the counterPath. - Measurement = "win_mem" - - [[inputs.win_perf_counters.object]] - # Example query where the Instance portion must be removed to get data back, - # such as from the Paging File object. - ObjectName = "Paging File" - Counters = [ - "% Usage", - ] - Instances = ["_Total"] - Measurement = "win_swap" -` - type Win_PerfCounters struct { PrintValid bool `toml:"PrintValid"` PreVistaSupport bool `toml:"PreVistaSupport" deprecated:"1.7.0;determined dynamically"` @@ -253,14 +116,6 @@ func extractCounterInfoFromCounterPath(counterPath string) (object string, insta return } -func (m *Win_PerfCounters) Description() string { - return "Input plugin to counterPath Performance Counters on Windows operating systems" -} - -func (m *Win_PerfCounters) SampleConfig() string { - return sampleConfig -} - func newCounter(counterHandle PDH_HCOUNTER, counterPath string, objectName string, instance string, counterName string, measurement string, includeTotal bool, useRawValue bool) *counter { measurementName := sanitizedChars.Replace(measurement) if measurementName == "" { diff --git a/plugins/inputs/win_perf_counters/win_perf_counters_sample_config.go b/plugins/inputs/win_perf_counters/win_perf_counters_sample_config.go new file mode 100644 index 0000000000000..62e6696db6abb --- /dev/null +++ b/plugins/inputs/win_perf_counters/win_perf_counters_sample_config.go @@ -0,0 +1,11 @@ +//go:build windows +// +build windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package win_perf_counters + +func (m *Win_PerfCounters) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/win_services/win_services.go b/plugins/inputs/win_services/win_services.go index 8770ae739877a..3c5abb4481217 100644 --- a/plugins/inputs/win_services/win_services.go +++ b/plugins/inputs/win_services/win_services.go @@ -79,18 +79,6 @@ func (rmr *MgProvider) Connect() (WinServiceManager, error) { } } -var sampleConfig = ` - ## Names of the services to monitor. Leave empty to monitor all the available services on the host. Globs accepted. - service_names = [ - "LanmanServer", - "TermService", - "Win*", - ] - #excluded_service_names = [] # optional, list of service names to exclude -` - -var description = "Input plugin to report Windows services info." - //WinServices is an implementation if telegraf.Input interface, providing info about Windows Services type WinServices struct { Log telegraf.Logger @@ -119,14 +107,6 @@ func (m *WinServices) Init() error { return nil } -func (m *WinServices) Description() string { - return description -} - -func (m *WinServices) SampleConfig() string { - return sampleConfig -} - func (m *WinServices) Gather(acc telegraf.Accumulator) error { scmgr, err := m.mgrProvider.Connect() if err != nil { diff --git a/plugins/inputs/win_services/win_services_sample_config.go b/plugins/inputs/win_services/win_services_sample_config.go new file mode 100644 index 0000000000000..5de8f33d39dad --- /dev/null +++ b/plugins/inputs/win_services/win_services_sample_config.go @@ -0,0 +1,11 @@ +//go:build windows +// +build windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package win_services + +func (m *WinServices) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/win_services/win_services_test.go b/plugins/inputs/win_services/win_services_test.go index b0720169d9db2..343b2c7f7f709 100644 --- a/plugins/inputs/win_services/win_services_test.go +++ b/plugins/inputs/win_services/win_services_test.go @@ -129,17 +129,6 @@ var testErrors = []testData{ }}, } -func TestBasicInfo(t *testing.T) { - - winServices := &WinServices{ - Log: testutil.Logger{}, - mgrProvider: &FakeMgProvider{testErrors[0]}, - } - winServices.Init() - require.NotEmpty(t, winServices.SampleConfig()) - require.NotEmpty(t, winServices.Description()) -} - func TestMgrErrors(t *testing.T) { //mgr.connect error winServices := &WinServices{ diff --git a/plugins/inputs/wireguard/wireguard.go b/plugins/inputs/wireguard/wireguard.go index 068fe8c53a75f..8fe602b24e3d5 100644 --- a/plugins/inputs/wireguard/wireguard.go +++ b/plugins/inputs/wireguard/wireguard.go @@ -32,18 +32,6 @@ type Wireguard struct { client *wgctrl.Client } -func (wg *Wireguard) Description() string { - return "Collect Wireguard server interface and peer statistics" -} - -func (wg *Wireguard) SampleConfig() string { - return ` - ## Optional list of Wireguard device/interface names to query. - ## If omitted, all Wireguard interfaces are queried. - # devices = ["wg0"] -` -} - func (wg *Wireguard) Init() error { var err error diff --git a/plugins/inputs/wireguard/wireguard_sample_config.go b/plugins/inputs/wireguard/wireguard_sample_config.go new file mode 100644 index 0000000000000..e5b7ef940af9d --- /dev/null +++ b/plugins/inputs/wireguard/wireguard_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package wireguard + +func (wg *Wireguard) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/wireless/wireless.go b/plugins/inputs/wireless/wireless.go index 911d7fb097d17..df063d81827d9 100644 --- a/plugins/inputs/wireless/wireless.go +++ b/plugins/inputs/wireless/wireless.go @@ -11,22 +11,6 @@ type Wireless struct { Log telegraf.Logger `toml:"-"` } -var sampleConfig = ` - ## Sets 'proc' directory path - ## If not specified, then default is /proc - # host_proc = "/proc" -` - -// Description returns information about the plugin. -func (w *Wireless) Description() string { - return "Monitor wifi signal strength and quality" -} - -// SampleConfig displays configuration instructions. -func (w *Wireless) SampleConfig() string { - return sampleConfig -} - func init() { inputs.Add("wireless", func() telegraf.Input { return &Wireless{} diff --git a/plugins/inputs/wireless/wireless_sample_config.go b/plugins/inputs/wireless/wireless_sample_config.go new file mode 100644 index 0000000000000..d878df8f59b12 --- /dev/null +++ b/plugins/inputs/wireless/wireless_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package wireless + +func (w *Wireless) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/x509_cert/x509_cert.go b/plugins/inputs/x509_cert/x509_cert.go index 246f6e8a05fbf..28acb676130fb 100644 --- a/plugins/inputs/x509_cert/x509_cert.go +++ b/plugins/inputs/x509_cert/x509_cert.go @@ -23,30 +23,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## List certificate sources - ## Prefix your entry with 'file://' if you intend to use relative paths - sources = ["tcp://example.org:443", "https://influxdata.com:443", - "udp://127.0.0.1:4433", "/etc/ssl/certs/ssl-cert-snakeoil.pem", - "/etc/mycerts/*.mydomain.org.pem", "file:///path/to/*.pem"] - - ## Timeout for SSL connection - # timeout = "5s" - - ## Pass a different name into the TLS request (Server Name Indication) - ## example: server_name = "myhost.example.org" - # server_name = "" - - ## Don't include root or intermediate certificates in output - # exclude_root_certs = false - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" -` -const description = "Reads metrics from a SSL certificate" - // X509Cert holds the configuration of the plugin. type X509Cert struct { Sources []string `toml:"sources"` @@ -60,16 +36,6 @@ type X509Cert struct { Log telegraf.Logger } -// Description returns description of the plugin. -func (c *X509Cert) Description() string { - return description -} - -// SampleConfig returns configuration sample for the plugin. -func (c *X509Cert) SampleConfig() string { - return sampleConfig -} - func (c *X509Cert) sourcesToURLs() error { for _, source := range c.Sources { if strings.HasPrefix(source, "file://") || diff --git a/plugins/inputs/x509_cert/x509_cert_sample_config.go b/plugins/inputs/x509_cert/x509_cert_sample_config.go new file mode 100644 index 0000000000000..b5f0c8b341504 --- /dev/null +++ b/plugins/inputs/x509_cert/x509_cert_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package x509_cert + +func (c *X509Cert) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/x509_cert/x509_cert_test.go b/plugins/inputs/x509_cert/x509_cert_test.go index 1d0a05c2f783d..cc7b2a3bb16b5 100644 --- a/plugins/inputs/x509_cert/x509_cert_test.go +++ b/plugins/inputs/x509_cert/x509_cert_test.go @@ -320,29 +320,6 @@ func TestGatherUDPCert(t *testing.T) { require.True(t, acc.HasMeasurement("x509_cert")) } -func TestStrings(t *testing.T) { - sc := X509Cert{} - require.NoError(t, sc.Init()) - - tests := []struct { - name string - method string - returned string - expected string - }{ - {name: "description", method: "Description", returned: sc.Description(), expected: description}, - {name: "sample config", method: "SampleConfig", returned: sc.SampleConfig(), expected: sampleConfig}, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - if test.returned != test.expected { - t.Errorf("Expected method %s to return '%s', found '%s'.", test.method, test.expected, test.returned) - } - }) - } -} - func TestGatherCertIntegration(t *testing.T) { if testing.Short() { t.Skip("Skipping integration test in short mode") diff --git a/plugins/inputs/xtremio/README.md b/plugins/inputs/xtremio/README.md index f646207bcdce2..dae2b22720016 100644 --- a/plugins/inputs/xtremio/README.md +++ b/plugins/inputs/xtremio/README.md @@ -5,10 +5,11 @@ The `xtremio` plugin gathers metrics from a Dell EMC XtremIO Storage Array's V3 ## Configuration ```toml + # Gathers Metrics From a Dell EMC XtremIO Storage Array's V3 API [[inputs.xtremio]] ## XtremIO User Interface Endpoint url = "https://xtremio.example.com/" # required - + ## Credentials username = "user1" password = "pass123" diff --git a/plugins/inputs/xtremio/xtremio.go b/plugins/inputs/xtremio/xtremio.go index 8bc194e8c04ce..a632955adad6e 100644 --- a/plugins/inputs/xtremio/xtremio.go +++ b/plugins/inputs/xtremio/xtremio.go @@ -27,35 +27,6 @@ type XtremIO struct { client *http.Client } -const sampleConfig = ` - ## XtremIO User Interface Endpoint - url = "https://xtremio.example.com/" # required - - ## Credentials - username = "user1" - password = "pass123" - - ## Metrics to collect from the XtremIO - # collectors = ["bbus","clusters","ssds","volumes","xms"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use SSL but skip chain & host verification - # insecure_skip_verify = false -` - -// Description will appear directly above the plugin definition in the config file -func (xio *XtremIO) Description() string { - return `Gathers Metrics From a Dell EMC XtremIO Storage Array's V3 API` -} - -// SampleConfig will populate the sample configuration portion of the plugin's configuration -func (xio *XtremIO) SampleConfig() string { - return sampleConfig -} - func (xio *XtremIO) Init() error { if xio.Username == "" { return errors.New("username cannot be empty") diff --git a/plugins/inputs/xtremio/xtremio_sample_config.go b/plugins/inputs/xtremio/xtremio_sample_config.go new file mode 100644 index 0000000000000..fc343a203221b --- /dev/null +++ b/plugins/inputs/xtremio/xtremio_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package xtremio + +func (xio *XtremIO) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/zfs/README.md b/plugins/inputs/zfs/README.md index b77cbc3a6647d..3b06d7730d293 100644 --- a/plugins/inputs/zfs/README.md +++ b/plugins/inputs/zfs/README.md @@ -7,6 +7,7 @@ from `sysctl`, 'zfs' and `zpool` on FreeBSD. ## Configuration ```toml +# Read metrics of ZFS from arcstats, zfetchstats, vdev_cache_stats, pools and datasets [[inputs.zfs]] ## ZFS kstat path. Ignored on FreeBSD ## If not specified, then default is: diff --git a/plugins/inputs/zfs/zfs.go b/plugins/inputs/zfs/zfs.go index 4e1999cf68d30..8902a00d81ccb 100644 --- a/plugins/inputs/zfs/zfs.go +++ b/plugins/inputs/zfs/zfs.go @@ -18,28 +18,3 @@ type Zfs struct { zdataset Zdataset //nolint:varcheck,unused // False positive - this var is used for non-default build tag: freebsd Log telegraf.Logger `toml:"-"` } - -var sampleConfig = ` - ## ZFS kstat path. Ignored on FreeBSD - ## If not specified, then default is: - # kstatPath = "/proc/spl/kstat/zfs" - - ## By default, telegraf gather all zfs stats - ## If not specified, then default is: - # kstatMetrics = ["arcstats", "zfetchstats", "vdev_cache_stats"] - ## For Linux, the default is: - # kstatMetrics = ["abdstats", "arcstats", "dnodestats", "dbufcachestats", - # "dmu_tx", "fm", "vdev_mirror_stats", "zfetchstats", "zil"] - ## By default, don't gather zpool stats - # poolMetrics = false - ## By default, don't gather zdataset stats - # datasetMetrics = false -` - -func (z *Zfs) SampleConfig() string { - return sampleConfig -} - -func (z *Zfs) Description() string { - return "Read metrics of ZFS from arcstats, zfetchstats, vdev_cache_stats, pools and datasets" -} diff --git a/plugins/inputs/zfs/zfs_sample_config.go b/plugins/inputs/zfs/zfs_sample_config.go new file mode 100644 index 0000000000000..466558426605d --- /dev/null +++ b/plugins/inputs/zfs/zfs_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package zfs + +func (z *Zfs) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/zipkin/README.md b/plugins/inputs/zipkin/README.md index 3b47da5f430d5..1a03d588ca2c9 100644 --- a/plugins/inputs/zipkin/README.md +++ b/plugins/inputs/zipkin/README.md @@ -8,9 +8,10 @@ based on its main usage cases and the evolution of the OpenTracing standard.* ## Configuration ```toml +# This plugin implements the Zipkin http server to gather trace and timing data needed to troubleshoot latency problems in microservice architectures. [[inputs.zipkin]] - path = "/api/v1/spans" # URL path for span data - port = 9411 # Port on which Telegraf listens + # path = "/api/v1/spans" # URL path for span data + # port = 9411 # Port on which Telegraf listens ``` The plugin accepts spans in `JSON` or `thrift` if the `Content-Type` is `application/json` or `application/x-thrift`, respectively. diff --git a/plugins/inputs/zipkin/zipkin.go b/plugins/inputs/zipkin/zipkin.go index c230736ad195f..be6f9c95a6bd1 100644 --- a/plugins/inputs/zipkin/zipkin.go +++ b/plugins/inputs/zipkin/zipkin.go @@ -47,11 +47,6 @@ type Handler interface { Register(router *mux.Router, recorder Recorder) error } -const sampleConfig = ` - # path = "/api/v1/spans" # URL path for span data - # port = 9411 # Port on which Telegraf listens -` - // Zipkin is a telegraf configuration structure for the zipkin input plugin, // but it also contains fields for the management of a separate, concurrent // zipkin http server @@ -68,16 +63,6 @@ type Zipkin struct { waitGroup *sync.WaitGroup } -// Description is a necessary method implementation from telegraf.ServiceInput -func (z Zipkin) Description() string { - return "This plugin implements the Zipkin http server to gather trace and timing data needed to troubleshoot latency problems in microservice architectures." -} - -// SampleConfig is a necessary method implementation from telegraf.ServiceInput -func (z Zipkin) SampleConfig() string { - return sampleConfig -} - // Gather is empty for the zipkin plugin; all gathering is done through // the separate goroutine launched in (*Zipkin).Start() func (z *Zipkin) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/zipkin/zipkin_sample_config.go b/plugins/inputs/zipkin/zipkin_sample_config.go new file mode 100644 index 0000000000000..a7bad2f40a361 --- /dev/null +++ b/plugins/inputs/zipkin/zipkin_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package zipkin + +func (z Zipkin) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/zookeeper/zookeeper.go b/plugins/inputs/zookeeper/zookeeper.go index 625ba47bd690e..8581da9c3ac99 100644 --- a/plugins/inputs/zookeeper/zookeeper.go +++ b/plugins/inputs/zookeeper/zookeeper.go @@ -32,38 +32,8 @@ type Zookeeper struct { tlsConfig *tls.Config } -var sampleConfig = ` - ## An array of address to gather stats about. Specify an ip or hostname - ## with port. ie localhost:2181, 10.0.0.1:2181, etc. - - ## If no servers are specified, then localhost is used as the host. - ## If no port is specified, 2181 is used - servers = [":2181"] - - ## Timeout for metric collections from all servers. Minimum timeout is "1s". - # timeout = "5s" - - ## Optional TLS Config - # enable_tls = true - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## If false, skip chain & host verification - # insecure_skip_verify = true -` - var defaultTimeout = 5 * time.Second -// SampleConfig returns sample configuration message -func (z *Zookeeper) SampleConfig() string { - return sampleConfig -} - -// Description returns description of Zookeeper plugin -func (z *Zookeeper) Description() string { - return `Reads 'mntr' stats from one or many zookeeper servers` -} - func (z *Zookeeper) dial(ctx context.Context, addr string) (net.Conn, error) { var dialer net.Dialer if z.EnableTLS || z.EnableSSL { diff --git a/plugins/inputs/zookeeper/zookeeper_sample_config.go b/plugins/inputs/zookeeper/zookeeper_sample_config.go new file mode 100644 index 0000000000000..e13ab459b6c6d --- /dev/null +++ b/plugins/inputs/zookeeper/zookeeper_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package zookeeper + +func (z *Zookeeper) SampleConfig() string { + return `{{ .SampleConfig }}` +}