Example #1
0
func runCollector(collector collector.Collector) {
	log.Info("Running ", collector)

	ticker := time.NewTicker(time.Duration(collector.Interval()) * time.Second)
	collect := ticker.C

	staggerValue := 1
	collectionDeadline := time.Duration(collector.Interval() + staggerValue)

	for {
		select {
		case <-collect:
			if collector.CollectorType() == "listener" {
				collector.Collect()
			} else {
				countdownTimer := time.AfterFunc(collectionDeadline*time.Second, func() {
					reportCollector(collector)
				})
				collector.Collect()
				countdownTimer.Stop()
			}
		}
	}
	ticker.Stop()
}
Example #2
0
func runCollector(collector collector.Collector) {
	log.Info("Running ", collector)
	for {
		collector.Collect()
		time.Sleep(time.Duration(collector.Interval()) * time.Second)
	}
}
Example #3
0
func runCollector(collector collector.Collector) {
	for {
		log.Println("Collecting from", collector)
		collector.Collect()
		time.Sleep(time.Duration(collector.Interval()) * time.Second)
	}
}