diff options
| -rw-r--r-- | lib/Monitoring/Plugin.pm | 13 |
1 files 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 { | |||
| 131 | 131 | ||
| 132 | # in order of preference, get warning and critical from | 132 | # in order of preference, get warning and critical from |
| 133 | # 1. explicit arguments to check_threshold | 133 | # 1. explicit arguments to check_threshold |
| 134 | # 2. previously explicitly set threshold object | 134 | # 2. previously explicitly set threshold object or implicit theshold object created by warning and critical |
| 135 | # 3. implicit options from Getopts object | ||
| 136 | if ( exists $args{warning} || exists $args{critical} ) { | 135 | if ( exists $args{warning} || exists $args{critical} ) { |
| 137 | $self->set_thresholds( | 136 | $self->set_thresholds( |
| 138 | warning => $args{warning}, | 137 | warning => $args{warning}, |
| @@ -142,12 +141,6 @@ sub check_threshold { | |||
| 142 | elsif ( defined $self->threshold ) { | 141 | elsif ( defined $self->threshold ) { |
| 143 | # noop | 142 | # noop |
| 144 | } | 143 | } |
| 145 | elsif ( defined $self->opts ) { | ||
| 146 | $self->set_thresholds( | ||
| 147 | warning => $self->opts->warning, | ||
| 148 | critical => $self->opts->critical, | ||
| 149 | ); | ||
| 150 | } | ||
| 151 | else { | 144 | else { |
| 152 | return UNKNOWN; | 145 | return UNKNOWN; |
| 153 | } | 146 | } |
| @@ -163,6 +156,10 @@ sub add_arg { | |||
| 163 | sub getopts { | 156 | sub getopts { |
| 164 | my $self = shift; | 157 | my $self = shift; |
| 165 | $self->opts->getopts(@_) if $self->_check_for_opts; | 158 | $self->opts->getopts(@_) if $self->_check_for_opts; |
| 159 | $self->set_thresholds( | ||
| 160 | warning => $self->opts->warning, | ||
| 161 | critical => $self->opts->critical, | ||
| 162 | ) if ( defined $self->opts->warning && defined $self->opts->critical ); | ||
| 166 | } | 163 | } |
| 167 | 164 | ||
| 168 | sub _check_for_opts { | 165 | sub _check_for_opts { |
