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