From ef61c14dbab1199ad1824ae364dc1774c96ff27c Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 21 Jul 2010 19:06:09 +0100 Subject: [PATCH] calc_reliability_stats() now works by inspecting each probe element. --- lib/ZOOM/IRSpy/Utils.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/ZOOM/IRSpy/Utils.pm b/lib/ZOOM/IRSpy/Utils.pm index 475e9de..27df7c1 100644 --- a/lib/ZOOM/IRSpy/Utils.pm +++ b/lib/ZOOM/IRSpy/Utils.pm @@ -814,11 +814,17 @@ sub calc_reliability_string { sub calc_reliability_stats { my($xc) = @_; + my $now = isodate(time()); my @allpings = $xc->findnodes("i:status/i:probe"); - my $nall = @allpings; - return (0, 0, 0) if $nall == 0; - my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]'); - my $nok = @okpings; + return (0, 0, 0) if @allpings == 0; + + my($nall, $nok) = (0, 0); + foreach my $node (@allpings) { + my $ok = $xc->findvalue('@ok', $node); + $nall++; + $nok += !!$ok; + } + my $percent = int(100*$nok/$nall + 0.5); return ($nok, $nall, $percent); } -- 1.7.10.4