diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index 23c3ef946..61389ddc6 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -203,7 +203,7 @@ sub check_options { push @$change_macros_opt, 'unknown-' . $_->{label}, 'warning-' . $_->{label}, 'critical-' . $_->{label} if (defined($_->{type}) && $_->{type} == 2); $_->{obj}->{instance_mode} = $self; - $_->{obj}->init(option_results => $self->{option_results}); + $_->{obj}->init(option_results => $self->{option_results}) if (!defined($_->{type}) || $_->{type} != 2); } } diff --git a/centreon/plugins/values.pm b/centreon/plugins/values.pm index 741774561..c9b086bb9 100644 --- a/centreon/plugins/values.pm +++ b/centreon/plugins/values.pm @@ -61,9 +61,14 @@ sub new { sub init { my ($self, %options) = @_; + my $unkn = defined($self->{threshold_unkn}) ? $self->{threshold_unkn} : 'unknown-' . $self->{thlabel}; my $warn = defined($self->{threshold_warn}) ? $self->{threshold_warn} : 'warning-' . $self->{thlabel}; my $crit = defined($self->{threshold_crit}) ? $self->{threshold_crit} : 'critical-' . $self->{thlabel}; - + + if (($self->{perfdata}->threshold_validate(label => $unkn, value => $options{option_results}->{$unkn})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong $unkn threshold '" . $options{option_results}->{$unkn} . "'."); + $self->{output}->option_exit(); + } if (($self->{perfdata}->threshold_validate(label => $warn, value => $options{option_results}->{$warn})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong $warn threshold '" . $options{option_results}->{$warn} . "'."); $self->{output}->option_exit(); @@ -107,7 +112,8 @@ sub threshold_check { if (defined($self->{closure_custom_threshold_check})) { return &{$self->{closure_custom_threshold_check}}($self, %options); } - + + my $unkn = defined($self->{threshold_unkn}) ? $self->{threshold_unkn} : 'unknown-' . $self->{thlabel}; my $warn = defined($self->{threshold_warn}) ? $self->{threshold_warn} : 'warning-' . $self->{thlabel}; my $crit = defined($self->{threshold_crit}) ? $self->{threshold_crit} : 'critical-' . $self->{thlabel}; @@ -121,7 +127,8 @@ sub threshold_check { return $self->{perfdata}->threshold_check( value => $value, threshold => [ { label => $crit, exit_litteral => 'critical' }, - { label => $warn, exit_litteral => 'warning' } + { label => $warn, exit_litteral => 'warning' }, + { label => $unkn, exit_litteral => 'unknown' } ] ); } diff --git a/network/f5/bigip/snmp/mode/trunks.pm b/network/f5/bigip/snmp/mode/trunks.pm index 2b7224437..305556def 100644 --- a/network/f5/bigip/snmp/mode/trunks.pm +++ b/network/f5/bigip/snmp/mode/trunks.pm @@ -222,7 +222,7 @@ sub set_counters { ] } ]; - + $self->{maps_counters}->{trunk_global} = [ { label => 'status', type => 2, critical_default => '%{status} =~ /uninitialized|down/', @@ -314,25 +314,15 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - 'units-traffic:s' => { name => 'units_traffic', default => '%' }, - 'speed:s' => { name => 'speed' }, - 'add-interfaces' => { name => 'add_interfaces' } + 'filter-name:s' => { name => 'filter_name' }, + 'units-traffic:s' => { name => 'units_traffic', default => '%' }, + 'speed:s' => { name => 'speed' }, + 'add-interfaces' => { name => 'add_interfaces' } }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => [ - 'unknown_status', 'warning_status', 'critical_status', - 'unknown_interface_status', 'warning_interface_status', 'critical_interface_status' - ]); -} - my $map_trunk_status = { 0 => 'up', 1 => 'down',