Add polling method to logparser and tail inputs (#3213)
This commit is contained in:
@@ -15,10 +15,15 @@ import (
|
||||
"github.com/influxdata/telegraf/plugins/parsers"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultWatchMethod = "inotify"
|
||||
)
|
||||
|
||||
type Tail struct {
|
||||
Files []string
|
||||
FromBeginning bool
|
||||
Pipe bool
|
||||
WatchMethod string
|
||||
|
||||
tailers []*tail.Tail
|
||||
parser parsers.Parser
|
||||
@@ -50,6 +55,9 @@ const sampleConfig = `
|
||||
## Whether file is a named pipe
|
||||
pipe = false
|
||||
|
||||
## Method used to watch for file updates. Can be either "inotify" or "poll".
|
||||
# watch_method = "inotify"
|
||||
|
||||
## Data format to consume.
|
||||
## Each data format has its own unique set of configuration options, read
|
||||
## more about them here:
|
||||
@@ -83,6 +91,11 @@ func (t *Tail) Start(acc telegraf.Accumulator) error {
|
||||
}
|
||||
}
|
||||
|
||||
var poll bool
|
||||
if t.WatchMethod == "poll" {
|
||||
poll = true
|
||||
}
|
||||
|
||||
// Create a "tailer" for each file
|
||||
for _, filepath := range t.Files {
|
||||
g, err := globpath.Compile(filepath)
|
||||
@@ -96,6 +109,7 @@ func (t *Tail) Start(acc telegraf.Accumulator) error {
|
||||
Follow: true,
|
||||
Location: seek,
|
||||
MustExist: true,
|
||||
Poll: poll,
|
||||
Pipe: t.Pipe,
|
||||
Logger: tail.DiscardingLogger,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user