Load external .so plugins
support for the Go 1.8 shared object feature of loading external plugins. this support relies on the developer defining a `Plugin` symbol in their .so file that is a telegraf plugin interface. So instead of the plugin developer "Adding" their own plugin to the telegraf registry, telegraf loads the .so, looks up the Plugin symbol, and then adds it if it finds it. The name of the plugin is determined by telegraf, and is namespaced based on the filename and path. see #1717
This commit is contained in:
@@ -39,6 +39,14 @@ var (
|
||||
|
||||
// envVarRe is a regex to find environment variables in the config file
|
||||
envVarRe = regexp.MustCompile(`\$\w+`)
|
||||
|
||||
// addQuoteRe is a regex for finding and adding quotes around / characters
|
||||
// when they are used for distinguishing external plugins.
|
||||
// ie, a ReplaceAll() with this pattern will be used to turn this:
|
||||
// [[inputs.external/test/example]]
|
||||
// to
|
||||
// [[inputs."external/test/example"]]
|
||||
addQuoteRe = regexp.MustCompile(`(\[?\[?inputs|outputs|processors|aggregators)\.(external\/[^.\]]+)`)
|
||||
)
|
||||
|
||||
// Config specifies the URL/user/password for the database that telegraf
|
||||
@@ -704,6 +712,9 @@ func parseFile(fpath string) (*ast.Table, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// add quotes around external plugin paths.
|
||||
contents = addQuoteRe.ReplaceAll(contents, []byte(`$1."$2"`))
|
||||
|
||||
return toml.Parse(contents)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user