File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -131,8 +131,7 @@ sub check_threshold {
131131
132132 # in order of preference, get warning and critical from
133133 # 1. explicit arguments to check_threshold
134- # 2. previously explicitly set threshold object
135- # 3. implicit options from Getopts object
134+ # 2. previously explicitly set threshold object or implicit theshold object created by warning and critical
136135 if ( exists $args {warning } || exists $args {critical } ) {
137136 $self -> set_thresholds(
138137 warning => $args {warning },
@@ -142,12 +141,6 @@ sub check_threshold {
142141 elsif ( defined $self -> threshold ) {
143142 # noop
144143 }
145- elsif ( defined $self -> opts ) {
146- $self -> set_thresholds(
147- warning => $self -> opts-> warning,
148- critical => $self -> opts-> critical,
149- );
150- }
151144 else {
152145 return UNKNOWN;
153146 }
@@ -163,6 +156,10 @@ sub add_arg {
163156sub getopts {
164157 my $self = shift ;
165158 $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 );
166163}
167164
168165sub _check_for_opts {
You can’t perform that action at this time.
0 commit comments