Nagios/Plugin/CheckHost/Result/Ping.pm

filter: Statementstmt 100% 34 / 34 Branchbran 71.4% 10 / 14 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 78.4% 51 / 65 CC 12 SCAR 17.4
CC
12
Cov
85%
calc_rtt
7.2
calc_loss
6.3
BEGIN
1.0
CRAP 5.7
« Nagios/Plugin/CheckHost.pm ↑ Summary Nagios/Plugin/CheckHost/Result.pm »
1 package Nagios::Plugin::CheckHost::Result::Ping;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base "Nagios::Plugin::CheckHost::Result";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶sub calc_rtt {
Subroutine calc_rtt: called CC=7 SCAR=19.8
Pod undocumented
9 11 my ($self, $node) = @_;
10  
11 11 my $result = $self->{results}->{$node};
12 11 ▶ return unless $result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 11 11
13 11 $result = $result->[0];
14 11 ▶ return unless $result and $result->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $result and $result->[0] 0 11 11
Condition33%1/3
$result and $result->[0]
!ll&&!rl&&r
0011
MC/DC0%0/2
$result and $result->[0]
$result $result->[0]
Truth table33%1/3
A and B
A= $resultB= $result->[0]
ABresult
0X0
100
111
15  
16 11 my $avg = 0;
17 11 my $total = 0;
18 11 foreach my $check (@$result) {
19 44 ▶ if ($check->[0] eq "OK") {
Branch: 1 branch
BranchTrueFalseTotal
if ($check->[0] eq "OK") 29 15 44
20 29 $avg += $check->[1];
21 29 $total += 1;
22 }
23 }
24 11 ▶ return unless $total;
Branch: 1 branch
BranchTrueFalseTotal
unless $total 3 8 11
25 8 $avg/$total;
26 }
27  
28 20 ▶sub calc_loss {
Subroutine calc_loss: called CC=6 SCAR=18.4
Pod undocumented
29 20 my ($self, $node) = @_;
30  
31 20 my $result = $self->{results}->{$node};
32 20 ▶ return 1 unless $result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 20 20
33 20 $result = $result->[0];
34 20 ▶ return 1 unless $result and $result->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $result and $result->[0] 0 20 20
Condition33%1/3
$result and $result->[0]
!ll&&!rl&&r
0020
MC/DC0%0/2
$result and $result->[0]
$result $result->[0]
Truth table33%1/3
A and B
A= $resultB= $result->[0]
ABresult
0X0
100
111
35  
36 20 my ($success, $fail) = (0, 0);
37 20 foreach my $check (@$result) {
38 80 ▶ if (uc $check->[0] eq "OK") {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $check->[0] eq 'OK') { } 50 30 80
39 50 $success++;
40 } else {
41 30 $fail++;
42 }
43 }
44
45 20 $fail/($fail+$success);
46 }
47  
48 1 1;
« Nagios/Plugin/CheckHost.pm ↑ Summary Nagios/Plugin/CheckHost/Result.pm »