Nagios/Plugin/Threshold/Group.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 3 totaltotal 81.8% 45 / 55 CC 8 SCAR 13.0
CC
8
Cov
87%
get_status
6.0
new
3.1
get_value_status
2.0
CRAP 3.7
« Net/CheckHost.pm ↑ Summary Nagios/Plugin/CheckHost/HTTP.pm »
1 package Nagios::Plugin::Threshold::Group;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Monitoring::Plugin::Functions qw(OK WARNING CRITICAL);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod undocumented
10 7 my ($class, %args) = @_;
11  
12 7 ▶ my $single_threshold = delete $args{single_threshold} or croak 'single_threshold missed';
Branch: 1 branch
BranchTrueFalseTotal
my $single_threshold = delete $args{"single_threshold"} or croak("single_threshold missed") 7 0 7
13 7 ▶ my $group_threshold = delete $args{group_threshold} or croak 'group_threshold missed';
Branch: 1 branch
BranchTrueFalseTotal
my $group_threshold = delete $args{"group_threshold"} or croak("group_threshold missed") 7 0 7
14  
15 7 bless {
16 single_threshold => $single_threshold,
17 group_threshold => $group_threshold,
18 }, $class;
19 }
20  
21 0 ▶sub get_value_status {
Subroutine get_value_status: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my ($self, $value) = @_;
23  
24 0 $self->{single_threshold}->get_status($value);
25 }
26  
27 8 ▶sub get_status {
Subroutine get_status: called CC=6 SCAR=18.0
Pod undocumented
28 8 my ($self, $values) = @_;
29  
30 8 ▶ $values = [$values] if ref $values eq '';
Branch: 1 branch
BranchTrueFalseTotal
if ref $values eq "" 0 8 8
31  
32 8 my $st = $self->{single_threshold};
33 8 my $gt = $self->{group_threshold};
34  
35 8 my $s = {
36 Monitoring::Plugin::Functions::OK => 0,
37 Monitoring::Plugin::Functions::WARNING => 0,
38 Monitoring::Plugin::Functions::CRITICAL => 0,
39 };
40  
41 8 foreach my $value (@$values) {
42 28 $s->{$st->get_status($value)}++;
43 }
44  
45 8 my $criticals = $s->{Monitoring::Plugin::Functions::CRITICAL};
46 8 my $status = $gt->get_status($criticals);
47 8 ▶ return $status if $status != OK;
Branch: 1 branch
BranchTrueFalseTotal
if $status != 0 4 4 8
48  
49 4 ▶ if ($gt->warning->is_set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gt->warning->is_set) 4 0 4
50 4 my $warnings = $s->{Monitoring::Plugin::Functions::WARNING};
51 4 ▶ return WARNING if $gt->warning->check_range($warnings + $criticals);
Branch: 1 branch
BranchTrueFalseTotal
if $gt->warning->check_range($warnings + $criticals) 1 3 4
52 }
53  
54 OK
55 3 }
56  
57 2 1;
« Net/CheckHost.pm ↑ Summary Nagios/Plugin/CheckHost/HTTP.pm »