add unknown thresholds
This commit is contained in:
parent
3effd636c5
commit
ca4bb673e1
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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' }
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue