Add parameter to force the interval of gather for sysstat (#4068)

This commit is contained in:
Adrián López 2018-04-26 03:59:42 +02:00 committed by Daniel Nelson
parent abdff033cc
commit 46a8bdbfe5
1 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,9 @@ type Sysstat struct {
// Sadc represents the path to the sadc collector utility.
Sadc string `toml:"sadc_path"`
// Force the execution time of sadc
SadcInterval internal.Duration `toml:"sadc_interval"`
// Sadf represents the path to the sadf cmd.
Sadf string `toml:"sadf_path"`
@ -136,6 +139,11 @@ func (*Sysstat) SampleConfig() string {
}
func (s *Sysstat) Gather(acc telegraf.Accumulator) error {
if s.SadcInterval.Duration != 0 {
// Collect interval is calculated as interval - parseInterval
s.interval = int(s.SadcInterval.Duration.Seconds()) + parseInterval
}
if s.interval == 0 {
if firstTimestamp.IsZero() {
firstTimestamp = time.Now()