Last active
June 14, 2019 13:16
-
-
Save krisclarkdev/184c9db7d3e00e20dca047f97074c5c1 to your computer and use it in GitHub Desktop.
Boilerplate code for a telegraf plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Step 1. Create a folder called "mycollector" inside telegraf/plugins/inputs | |
Step 2. Create a file named "mycollector.go" inside the above folder | |
Step 3. Add an entry for "mycollector" *alphabetically* in plugins/inputs/all/all.go | |
_ "github.com/influxdata/telegraf/plugins/inputs/mycollector" | |
*/ | |
package mycollector | |
import ( | |
"github.com/influxdata/telegraf" | |
"github.com/influxdata/telegraf/plugins/inputs" | |
) | |
type Mycollector struct { | |
Servers []string | |
Username string | |
Password string | |
} | |
func (m *Mycollector) Gather(acc telegraf.Accumulator) error { | |
// This does work | |
// At end of collector fil Accumulator | |
return nil | |
} | |
func (m *Mycollector) Description() string { | |
return "" | |
} | |
func (m *Mycollector) SampleConfig() string { | |
return "" | |
} | |
func init() { | |
inputs.Add("mycollector", func() telegraf.Input { | |
return &Mycollector{} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment