From aac4c29dc6c5cffa1f2f94df4bd81991475ee464 Mon Sep 17 00:00:00 2001 From: Pontus Rydin Date: Tue, 7 May 2019 14:52:24 -0400 Subject: [PATCH] Fix interval estimation in vsphere input (#5726) --- plugins/inputs/vsphere/endpoint.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index 694efb574..411bdc965 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -806,9 +806,17 @@ func (e *Endpoint) collectResource(ctx context.Context, resourceType string, acc localNow := time.Now() estInterval := time.Duration(time.Minute) if !res.lastColl.IsZero() { - estInterval = localNow.Sub(res.lastColl).Truncate(time.Duration(res.sampling) * time.Second) + s := time.Duration(res.sampling) * time.Second + rawInterval := localNow.Sub(res.lastColl) + paddedInterval := rawInterval + time.Duration(res.sampling/2)*time.Second + estInterval = paddedInterval.Truncate(s) + if estInterval < s { + estInterval = s + } + log.Printf("D! [inputs.vsphere] Raw interval %s, padded: %s, estimated: %s", rawInterval, paddedInterval, estInterval) } log.Printf("D! [inputs.vsphere] Interval estimated to %s", estInterval) + res.lastColl = localNow latest := res.latestSample if !latest.IsZero() {