@@ -323,7 +323,7 @@ func (a *Agent) runInputs(
323
323
wg .Add (1 )
324
324
go func (input * models.RunningInput ) {
325
325
defer wg .Done ()
326
- a .gatherLoop (ctx , acc , input , ticker )
326
+ a .gatherLoop (ctx , acc , input , ticker , interval )
327
327
}(input )
328
328
}
329
329
@@ -454,13 +454,14 @@ func (a *Agent) gatherLoop(
454
454
acc telegraf.Accumulator ,
455
455
input * models.RunningInput ,
456
456
ticker Ticker ,
457
+ interval time.Duration ,
457
458
) {
458
459
defer panicRecover (input )
459
460
460
461
for {
461
462
select {
462
463
case <- ticker .Elapsed ():
463
- err := a .gatherOnce (acc , input , ticker )
464
+ err := a .gatherOnce (acc , input , ticker , interval )
464
465
if err != nil {
465
466
acc .AddError (err )
466
467
}
@@ -476,18 +477,28 @@ func (a *Agent) gatherOnce(
476
477
acc telegraf.Accumulator ,
477
478
input * models.RunningInput ,
478
479
ticker Ticker ,
480
+ interval time.Duration ,
479
481
) error {
480
482
done := make (chan error )
481
483
go func () {
482
484
done <- input .Gather (acc )
483
485
}()
484
486
487
+ // Only warn after interval seconds, even if the interval is started late.
488
+ // Intervals can start late if the previous interval went over or due to
489
+ // clock changes.
490
+ slowWarning := time .NewTicker (interval )
491
+ defer slowWarning .Stop ()
492
+
485
493
for {
486
494
select {
487
495
case err := <- done :
488
496
return err
497
+ case <- slowWarning .C :
498
+ log .Printf ("W! [%s] Collection took longer than expected; not complete after interval of %s" ,
499
+ input .LogName (), interval )
489
500
case <- ticker .Elapsed ():
490
- log .Printf ("W ! [agent] [ %s] did not complete within its interval " ,
501
+ log .Printf ("D ! [%s] Previous collection has not completed; scheduled collection skipped " ,
491
502
input .LogName ())
492
503
}
493
504
}
0 commit comments