From 1b60ea870d19ed2791bd791042269f2136c60d0f Mon Sep 17 00:00:00 2001 From: Brian Hourigan Date: Sat, 22 Nov 2014 19:53:50 -0500 Subject: [PATCH] Apache response time was incorrectly divided by 1000 twice, fixed that bug and moved division to save function to get higher precision --- plugins/apache/apache_vhosts/apache_pipelogger | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/apache/apache_vhosts/apache_pipelogger b/plugins/apache/apache_vhosts/apache_pipelogger index d762c5cb..09e39617 100644 --- a/plugins/apache/apache_vhosts/apache_pipelogger +++ b/plugins/apache/apache_vhosts/apache_pipelogger @@ -40,7 +40,6 @@ while () { # sanity check next unless m/^([\d\w\.\-_]+\s){5}([\d\w\.\-_]+$)/; # escaped "." and "-" - $time=sprintf("%d",$time/1000); # microsec to millisec # sitename to munin fieldname my $vpm=clean_fieldname($vhost); @@ -66,9 +65,6 @@ while () { $temp{$vpm}{"status"}{$status}++ if $status; if ($time) { - # microsec to millisec - $time=sprintf("%d",$time/1000); - # min/max execution time $temp{$vpm}{'max_time'}=max($temp{$vpm}{'max_time'},$time); @@ -93,8 +89,8 @@ sub periodic_write { $old{$vpm}{'requests'}+=$temp{$vpm}{'requests'} if $temp{$vpm}{'requests'}; $old{$vpm}{'time'}+=$temp{$vpm}{'time'} if $temp{$vpm}{'time'}; $old{$vpm}{'label'}=$temp{$vpm}{'label'}; - $old{$vpm}{'avg_time'}=sprintf("%d",($old{$vpm}{'avg_time'}+$temp{$vpm}{'avg_time'})/2); - $old{$vpm}{'max_time'}=max($old{$vpm}{'max_time'},$temp{$vpm}{'max_time'}); + $old{$vpm}{'avg_time'}=sprintf("%d",(($old{$vpm}{'avg_time'}+$temp{$vpm}{'avg_time'})/2)/1000); + $old{$vpm}{'max_time'}=max($old{$vpm}{'max_time'},$temp{$vpm}{'max_time'})/1000; $old{$vpm}{'max_bytes'}=max($temp{$vpm}{'max_bytes'},$temp{$vpm}{'max_bytes'}); $old{$vpm}{'avg_bytes'}=sprintf("%d",($old{$vpm}{'avg_bytes'}+$temp{$vpm}{'avg_bytes'})/2);