Skip to content

Commit

Permalink
feat: migrate input plugins to new sample config format (M-Z) (influx…
Browse files Browse the repository at this point in the history
  • Loading branch information
sspaink authored Apr 11, 2022
1 parent 66daef2 commit b355be5
Show file tree
Hide file tree
Showing 307 changed files with 1,433 additions and 4,446 deletions.
1 change: 1 addition & 0 deletions plugins/inputs/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions plugins/inputs/mailchimp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
```
Expand Down
19 changes: 0 additions & 19 deletions plugins/inputs/mailchimp/mailchimp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/mailchimp/mailchimp_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
1 change: 1 addition & 0 deletions plugins/inputs/marklogic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 0 additions & 29 deletions plugins/inputs/marklogic/marklogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/marklogic/marklogic_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
19 changes: 0 additions & 19 deletions plugins/inputs/mcrouter/mcrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/mcrouter/mcrouter_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
14 changes: 0 additions & 14 deletions plugins/inputs/mdstat/mdstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions plugins/inputs/mdstat/mdstat_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
6 changes: 0 additions & 6 deletions plugins/inputs/mem/memory.go → plugins/inputs/mem/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/mem/mem_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
File renamed without changes.
25 changes: 0 additions & 25 deletions plugins/inputs/memcached/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/memcached/memcached_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
53 changes: 0 additions & 53 deletions plugins/inputs/mesos/mesos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/mesos/mesos_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
4 changes: 4 additions & 0 deletions plugins/inputs/minecraft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
22 changes: 0 additions & 22 deletions plugins/inputs/minecraft/minecraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/minecraft/minecraft_sample_config.go
Original file line number Diff line number Diff line change
@@ -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 }}`
}
Loading

0 comments on commit b355be5

Please sign in to comment.