Reset read deadline for syslog input (#4369)
This commit is contained in:
parent
1cc300710c
commit
69d22afcc2
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
)
|
||||
|
||||
const defaultReadTimeout = time.Millisecond * 500
|
||||
const defaultReadTimeout = time.Second * 5
|
||||
const ipMaxPacketSize = 64 * 1024
|
||||
|
||||
// Syslog is a syslog plugin
|
||||
|
@ -279,19 +279,23 @@ func (s *Syslog) handle(conn net.Conn, acc telegraf.Accumulator) {
|
|||
conn.Close()
|
||||
}()
|
||||
|
||||
if s.ReadTimeout != nil && s.ReadTimeout.Duration > 0 {
|
||||
conn.SetReadDeadline(time.Now().Add(s.ReadTimeout.Duration))
|
||||
}
|
||||
|
||||
var p *rfc5425.Parser
|
||||
|
||||
if s.BestEffort {
|
||||
p = rfc5425.NewParser(conn, rfc5425.WithBestEffort())
|
||||
} else {
|
||||
p = rfc5425.NewParser(conn)
|
||||
}
|
||||
|
||||
if s.ReadTimeout != nil && s.ReadTimeout.Duration > 0 {
|
||||
conn.SetReadDeadline(time.Now().Add(s.ReadTimeout.Duration))
|
||||
}
|
||||
|
||||
p.ParseExecuting(func(r *rfc5425.Result) {
|
||||
s.store(*r, acc)
|
||||
if s.ReadTimeout != nil && s.ReadTimeout.Duration > 0 {
|
||||
conn.SetReadDeadline(time.Now().Add(s.ReadTimeout.Duration))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -361,7 +365,7 @@ func fields(msg rfc5424.SyslogMessage, s *Syslog) map[string]interface{} {
|
|||
}
|
||||
|
||||
if msg.Message() != nil {
|
||||
flds["message"] = *msg.Message()
|
||||
flds["message"] = strings.TrimSpace(*msg.Message())
|
||||
}
|
||||
|
||||
if msg.StructuredData() != nil {
|
||||
|
|
Loading…
Reference in New Issue