[monitoring-plugin-perl] We think it is better to always have a threshold ...
A Codeweavers Infrastructure Bod
git at monitoring-plugins.org
Wed Sep 9 14:30:03 CEST 2020
Module: monitoring-plugin-perl
Branch: master
Commit: 0b62478ad269cc6042dfc411619cfe0f6c9517aa
Author: A Codeweavers Infrastructure Bod <36475663+infraweavers at users.noreply.github.com>
Date: Wed Sep 9 10:59:13 2020 +0100
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugin-perl/commit/?id=0b62478
We think it is better to always have a threshold object implicitly created when warning and critical is passed in, so that order of execution between $mp->check_threshold and $mp->add_perfdata doesn't matter
---
lib/Monitoring/Plugin.pm | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lib/Monitoring/Plugin.pm b/lib/Monitoring/Plugin.pm
index 3b4d7b3..3660ba7 100644
--- a/lib/Monitoring/Plugin.pm
+++ b/lib/Monitoring/Plugin.pm
@@ -131,8 +131,7 @@ sub check_threshold {
# in order of preference, get warning and critical from
# 1. explicit arguments to check_threshold
- # 2. previously explicitly set threshold object
- # 3. implicit options from Getopts object
+ # 2. previously explicitly set threshold object or implicit theshold object created by warning and critical
if ( exists $args{warning} || exists $args{critical} ) {
$self->set_thresholds(
warning => $args{warning},
@@ -142,12 +141,6 @@ sub check_threshold {
elsif ( defined $self->threshold ) {
# noop
}
- elsif ( defined $self->opts ) {
- $self->set_thresholds(
- warning => $self->opts->warning,
- critical => $self->opts->critical,
- );
- }
else {
return UNKNOWN;
}
@@ -163,6 +156,10 @@ sub add_arg {
sub getopts {
my $self = shift;
$self->opts->getopts(@_) if $self->_check_for_opts;
+ $self->set_thresholds(
+ warning => $self->opts->warning,
+ critical => $self->opts->critical,
+ ) if ( defined $self->opts->warning && defined $self->opts->critical );
}
sub _check_for_opts {
More information about the Commits
mailing list