| 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
| |||||||||||
| 13 | 7 | ▶ | my $group_threshold = delete $args{group_threshold} or croak 'group_threshold missed'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 48 | |||||||||||
| 49 | 4 | ▶ | if ($gt->warning->is_set) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 4 | my $warnings = $s->{Monitoring::Plugin::Functions::WARNING}; | |||||||||
| 51 | 4 | ▶ | return WARNING if $gt->warning->check_range($warnings + $criticals); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | OK | ||||||||||
| 55 | 3 | } | |||||||||
| 56 | |||||||||||
| 57 | 2 | 1; | |||||||||