From d9ab69e0a11462e21df8d2885efcbf91ec5a55c0 Mon Sep 17 00:00:00 2001 From: Kris Popendorf Date: Tue, 23 Apr 2013 11:18:40 +0900 Subject: [PATCH] Fixes bandwidth_ to successfully init new installs. Previously the script would try to divide by 0 for calculating rates on the first run, and crash before getting to store() to write initial values thus never initing itself. This fixes that, and makes it a little easier to debug in case of future crashes (no need for 'eval' wrapper). --- plugins/network/bandwidth_ | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/network/bandwidth_ b/plugins/network/bandwidth_ index 99a4fc39..1ceda5e6 100755 --- a/plugins/network/bandwidth_ +++ b/plugins/network/bandwidth_ @@ -75,7 +75,7 @@ my $count30 = 2592000; # The number of seconds in 30 days my $unix_ts = time; my $rollover = 4294967295; -eval { init(); }; +init(); sub autoconf { $0 =~ /bandwidth_(.+)*$/; @@ -263,6 +263,7 @@ sub sum_old { sub munin_output { my $period = $unix_ts - $oldest_ts; + return unless $period; #can't estimate anything from a single point, so don't. my $total30 = $input_30days + $output_30days; my $average30 = $total30 / $period; print "average.value $average30\n";