line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nagios::Plugin::CheckHost::Result::Ping; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
360
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
14
|
use base "Nagios::Plugin::CheckHost::Result"; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
335
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub calc_rtt { |
9
|
11
|
|
|
11
|
0
|
9
|
my ($self, $node) = @_; |
10
|
|
|
|
|
|
|
|
11
|
11
|
|
|
|
|
16
|
my $result = $self->{results}->{$node}; |
12
|
11
|
50
|
|
|
|
17
|
return unless $result; |
13
|
11
|
|
|
|
|
8
|
$result = $result->[0]; |
14
|
11
|
50
|
33
|
|
|
30
|
return unless $result and $result->[0]; |
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
|
|
7
|
my $avg = 0; |
17
|
11
|
|
|
|
|
9
|
my $total = 0; |
18
|
11
|
|
|
|
|
13
|
foreach my $check (@$result) { |
19
|
44
|
100
|
|
|
|
58
|
if ($check->[0] eq "OK") { |
20
|
29
|
|
|
|
|
20
|
$avg += $check->[1]; |
21
|
29
|
|
|
|
|
24
|
$total += 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
11
|
100
|
|
|
|
22
|
return unless $total; |
25
|
8
|
|
|
|
|
22
|
$avg/$total; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub calc_loss { |
29
|
20
|
|
|
20
|
0
|
19
|
my ($self, $node) = @_; |
30
|
|
|
|
|
|
|
|
31
|
20
|
|
|
|
|
37
|
my $result = $self->{results}->{$node}; |
32
|
20
|
50
|
|
|
|
30
|
return 1 unless $result; |
33
|
20
|
|
|
|
|
17
|
$result = $result->[0]; |
34
|
20
|
50
|
33
|
|
|
52
|
return 1 unless $result and $result->[0]; |
35
|
|
|
|
|
|
|
|
36
|
20
|
|
|
|
|
17
|
my ($success, $fail) = (0, 0); |
37
|
20
|
|
|
|
|
23
|
foreach my $check (@$result) { |
38
|
80
|
100
|
|
|
|
97
|
if (uc $check->[0] eq "OK") { |
39
|
50
|
|
|
|
|
36
|
$success++; |
40
|
|
|
|
|
|
|
} else { |
41
|
30
|
|
|
|
|
25
|
$fail++; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
20
|
|
|
|
|
57
|
$fail/($fail+$success); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |