Add means for config to 'work' (not cause an exit) cross platform

This commit is contained in:
Greg Linton
2018-10-24 10:15:38 -06:00
parent 8d0ec993c7
commit 1cf2058dbf
2 changed files with 54 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
package inputs
import (
"log"
"github.com/influxdata/telegraf"
)
// InvalidPlugin is used when a plugin may be invalid for a
// platform or other reason.
type InvalidPlugin struct {
InvalidReason string
OrigDesc string
OrigSampleCfg string
}
// Description should be inherited from the parent plugin.
func (i *InvalidPlugin) Description() string {
return i.OrigDesc
}
// SampleConfig should be inherited from the parent plugin.
func (i *InvalidPlugin) SampleConfig() string {
return i.OrigSampleCfg
}
// Gather does nothing, as the plugin is invalid.
func (i *InvalidPlugin) Gather(_a0 telegraf.Accumulator) error {
return nil
}
// Start prints the reason the plugin was not valid.
func (i *InvalidPlugin) Start(telegraf.Accumulator) error {
log.Printf("E! %s", i.InvalidReason)
return nil
}
// Stop does nothing, as the plugin is invalid.
func (i *InvalidPlugin) Stop() { return }
@@ -1,3 +1,18 @@
// +build windows
package processes
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
)
func init() {
inputs.Add("processes", func() telegraf.Input {
return &inputs.InvalidPlugin{
InvalidReason: "Process input plugin not supported on windows",
OrigDesc: "Get the number of processes and group them by status",
OrigSampleCfg: "",
}
})
}