fix(core): code evaluation tested with values - not permissive (#3237)
This commit is contained in:
parent
f17c9f9341
commit
5764b0457c
|
@ -27,27 +27,18 @@ use warnings;
|
|||
|
||||
sub custom_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
# To exclude some OK
|
||||
if (defined($self->{instance_mode}->{option_results}->{ok_status}) && $self->{instance_mode}->{option_results}->{ok_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{ok_status})) {
|
||||
$status = 'ok';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_status})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_status})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
# To exclude some OK
|
||||
if (defined($self->{instance_mode}->{option_results}->{ok_status}) && $self->{instance_mode}->{option_results}->{ok_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{ok_status})) {
|
||||
$status = 'ok';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_status})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_status})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
|
|
@ -60,26 +60,16 @@ sub custom_hosts_perfdata {
|
|||
sub custom_hosts_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $message;
|
||||
my $status = 'ok';
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_total}) && $self->{instance_mode}->{option_results}->{critical_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_total})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_total}) && $self->{instance_mode}->{option_results}->{warning_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_total})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_total}) && $self->{instance_mode}->{option_results}->{critical_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_total})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_total}) && $self->{instance_mode}->{option_results}->{warning_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_total})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
sub custom_services_calc {
|
||||
|
@ -94,8 +84,8 @@ sub custom_services_calc {
|
|||
|
||||
sub custom_services_output {
|
||||
my ($self, %options) = @_;
|
||||
my $msg = '';
|
||||
$msg .= "[ok:$self->{result_values}->{ok_total}][warning:$self->{result_values}->{warning_total}][critical:$self->{result_values}->{critical_total}][unknown:$self->{result_values}->{unknown_total}]\n";
|
||||
|
||||
my $msg .= "[ok:$self->{result_values}->{ok_total}][warning:$self->{result_values}->{warning_total}][critical:$self->{result_values}->{critical_total}][unknown:$self->{result_values}->{unknown_total}]\n";
|
||||
return $msg
|
||||
}
|
||||
|
||||
|
@ -114,27 +104,16 @@ sub custom_services_perfdata {
|
|||
sub custom_services_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $message;
|
||||
my $status = 'ok';
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_total}) && $self->{instance_mode}->{option_results}->{critical_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_total})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_total}) && $self->{instance_mode}->{option_results}->{warning_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_total})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_total}) && $self->{instance_mode}->{option_results}->{critical_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_total})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_total}) && $self->{instance_mode}->{option_results}->{warning_total} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_total})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
}
|
||||
|
||||
sub custom_groups_calc {
|
||||
|
@ -220,23 +199,14 @@ sub custom_groups_perfdata {
|
|||
|
||||
sub custom_groups_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_groups}) && $self->{instance_mode}->{option_results}->{critical_groups} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_groups})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_groups}) && $self->{instance_mode}->{option_results}->{warning_groups} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_groups})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_groups}) && $self->{instance_mode}->{option_results}->{critical_groups} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_groups})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_groups}) && $self->{instance_mode}->{option_results}->{warning_groups} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_groups})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
@ -245,8 +215,7 @@ sub custom_groups_threshold {
|
|||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
];
|
||||
$self->{maps_counters_type} = [];
|
||||
|
||||
$self->{maps_counters}->{totalservice} = [
|
||||
{ label => 'total-service', threshold => 0, set => {
|
||||
|
|
|
@ -31,31 +31,22 @@ use Digest::MD5 qw(md5_hex);
|
|||
|
||||
sub custom_select_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
our $expand = $self->{result_values}->{expand};
|
||||
if (defined($self->{result_values}->{config}->{critical}) && $self->{result_values}->{config}->{critical} &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{critical})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{result_values}->{config}->{warning}) && $self->{result_values}->{config}->{warning} ne '' &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{warning})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{result_values}->{config}->{unknown}) && $self->{result_values}->{config}->{unknown} &&
|
||||
$self->{instance_mode}->reval($self->{result_values}->{config}->{unknown})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsafe code evaluation: ' . $@);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
our $expand = $self->{result_values}->{expand};
|
||||
if (defined($self->{result_values}->{config}->{critical}) && $self->{result_values}->{config}->{critical} &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{critical})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{result_values}->{config}->{warning}) && $self->{result_values}->{config}->{warning} ne '' &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{warning})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{result_values}->{config}->{unknown}) && $self->{result_values}->{config}->{unknown} &&
|
||||
$self->{instance_mode}->reval($self->{result_values}->{config}->{unknown})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsafe code evaluation: ' . $@);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{result_values}->{last_status} = $status;
|
||||
|
|
|
@ -164,25 +164,15 @@ sub connector_response_status {
|
|||
|
||||
# Check response
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{critical_connector_status}) && $self->{critical_connector_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{critical_connector_status}, values => $self->{result})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{warning_connector_status}) && $self->{warning_connector_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{warning_connector_status}, values => $self->{result})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{unknown_connector_status}) && $self->{unknown_connector_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{unknown_connector_status}, values => $self->{result})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->add_option_msg(short_msg => 'filter connector status issue: ' . $message);
|
||||
$self->{output}->option_exit();
|
||||
if (defined($self->{critical_connector_status}) && $self->{critical_connector_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{critical_connector_status}, values => $self->{result})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{warning_connector_status}) && $self->{warning_connector_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{warning_connector_status}, values => $self->{result})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{unknown_connector_status}) && $self->{unknown_connector_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{unknown_connector_status}, values => $self->{result})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
|
|
|
@ -29,25 +29,16 @@ use centreon::plugins::statefile;
|
|||
|
||||
sub custom_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{dc_critical}++;
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{dc_warning}++;
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{dc_critical}++;
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{dc_warning}++;
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
|
|
@ -29,25 +29,16 @@ use centreon::plugins::statefile;
|
|||
|
||||
sub custom_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{host_critical}++;
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{host_warning}++;
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{host_critical}++;
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}})) {
|
||||
$self->{instance_mode}->{host_warning}++;
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
|
|
@ -75,22 +75,15 @@ sub check {
|
|||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok';
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
|
|
@ -73,22 +73,15 @@ sub check {
|
|||
|
||||
$checked++;
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok';
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
|
|
@ -75,22 +75,15 @@ sub check {
|
|||
)
|
||||
);
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok';
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
|
|
@ -82,22 +82,15 @@ sub check {
|
|||
|
||||
$checked++;
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok'
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
|
|
@ -74,22 +74,15 @@ sub check {
|
|||
centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
|
||||
|
||||
$checked++;
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok';
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
|
|
@ -68,22 +68,15 @@ sub check {
|
|||
|
||||
$checked++;
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok';
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
|
|
@ -70,22 +70,15 @@ sub check {
|
|||
|
||||
$checked++;
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $status = 'ok';
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{critical}, values => $self->{data})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{warning}, values => $self->{data})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
|
@ -96,7 +89,7 @@ sub check {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($checked == 0) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
|
|
|
@ -33,30 +33,21 @@ use Time::HiRes qw(gettimeofday tv_interval);
|
|||
sub custom_select_threshold {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
our $expand = $self->{result_values}->{expand};
|
||||
if (defined($self->{result_values}->{config}->{critical}) && $self->{result_values}->{config}->{critical} &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{critical})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{result_values}->{config}->{warning}) && $self->{result_values}->{config}->{warning} ne '' &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{warning})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{result_values}->{config}->{unknown}) && $self->{result_values}->{config}->{unknown} &&
|
||||
$self->{instance_mode}->reval($self->{result_values}->{config}->{unknown})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsafe code evaluation: ' . $@);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
our $expand = $self->{result_values}->{expand};
|
||||
if (defined($self->{result_values}->{config}->{critical}) && $self->{result_values}->{config}->{critical} &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{critical})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{result_values}->{config}->{warning}) && $self->{result_values}->{config}->{warning} ne '' &&
|
||||
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{warning})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{result_values}->{config}->{unknown}) && $self->{result_values}->{config}->{unknown} &&
|
||||
$self->{instance_mode}->reval($self->{result_values}->{config}->{unknown})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsafe code evaluation: ' . $@);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{result_values}->{last_status} = $status;
|
||||
|
|
|
@ -383,26 +383,15 @@ sub request {
|
|||
|
||||
# Check response
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($options{request}->{critical_status}) && $options{request}->{critical_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $options{request}->{critical_status}, values => { code => $self->{response_code} })) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($options{request}->{warning_status}) && $options{request}->{warning_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $options{request}->{warning_status}, values => { code => $self->{response_code} })) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($options{request}->{unknown_status}) && $options{request}->{unknown_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $options{request}->{unknown_status}, values => { code => $self->{response_code} })) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->add_option_msg(short_msg => 'filter status issue: ' . $message);
|
||||
$self->{output}->option_exit();
|
||||
if (defined($options{request}->{critical_status}) && $options{request}->{critical_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $options{request}->{critical_status}, values => { code => $self->{response_code} })) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($options{request}->{warning_status}) && $options{request}->{warning_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $options{request}->{warning_status}, values => { code => $self->{response_code} })) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($options{request}->{unknown_status}) && $options{request}->{unknown_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $options{request}->{unknown_status}, values => { code => $self->{response_code} })) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
|
|
|
@ -251,27 +251,16 @@ sub request {
|
|||
|
||||
# Check response
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
my $code = $self->{response}->code();
|
||||
if (defined($request_options->{critical_status}) && $request_options->{critical_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $request_options->{critical_status}, values => { code => $code })) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($request_options->{warning_status}) && $request_options->{warning_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $request_options->{warning_status}, values => { code => $code })) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($request_options->{unknown_status}) && $request_options->{unknown_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $request_options->{unknown_status}, values => { code => $code })) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->add_option_msg(short_msg => 'filter status issue: ' . $message);
|
||||
$self->{output}->option_exit();
|
||||
my $code = $self->{response}->code();
|
||||
if (defined($request_options->{critical_status}) && $request_options->{critical_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $request_options->{critical_status}, values => { code => $code })) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($request_options->{warning_status}) && $request_options->{warning_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $request_options->{warning_status}, values => { code => $code })) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($request_options->{unknown_status}) && $request_options->{unknown_status} ne '' &&
|
||||
$self->{output}->test_eval(test => $request_options->{unknown_status}, values => { code => $code })) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
|
|
|
@ -928,9 +928,15 @@ sub test_eval {
|
|||
die 'Unsafe code evaluation: ' . $@;
|
||||
}
|
||||
} elsif (defined($options{values})) {
|
||||
# unsafe code execution. don't need to check if it's safe (with no values)
|
||||
my $values = $options{values};
|
||||
$result = eval "$options{test}";
|
||||
{
|
||||
local $SIG{__WARN__} = sub {}; # ignore
|
||||
|
||||
$result = eval "$options{test}";
|
||||
if ($@) {
|
||||
die 'Code evaluation error: ' . $@;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -30,30 +30,21 @@ our @EXPORT_OK = qw(catalog_status_threshold catalog_status_threshold_ng catalog
|
|||
sub catalog_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
my $label = $self->{label};
|
||||
$label =~ s/-/_/g;
|
||||
if (defined($self->{instance_mode}->{option_results}->{'ok_' . $label}) && $self->{instance_mode}->{option_results}->{'ok_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'ok_' . $label})) {
|
||||
$status = 'ok';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'critical_' . $label}) && $self->{instance_mode}->{option_results}->{'critical_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical_' . $label})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning_' . $label}) && $self->{instance_mode}->{option_results}->{'warning_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning_' . $label})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'unknown_' . $label}) && $self->{instance_mode}->{option_results}->{'unknown_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'unknown_' . $label})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
my $label = $self->{label};
|
||||
$label =~ s/-/_/g;
|
||||
if (defined($self->{instance_mode}->{option_results}->{'ok_' . $label}) && $self->{instance_mode}->{option_results}->{'ok_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'ok_' . $label})) {
|
||||
$status = 'ok';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'critical_' . $label}) && $self->{instance_mode}->{option_results}->{'critical_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical_' . $label})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning_' . $label}) && $self->{instance_mode}->{option_results}->{'warning_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning_' . $label})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'unknown_' . $label}) && $self->{instance_mode}->{option_results}->{'unknown_' . $label} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'unknown_' . $label})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
@ -64,23 +55,15 @@ sub catalog_status_threshold_ng {
|
|||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'unknown-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'unknown-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'unknown-' . $self->{label}})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}})) {
|
||||
$status = 'warning';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{'unknown-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'unknown-' . $self->{label}} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{'unknown-' . $self->{label}})) {
|
||||
$status = 'unknown';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
|
|
@ -761,7 +761,6 @@ sub change_macros {
|
|||
foreach (@{$options{macros}}) {
|
||||
if (defined($self->{option_results}->{$_}) && $self->{option_results}->{$_} ne '') {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$values->{$1}/g;
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{$_});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,7 +257,14 @@ sub eval {
|
|||
}
|
||||
} else {
|
||||
my $values = $self->{result_values};
|
||||
$result = eval "$options{value}";
|
||||
{
|
||||
local $SIG{__WARN__} = sub {}; # ignore
|
||||
|
||||
$result = eval "$options{value}";
|
||||
if ($@) {
|
||||
die 'Code evaluation error: ' . $@;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -43,23 +43,14 @@ sub prefix_metric_output {
|
|||
|
||||
sub custom_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_status})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_status})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_status})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_status})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
|
|
@ -27,6 +27,7 @@ use warnings;
|
|||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'Status : ' . $self->{result_values}->{linkstatus} . ' (oper: ' . $self->{result_values}->{opstatus} . ', ' . 'admin: ' . $self->{result_values}->{admstatus} . ')';
|
||||
if (defined($self->{instance_mode}->{option_results}->{add_duplex_status})) {
|
||||
$msg .= ' (duplex: ' . $self->{result_values}->{duplexstatus} . ')';
|
||||
|
@ -324,15 +325,10 @@ sub add_result_global {
|
|||
admstatus => $self->{oid_adminstatus_mapping}->{$self->{results}->{$self->{oid_adminstatus} . '.' . $_}}
|
||||
};
|
||||
foreach (('global_link_up', 'global_link_down', 'global_admin_up', 'global_admin_down', 'global_oper_up', 'global_oper_down')) {
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { return ; };
|
||||
local $SIG{__DIE__} = sub { return ; };
|
||||
|
||||
if (defined($self->{option_results}->{$_ . '_rule'}) && $self->{option_results}->{$_ . '_rule'} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{$_ . '_rule'}, values => $values)) {
|
||||
$self->{global}->{$_}++;
|
||||
}
|
||||
};
|
||||
if (defined($self->{option_results}->{$_ . '_rule'}) && $self->{option_results}->{$_ . '_rule'} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{$_ . '_rule'}, values => $values)) {
|
||||
$self->{global}->{$_}++;
|
||||
}
|
||||
}
|
||||
$self->{global}->{total_port}++;
|
||||
}
|
||||
|
|
|
@ -33,27 +33,18 @@ use Digest::MD5 qw(md5_hex);
|
|||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_status})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_status})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
if (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{critical_status})) {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
$self->eval(value => $self->{instance_mode}->{option_results}->{warning_status})) {
|
||||
$status = 'warning';
|
||||
}
|
||||
|
||||
$self->{instance_mode}->{last_status} = 0;
|
||||
if (eval "$self->{instance_mode}->{check_status}") {
|
||||
$self->{instance_mode}->{last_status} = 1;
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
$self->{instance_mode}->{last_status} = 0;
|
||||
if (eval "$self->{instance_mode}->{check_status}") {
|
||||
$self->{instance_mode}->{last_status} = 1;
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
@ -1341,15 +1332,10 @@ sub add_result_global {
|
|||
admstatus => $self->{oid_adminstatus_mapping}->{ $self->{results}->{$self->{oid_adminstatus} . '.' . $_} }
|
||||
};
|
||||
foreach (('global_admin_up', 'global_admin_down', 'global_oper_up', 'global_oper_down')) {
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { return ; };
|
||||
local $SIG{__DIE__} = sub { return ; };
|
||||
|
||||
if (defined($self->{option_results}->{$_ . '_rule'}) && $self->{option_results}->{$_ . '_rule'} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{$_ . '_rule'}, values => $values)) {
|
||||
$self->{global}->{$_}++;
|
||||
}
|
||||
};
|
||||
if (defined($self->{option_results}->{$_ . '_rule'}) && $self->{option_results}->{$_ . '_rule'} ne '' &&
|
||||
$self->{output}->test_eval(test => $self->{option_results}->{$_ . '_rule'}, values => $values)) {
|
||||
$self->{global}->{$_}++;
|
||||
}
|
||||
}
|
||||
$self->{global}->{total_port}++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue