From 46a8bdbfe54c97190c82eaee46d9c3413c6ff20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20L=C3=B3pez?= Date: Thu, 26 Apr 2018 03:59:42 +0200 Subject: [PATCH] Add parameter to force the interval of gather for sysstat (#4068) --- plugins/inputs/sysstat/sysstat.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/inputs/sysstat/sysstat.go b/plugins/inputs/sysstat/sysstat.go index 1daa85730..42ce89550 100644 --- a/plugins/inputs/sysstat/sysstat.go +++ b/plugins/inputs/sysstat/sysstat.go @@ -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()