b8fb6c5
From 4a39b56c7aefdd9794add4468c7dbe87ff683ce8 Mon Sep 17 00:00:00 2001
b8fb6c5
From: Daniel Black <daniel.black@openquery.com>
b8fb6c5
Date: Sun, 26 Oct 2014 17:36:29 +1100
b8fb6c5
Subject: [PATCH] Run munin-asyncd fetching on wall clock type
b8fb6c5
b8fb6c5
Patch by Picnic Pete: https://github.com/picnicpete
b8fb6c5
---
b8fb6c5
 node/_bin/munin-asyncd.in | 11 ++++++++---
b8fb6c5
 1 file changed, 8 insertions(+), 3 deletions(-)
b8fb6c5
b8fb6c5
diff --git a/node/_bin/munin-asyncd.in b/node/_bin/munin-asyncd.in
b8fb6c5
index 8efe50f..4811b2d 100644
b8fb6c5
--- a/node/_bin/munin-asyncd.in
b8fb6c5
+++ b/node/_bin/munin-asyncd.in
b8fb6c5
@@ -160,9 +160,14 @@ MAIN: while($keepgoing) {
b8fb6c5
 			next;
b8fb6c5
 		}
b8fb6c5
 
b8fb6c5
-		# Should update it
b8fb6c5
-		$last_updated{$plugin} = $when;
b8fb6c5
-		$when_next = min($when_next, $when + max($plugin_rate, $minrate));
b8fb6c5
+		# Should update it - based on wall clock time
b8fb6c5
+		my $should_have_been = $when - ($when % $plugin_rate);
b8fb6c5
+		my $should_be_next = $should_have_been + $plugin_rate;
b8fb6c5
+
b8fb6c5
+		$last_updated{$plugin} = $should_have_been;
b8fb6c5
+		if ($should_be_next < $when_next) {
b8fb6c5
+			$when_next = $should_be_next;
b8fb6c5
+		}
b8fb6c5
 
b8fb6c5
 		if ($do_fork && fork()) {
b8fb6c5
 			# parent, return directly