From: Mike Taylor Date: Wed, 21 Jul 2010 18:06:09 +0000 (+0100) Subject: calc_reliability_stats() now works by inspecting each probe element. X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=ef61c14dbab1199ad1824ae364dc1774c96ff27c;p=irspy-moved-to-github.git calc_reliability_stats() now works by inspecting each probe element. --- 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); }