+ update: refactoring with hardware template class
This commit is contained in:
parent
49e191dc66
commit
46666073ae
|
@ -198,7 +198,7 @@ sub check_options {
|
|||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->call_object_callback(method_name => $self->{cb_threshold_numeric_check_section_option},
|
||||
section => $section, option_value => $val);
|
||||
section => $section, option_name => $option, option_value => $val);
|
||||
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
|
@ -215,12 +215,9 @@ sub check_options {
|
|||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub load_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{loaded} = 0;
|
||||
$self->call_object_callback(method_name => $self->{cb_hook1},
|
||||
%options);
|
||||
|
||||
foreach (@{$self->{components_module}}) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = $self->{components_path} . "::$_";
|
||||
|
@ -233,15 +230,10 @@ sub run {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($self->{loaded} == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->call_object_callback(method_name => $self->{cb_hook2},
|
||||
%options);
|
||||
|
||||
}
|
||||
|
||||
sub exec_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (@{$self->{components_module}}) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
|
@ -250,9 +242,23 @@ sub run {
|
|||
$func->($self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{loaded} = 0;
|
||||
$self->call_object_callback(method_name => $self->{cb_hook1}, %options);
|
||||
|
||||
$self->load_components(%options);
|
||||
if ($self->{loaded} == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->call_object_callback(method_name => $self->{cb_hook3},
|
||||
%options);
|
||||
$self->call_object_callback(method_name => $self->{cb_hook2}, %options);
|
||||
$self->exec_components(%options);
|
||||
$self->call_object_callback(method_name => $self->{cb_hook3}, %options);
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
|
|
|
@ -25,9 +25,9 @@ use warnings;
|
|||
use hardware::pdu::raritan::snmp::mode::components::resources qw($mapping %raritan_type %map_type);
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self, %options) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $mapping->{$options{type} . '_label'}->{Label}->{oid} },
|
||||
push @{$self->{request}}, { oid => $mapping->{$options{type} . '_label'}->{Label}->{oid} },
|
||||
{ oid => $mapping->{$options{type}}->{Unit}->{oid} },
|
||||
{ oid => $mapping->{$options{type}}->{Decimal}->{oid} },
|
||||
{ oid => $mapping->{$options{type}}->{EnabledThresholds}->{oid} },
|
||||
|
|
|
@ -20,210 +20,73 @@
|
|||
|
||||
package hardware::pdu::raritan::snmp::mode::inletsensors;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type);
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = $thresholds;
|
||||
|
||||
$self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components';
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
|
||||
}
|
||||
|
||||
sub check_numeric_section_option {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($raritan_type{$options{section}})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub load_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mod_name = $self->{components_path} . "::sensor";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->($self, type => 'inlet');
|
||||
|
||||
$self->{loaded} = 1;
|
||||
}
|
||||
|
||||
sub exec_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mod_name = $self->{components_path} . "::sensor";
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self, component => $self->{option_results}->{component}, type => 'inlet');
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter:s@" => { name => 'filter' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
{
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{filter} = [];
|
||||
foreach my $val (@{$self->{option_results}->{filter}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
if (scalar(@values) < 3) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $status, $filter);
|
||||
if (scalar(@values) == 3) {
|
||||
($section, $status, $filter) = @values;
|
||||
$instance = '.*';
|
||||
} else {
|
||||
($section, $instance, $status, $filter) = @values;
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance };
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $value) = ($1, $2, $3);
|
||||
if (!defined($raritan_type{$section})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $snmp_request = [];
|
||||
|
||||
my $mod_name = "hardware::pdu::raritan::snmp::mode::components::sensor";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->(type => 'inlet', request => $snmp_request);
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request, return_type => 1);
|
||||
|
||||
$func = $mod_name->can('check');
|
||||
$func->($self, component => $self->{option_results}->{component}, type => 'inlet');
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s sensors are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No sensors are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_filter {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (@{$self->{filter}}) {
|
||||
if ($options{section} =~ /$_->{filter}/) {
|
||||
if (!defined($options{instance}) && !defined($_->{instance})) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{instance}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i &&
|
||||
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $label = defined($options{label}) ? $options{label} : $options{section};
|
||||
foreach (@{$thresholds->{$label}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -20,210 +20,73 @@
|
|||
|
||||
package hardware::pdu::raritan::snmp::mode::ocprotsensors;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type);
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = $thresholds;
|
||||
|
||||
$self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components';
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
|
||||
}
|
||||
|
||||
sub check_numeric_section_option {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($raritan_type{$options{section}})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub load_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mod_name = $self->{components_path} . "::sensor";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->($self, type => 'ocprot');
|
||||
|
||||
$self->{loaded} = 1;
|
||||
}
|
||||
|
||||
sub exec_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mod_name = $self->{components_path} . "::sensor";
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self, component => $self->{option_results}->{component}, type => 'ocprot');
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter:s@" => { name => 'filter' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
{
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{filter} = [];
|
||||
foreach my $val (@{$self->{option_results}->{filter}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
if (scalar(@values) < 3) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $status, $filter);
|
||||
if (scalar(@values) == 3) {
|
||||
($section, $status, $filter) = @values;
|
||||
$instance = '.*';
|
||||
} else {
|
||||
($section, $instance, $status, $filter) = @values;
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance };
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $value) = ($1, $2, $3);
|
||||
if (!defined($raritan_type{$section})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $snmp_request = [];
|
||||
|
||||
my $mod_name = "hardware::pdu::raritan::snmp::mode::components::sensor";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->(type => 'ocprot', request => $snmp_request);
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request, return_type => 1);
|
||||
|
||||
$func = $mod_name->can('check');
|
||||
$func->($self, component => $self->{option_results}->{component}, type => 'ocprot');
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s sensors are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No sensors are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_filter {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (@{$self->{filter}}) {
|
||||
if ($options{section} =~ /$_->{filter}/) {
|
||||
if (!defined($options{instance}) && !defined($_->{instance})) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{instance}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i &&
|
||||
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $label = defined($options{label}) ? $options{label} : $options{section};
|
||||
foreach (@{$thresholds->{$label}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -20,12 +20,60 @@
|
|||
|
||||
package hardware::pdu::raritan::snmp::mode::outletsensors;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::pdu::raritan::snmp::mode::components::resources qw($thresholds %raritan_type);
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cb_threshold_numeric_check_section_option} = 'check_numeric_section_option';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = $thresholds;
|
||||
|
||||
$self->{components_path} = 'hardware::pdu::raritan::snmp::mode::components';
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
|
||||
}
|
||||
|
||||
sub check_numeric_section_option {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($raritan_type{$options{section}})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $options{option_name} option '" . $options{option_value} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub load_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mod_name = $self->{components_path} . "::sensor";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->($self, type => 'outlet');
|
||||
|
||||
$self->{loaded} = 1;
|
||||
}
|
||||
|
||||
sub exec_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mod_name = $self->{components_path} . "::sensor";
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self, component => $self->{option_results}->{component}, type => 'outlet');
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -33,197 +81,12 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter:s@" => { name => 'filter' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
{
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{filter} = [];
|
||||
foreach my $val (@{$self->{option_results}->{filter}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
push @{$self->{filter}}, { filter => $values[0], instance => $values[1] };
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
my @values = split (/,/, $val);
|
||||
if (scalar(@values) < 3) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $status, $filter);
|
||||
if (scalar(@values) == 3) {
|
||||
($section, $status, $filter) = @values;
|
||||
$instance = '.*';
|
||||
} else {
|
||||
($section, $instance, $status, $filter) = @values;
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status, instance => $instance };
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
next if (!defined($val) || $val eq '');
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $instance, $value) = ($1, $2, $3);
|
||||
if (!defined($raritan_type{$section})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, instance => $instance };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $snmp_request = [];
|
||||
|
||||
my $mod_name = "hardware::pdu::raritan::snmp::mode::components::sensor";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->(type => 'outlet', request => $snmp_request);
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request, return_type => 1);
|
||||
|
||||
$func = $mod_name->can('check');
|
||||
$func->($self, component => $self->{option_results}->{component}, type => 'outlet');
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s sensors are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No sensors are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_filter {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (@{$self->{filter}}) {
|
||||
if ($options{section} =~ /$_->{filter}/) {
|
||||
if (!defined($options{instance}) && !defined($_->{instance})) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
} elsif (defined($options{instance}) && $options{instance} =~ /$_->{instance}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{instance}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i &&
|
||||
(!defined($options{instance}) || $options{instance} =~ /$_->{instance}/)) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $label = defined($options{label}) ? $options{label} : $options{section};
|
||||
foreach (@{$thresholds->{$label}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -48,7 +48,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking " . $options{component});
|
||||
$self->{components}->{$options{component}} = {name => $options{component}, total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => $options{component}));
|
||||
return if ($self->check_filter(section => $options{component}));
|
||||
|
||||
my $mapping = {
|
||||
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_default_status },
|
||||
|
@ -58,7 +58,7 @@ sub check {
|
|||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
|
||||
|
||||
next if (!defined($result->{EntityExtErrorStatus}));
|
||||
next if ($self->check_exclude(section => $options{component}, instance => $instance));
|
||||
next if ($self->check_filter(section => $options{component}, instance => $instance));
|
||||
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
|
||||
$self->absent_problem(section => $options{component}, instance => $instance);
|
||||
next;
|
||||
|
|
|
@ -36,7 +36,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'fan'));
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
my $mapping = {
|
||||
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_fan_status },
|
||||
|
@ -46,7 +46,7 @@ sub check {
|
|||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
|
||||
|
||||
next if (!defined($result->{EntityExtErrorStatus}));
|
||||
next if ($self->check_exclude(section => 'fan', instance => $instance));
|
||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
|
||||
$self->absent_problem(section => 'fan', instance => $instance);
|
||||
next;
|
||||
|
|
|
@ -36,7 +36,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
my $mapping = {
|
||||
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_psu_status },
|
||||
|
@ -46,7 +46,7 @@ sub check {
|
|||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance);
|
||||
|
||||
next if (!defined($result->{EntityExtErrorStatus}));
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
|
||||
$self->absent_problem(section => 'psu', instance => $instance);
|
||||
next;
|
||||
|
|
|
@ -36,7 +36,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking sensors");
|
||||
$self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'sensor'));
|
||||
return if ($self->check_filter(section => 'sensor'));
|
||||
|
||||
my $mapping = {
|
||||
EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_sensor_status },
|
||||
|
@ -59,7 +59,7 @@ sub check {
|
|||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
|
||||
|
||||
next if (!defined($result->{EntityExtErrorStatus}));
|
||||
next if ($self->check_exclude(section => 'sensor', instance => $instance));
|
||||
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
||||
if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) {
|
||||
$self->absent_problem(section => 'sensor', instance => $instance);
|
||||
next;
|
||||
|
|
|
@ -20,89 +20,138 @@
|
|||
|
||||
package network::h3c::snmp::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::statefile;
|
||||
|
||||
my $thresholds = {
|
||||
psu => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['psuError', 'CRITICAL'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
fan => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['fanError', 'CRITICAL'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
sensor => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['sensorError', 'CRITICAL'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
other => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
unknown => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
chassis => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
backplane => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
container => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
module => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
port => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
stack => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
cpu => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
};
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$';
|
||||
|
||||
$self->{cb_hook1} = 'init_cache';
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
psu => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['psuError', 'CRITICAL'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
fan => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['fanError', 'CRITICAL'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
sensor => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['sensorError', 'CRITICAL'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
other => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
unknown => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
chassis => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
backplane => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
container => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
module => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
port => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
stack => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
cpu => [
|
||||
['notSupported', 'WARNING'],
|
||||
['normal', 'OK'],
|
||||
['entityAbsent', 'OK'],
|
||||
['hardwareFaulty', 'CRITICAL'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'network::h3c::snmp::mode::components';
|
||||
$self->{components_module} = ['fan', 'psu', 'slot', 'temperature'];
|
||||
|
||||
$self->{mapping_name} = {
|
||||
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
||||
7 => 'fan', 8 => 'sensor', 9 => 'module', 10 => 'port', 11 => 'stack', 12 => 'cpu'
|
||||
};
|
||||
$self->{mapping_component} = {
|
||||
1 => 'default', 2 => 'default', 3 => 'default', 4 => 'default', 5 => 'default', 6 => 'psu',
|
||||
7 => 'fan', 8 => 'sensor', 9 => 'default', 10 => 'default', 11 => 'default', 12 => 'default'
|
||||
};
|
||||
}
|
||||
|
||||
my $oid_hh3cEntityExtStateEntry = '.1.3.6.1.4.1.25506.2.6.1.1.1.1';
|
||||
my $oid_h3cEntityExtStateEntry = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1';
|
||||
my $oid_h3cEntityExtErrorStatus = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1.19';
|
||||
my $oid_hh3cEntityExtErrorStatus = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.19';
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
$self->write_cache();
|
||||
|
||||
$self->{branch} = $oid_hh3cEntityExtStateEntry;
|
||||
if (defined($self->{results}->{$oid_h3cEntityExtErrorStatus}) && scalar(keys %{$self->{results}->{$oid_h3cEntityExtErrorStatus}}) > 0) {
|
||||
$self->{branch} = $oid_h3cEntityExtStateEntry;
|
||||
}
|
||||
}
|
||||
|
||||
sub init_cache {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{request} = [
|
||||
{ oid => $oid_h3cEntityExtErrorStatus },
|
||||
{ oid => $oid_hh3cEntityExtErrorStatus },
|
||||
];
|
||||
$self->check_cache(%options);
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -111,21 +160,11 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"absent-problem:s" => { name => 'absent' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
{
|
||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -133,54 +172,6 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ($1, $2, $3);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $regexp, $value) = ($1, $2, $3);
|
||||
if ($section !~ /^(temperature)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: temperature).");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp };
|
||||
}
|
||||
}
|
||||
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
|
||||
|
@ -193,8 +184,8 @@ my $oid_entPhysicalName = '.1.3.6.1.2.1.47.1.1.1.1.7';
|
|||
sub check_cache {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
$self->{hostname} = $options{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $options{snmp}->get_port();
|
||||
|
||||
# init cache file
|
||||
$self->{write_cache} = 0;
|
||||
|
@ -202,7 +193,7 @@ sub check_cache {
|
|||
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
|
||||
if ($has_cache_file == 0 ||
|
||||
!defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) {
|
||||
push @{$self->{snmp_request}}, { oid => $oid_entPhysicalEntry, start => $oid_entPhysicalDescr, end => $oid_entPhysicalName };
|
||||
push @{$self->{request}}, { oid => $oid_entPhysicalEntry, start => $oid_entPhysicalDescr, end => $oid_entPhysicalName };
|
||||
$self->{write_cache} = 1;
|
||||
}
|
||||
}
|
||||
|
@ -250,159 +241,29 @@ sub get_instance_class {
|
|||
return @instances;
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub load_components {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_hh3cEntityExtStateEntry = '.1.3.6.1.4.1.25506.2.6.1.1.1.1';
|
||||
my $oid_h3cEntityExtStateEntry = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1';
|
||||
my $oid_h3cEntityExtErrorStatus = '.1.3.6.1.4.1.2011.10.2.6.1.1.1.1.19';
|
||||
my $oid_hh3cEntityExtErrorStatus = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.19';
|
||||
$self->{snmp_request} = [
|
||||
{ oid => $oid_h3cEntityExtErrorStatus },
|
||||
{ oid => $oid_hh3cEntityExtErrorStatus },
|
||||
];
|
||||
$self->check_cache();
|
||||
|
||||
my %mapping_name = (
|
||||
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
||||
7 => 'fan', 8 => 'sensor', 9 => 'module', 10 => 'port', 11 => 'stack', 12 => 'cpu'
|
||||
);
|
||||
my %mapping_component = (
|
||||
1 => 'default', 2 => 'default', 3 => 'default', 4 => 'default', 5 => 'default', 6 => 'psu',
|
||||
7 => 'fan', 8 => 'sensor', 9 => 'default', 10 => 'default', 11 => 'default', 12 => 'default'
|
||||
);
|
||||
|
||||
my $component = 0;
|
||||
foreach (keys %mapping_name) {
|
||||
if ($mapping_name{$_} =~ /$self->{option_results}->{component}/) {
|
||||
my $mod_name = "network::h3c::snmp::mode::components::" . $mapping_component{$_};
|
||||
foreach (keys %{$self->{mapping_name}}) {
|
||||
if ($self->{mapping_name}->{$_} =~ /$self->{option_results}->{component}/) {
|
||||
my $mod_name = $self->{components_path} . "::" . $self->{mapping_component}->{$_};
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
$component = 1;
|
||||
$self->{loaded} = 1;
|
||||
}
|
||||
}
|
||||
if ($component == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub exec_components {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{snmp_request});
|
||||
$self->write_cache();
|
||||
|
||||
$self->{branch} = $oid_hh3cEntityExtStateEntry;
|
||||
if (defined($self->{results}->{$oid_h3cEntityExtErrorStatus}) && scalar(keys %{$self->{results}->{$oid_h3cEntityExtErrorStatus}}) > 0) {
|
||||
$self->{branch} = $oid_h3cEntityExtStateEntry;
|
||||
}
|
||||
|
||||
foreach (keys %mapping_name) {
|
||||
if ($mapping_name{$_} =~ /$self->{option_results}->{component}/) {
|
||||
my $mod_name = "network::h3c::snmp::mode::components::" . $mapping_component{$_};
|
||||
foreach (keys %{$self->{mapping_name}}) {
|
||||
if ($self->{mapping_name}->{$_} =~ /$self->{option_results}->{component}/) {
|
||||
my $mod_name = $self->{components_path} . "::" . $self->{mapping_component}->{$_};
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self, component => $mapping_name{$_}, component_class => $_);
|
||||
$func->($self, component => $self->{mapping_name}->{$_}, component_class => $_);
|
||||
}
|
||||
}
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub absent_problem {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{absent}) &&
|
||||
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Component '%s' instance '%s' is not present",
|
||||
$options{section}, $options{instance}));
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{regexp}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -421,10 +282,10 @@ Which component to check (Default: '.*').
|
|||
Can be: 'fan', 'psu', 'other', 'unknown', 'sensor', 'chassis', 'backplane',
|
||||
'container', 'module', 'port', 'stack', 'cpu'.
|
||||
|
||||
=item B<--exclude>
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=fan)
|
||||
Can also exclude specific instance: --exclude=fan#101#
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
|
||||
Can also exclude specific instance: --filter=fan,101
|
||||
|
||||
=item B<--absent-problem>
|
||||
|
||||
|
@ -438,7 +299,7 @@ If total (with skipped) is 0. (Default: 'critical' returns).
|
|||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,status,regexp)
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)'
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@ my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3';
|
|||
my $oid_enclContactState = '.1.3.6.1.4.1.789.1.21.1.2.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_enclContactState };
|
||||
push @{$self->{request}}, { oid => $oid_enclContactState };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -47,13 +47,13 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking communications");
|
||||
$self->{components}->{communication} = {name => 'communications', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'communication'));
|
||||
return if ($self->check_filter(section => 'communication'));
|
||||
|
||||
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
|
||||
my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i};
|
||||
my $com_state = $map_com_states{$self->{results}->{$oid_enclContactState}->{$oid_enclContactState . '.' . $i}};
|
||||
|
||||
next if ($self->check_exclude(section => 'communication', instance => $shelf_addr));
|
||||
next if ($self->check_filter(section => 'communication', instance => $shelf_addr));
|
||||
|
||||
$self->{components}->{communication}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Shelve '%s' communication state is '%s'",
|
||||
|
|
|
@ -30,10 +30,9 @@ my $oid_enclElectronicsPresent = '.1.3.6.1.4.1.789.1.21.1.2.1.31';
|
|||
my $oid_enclElectronicsFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.33';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_enclElectronicsPresent };
|
||||
push @{$options{request}}, { oid => $oid_enclElectronicsFailed };
|
||||
push @{$self->{request}}, { oid => $oid_enclElectronicsPresent }, { oid => $oid_enclElectronicsFailed };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -41,7 +40,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking electronics");
|
||||
$self->{components}->{electronics} = {name => 'electronics', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'electronics'));
|
||||
return if ($self->check_filter(section => 'electronics'));
|
||||
|
||||
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
|
||||
my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i};
|
||||
|
@ -52,7 +51,7 @@ sub check {
|
|||
$num = centreon::plugins::misc::trim($num);
|
||||
next if ($num !~ /[0-9]/);
|
||||
|
||||
next if ($self->check_exclude(section => 'electronics', instance => $shelf_addr . '.' . $num));
|
||||
next if ($self->check_filter(section => 'electronics', instance => $shelf_addr . '.' . $num));
|
||||
$self->{components}->{electronics}->{total}++;
|
||||
|
||||
my $status = 'ok';
|
||||
|
|
|
@ -31,11 +31,10 @@ my $oid_enclFansFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.18';
|
|||
my $oid_enclFansSpeed = '.1.3.6.1.4.1.789.1.21.1.2.1.62';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_enclFansPresent };
|
||||
push @{$options{request}}, { oid => $oid_enclFansFailed };
|
||||
push @{$options{request}}, { oid => $oid_enclFansSpeed };
|
||||
push @{$self->{request}}, { oid => $oid_enclFansPresent }, { oid => $oid_enclFansFailed },
|
||||
{ oid => $oid_enclFansSpeed };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -43,7 +42,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'fan'));
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
|
||||
my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i};
|
||||
|
@ -56,7 +55,7 @@ sub check {
|
|||
next if ($num !~ /[0-9]/);
|
||||
my $current_value = (defined($current_speed[$num - 1]) && $current_speed[$num - 1] =~ /(^|\s)([0-9]+)/) ? $2 : '';
|
||||
|
||||
next if ($self->check_exclude(section => 'fan', instance => $shelf_addr . '.' . $num));
|
||||
next if ($self->check_filter(section => 'fan', instance => $shelf_addr . '.' . $num));
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
my $status = 'ok';
|
||||
|
|
|
@ -30,10 +30,9 @@ my $oid_enclPowerSuppliesPresent = '.1.3.6.1.4.1.789.1.21.1.2.1.13';
|
|||
my $oid_enclPowerSuppliesFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.15';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_enclPowerSuppliesPresent };
|
||||
push @{$options{request}}, { oid => $oid_enclPowerSuppliesFailed };
|
||||
push @{$self->{request}}, { oid => $oid_enclPowerSuppliesPresent }, { oid => $oid_enclPowerSuppliesFailed };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -41,7 +40,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
|
||||
my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i};
|
||||
|
@ -52,7 +51,7 @@ sub check {
|
|||
$num = centreon::plugins::misc::trim($num);
|
||||
next if ($num !~ /[0-9]/);
|
||||
|
||||
next if ($self->check_exclude(section => 'psu', instance => $shelf_addr . '.' . $num));
|
||||
next if ($self->check_filter(section => 'psu', instance => $shelf_addr . '.' . $num));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
my $status = 'ok';
|
||||
|
|
|
@ -38,9 +38,9 @@ my %map_raid_states = (
|
|||
my $oid_raidPStatus = '.1.3.6.1.4.1.789.1.6.10.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_raidPStatus };
|
||||
push @{$self->{request}}, { oid => $oid_raidPStatus };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -48,14 +48,14 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking raids");
|
||||
$self->{components}->{raid} = {name => 'raids', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'raid'));
|
||||
return if ($self->check_filter(section => 'raid'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidPStatus}})) {
|
||||
$oid =~ /^$oid_raidPStatus\.(.*)$/;
|
||||
my $instance = $1;
|
||||
my $raid_state = $map_raid_states{$self->{results}->{$oid_raidPStatus}->{$oid}};
|
||||
|
||||
next if ($self->check_exclude(section => 'raid', instance => $instance));
|
||||
next if ($self->check_filter(section => 'raid', instance => $instance));
|
||||
|
||||
$self->{components}->{raid}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Raid '%s' state is '%s'",
|
||||
|
|
|
@ -53,9 +53,9 @@ my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3';
|
|||
my $oid_enclEntry = '.1.3.6.1.4.1.789.1.21.1.2.1';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_enclEntry, begin => $mapping->{enclTempSensorsPresent}->{oid}, end => $mapping->{enclTempSensorsUnderTempWarnThr}->{oid} };
|
||||
push @{$self->{request}}, { oid => $oid_enclEntry, begin => $mapping->{enclTempSensorsPresent}->{oid}, end => $mapping->{enclTempSensorsUnderTempWarnThr}->{oid} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -63,7 +63,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'temperature'));
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_enclEntry}, instance => $i);
|
||||
|
@ -90,7 +90,7 @@ sub check {
|
|||
$current_temp[$num - 1] =~ /(-*[0-9]+)C/;
|
||||
my $current_value = $1;
|
||||
|
||||
next if ($self->check_exclude(section => 'temperature', instance => $shelf_addr . '.' . $num));
|
||||
next if ($self->check_filter(section => 'temperature', instance => $shelf_addr . '.' . $num));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
my $status = 'ok';
|
||||
|
|
|
@ -53,9 +53,9 @@ my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3';
|
|||
my $oid_enclTable = '.1.3.6.1.4.1.789.1.21.1.2';
|
||||
|
||||
sub load {
|
||||
my (%options) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$options{request}}, { oid => $oid_enclTable, begin => $mapping->{enclVoltSensorsPresent}->{oid}, end => $mapping->{enclVoltSensorsUnderVoltWarnThr}->{oid} };
|
||||
push @{$self->{request}}, { oid => $oid_enclTable, begin => $mapping->{enclVoltSensorsPresent}->{oid}, end => $mapping->{enclVoltSensorsUnderVoltWarnThr}->{oid} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -63,7 +63,7 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'voltage'));
|
||||
return if ($self->check_filter(section => 'voltage'));
|
||||
|
||||
for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_enclTable}, instance => $i);
|
||||
|
@ -86,7 +86,7 @@ sub check {
|
|||
my $co_thr = (defined($crit_over_thr[$num - 1]) && $crit_over_thr[$num - 1] =~ /(^|\s)(-*[0-9]+)/) ? $2 : '';
|
||||
my $current_value = ($current_volt[$num - 1] =~ /(^|\s)(-*[0-9]+)/) ? $2 : '';
|
||||
|
||||
next if ($self->check_exclude(section => 'voltage', instance => $shelf_addr . '.' . $num));
|
||||
next if ($self->check_filter(section => 'voltage', instance => $shelf_addr . '.' . $num));
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
|
||||
my $status = 'ok';
|
||||
|
|
|
@ -20,61 +20,81 @@
|
|||
|
||||
package storage::netapp::snmp::mode::shelf;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my $thresholds = {
|
||||
communication => [
|
||||
['initializing', 'WARNING'],
|
||||
['transitioning', 'WARNING'],
|
||||
['inactive', 'CRITICAL'],
|
||||
['reconfiguring', 'WARNING'],
|
||||
['nonexistent', 'CRITICAL'],
|
||||
['active', 'OK'],
|
||||
],
|
||||
raid => [
|
||||
['initializing', 'WARNING'],
|
||||
['reconstructionInProgress', 'WARNING'],
|
||||
['parityVerificationInProgress', 'OK'],
|
||||
['scrubbingInProgress', 'OK'],
|
||||
['prefailed', 'CRITICAL'],
|
||||
['failed', 'CRITICAL'],
|
||||
['active', 'OK'],
|
||||
],
|
||||
fan => [
|
||||
['failed', 'CRITICAL'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
psu => [
|
||||
['failed', 'CRITICAL'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
electronics => [
|
||||
['failed', 'CRITICAL'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
voltage => [
|
||||
['under critical threshold', 'CRITICAL'],
|
||||
['under warning threshold', 'WARNING'],
|
||||
['over critical threshold', 'CRITICAL'],
|
||||
['over warning threshold', 'WARNING'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
temperature => [
|
||||
['under critical threshold', 'CRITICAL'],
|
||||
['under warning threshold', 'WARNING'],
|
||||
['over critical threshold', 'CRITICAL'],
|
||||
['over warning threshold', 'WARNING'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
};
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(voltage|temperature|fan)$';
|
||||
|
||||
$self->{cb_hook1} = 'init_shelf';
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
communication => [
|
||||
['initializing', 'WARNING'],
|
||||
['transitioning', 'WARNING'],
|
||||
['inactive', 'CRITICAL'],
|
||||
['reconfiguring', 'WARNING'],
|
||||
['nonexistent', 'CRITICAL'],
|
||||
['active', 'OK'],
|
||||
],
|
||||
raid => [
|
||||
['initializing', 'WARNING'],
|
||||
['reconstructionInProgress', 'WARNING'],
|
||||
['parityVerificationInProgress', 'OK'],
|
||||
['scrubbingInProgress', 'OK'],
|
||||
['prefailed', 'CRITICAL'],
|
||||
['failed', 'CRITICAL'],
|
||||
['active', 'OK'],
|
||||
],
|
||||
fan => [
|
||||
['failed', 'CRITICAL'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
psu => [
|
||||
['failed', 'CRITICAL'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
electronics => [
|
||||
['failed', 'CRITICAL'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
voltage => [
|
||||
['under critical threshold', 'CRITICAL'],
|
||||
['under warning threshold', 'WARNING'],
|
||||
['over critical threshold', 'CRITICAL'],
|
||||
['over warning threshold', 'WARNING'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
temperature => [
|
||||
['under critical threshold', 'CRITICAL'],
|
||||
['under warning threshold', 'WARNING'],
|
||||
['over critical threshold', 'CRITICAL'],
|
||||
['over warning threshold', 'WARNING'],
|
||||
['ok', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::netapp::snmp::mode::components';
|
||||
$self->{components_module} = ['communication', 'psu', 'fan', 'temperature', 'voltage', 'electronics', 'raid'];
|
||||
}
|
||||
|
||||
my $oid_enclNumber = '.1.3.6.1.4.1.789.1.21.1.1';
|
||||
my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3';
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
$self->{number_shelf} = defined($self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'}) ? $self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'} : -1;
|
||||
$self->{shelf_addr} = $self->{results}->{$oid_enclChannelShelfAddr};
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -83,207 +103,15 @@ sub new {
|
|||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"component:s" => { name => 'component', default => '.*' },
|
||||
"absent-problem:s" => { name => 'absent' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"warning:s@" => { name => 'warning' },
|
||||
"critical:s@" => { name => 'critical' },
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ($1, $2, $3);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
|
||||
$self->{numeric_threshold} = {};
|
||||
foreach my $option (('warning', 'critical')) {
|
||||
foreach my $val (@{$self->{option_results}->{$option}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $regexp, $value) = ($1, $2, $3);
|
||||
if ($section !~ /(voltage|temperature|fan)/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option option '" . $val . "' (type must be: fan, voltage or temperature).");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $position = 0;
|
||||
if (defined($self->{numeric_threshold}->{$section})) {
|
||||
$position = scalar(@{$self->{numeric_threshold}->{$section}});
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => $option . '-' . $section . '-' . $position, value => $value)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong $option threshold '" . $value . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{numeric_threshold}->{$section} = [] if (!defined($self->{numeric_threshold}->{$section}));
|
||||
push @{$self->{numeric_threshold}->{$section}}, { label => $option . '-' . $section . '-' . $position, threshold => $option, regexp => $regexp };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $snmp_request = [];
|
||||
my @components = ('communication', 'psu', 'fan', 'temperature', 'voltage', 'electronics', 'raid');
|
||||
foreach (@components) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = "storage::netapp::snmp::mode::components::$_";
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
||||
error_msg => "Cannot load module '$mod_name'.");
|
||||
my $func = $mod_name->can('load');
|
||||
$func->(request => $snmp_request);
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(@{$snmp_request}) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
push @{$snmp_request}, ({ oid => $oid_enclNumber }, { oid => $oid_enclChannelShelfAddr });
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $snmp_request);
|
||||
$self->{number_shelf} = defined($self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'}) ? $self->{results}->{$oid_enclNumber}->{$oid_enclNumber . '.0'} : -1;
|
||||
$self->{shelf_addr} = $self->{results}->{$oid_enclChannelShelfAddr};
|
||||
|
||||
foreach (@components) {
|
||||
if (/$self->{option_results}->{component}/) {
|
||||
my $mod_name = "storage::netapp::snmp::mode::components::$_";
|
||||
my $func = $mod_name->can('check');
|
||||
$func->($self);
|
||||
}
|
||||
}
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
sub init_shelf {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub absent_problem {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{absent}) &&
|
||||
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Component '%s' instance '%s' is not present",
|
||||
$options{section}, $options{instance}));
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub get_severity_numeric {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'OK'; # default
|
||||
my $thresholds = { warning => undef, critical => undef };
|
||||
my $checked = 0;
|
||||
|
||||
if (defined($self->{numeric_threshold}->{$options{section}})) {
|
||||
my $exits = [];
|
||||
foreach (@{$self->{numeric_threshold}->{$options{section}}}) {
|
||||
if ($options{instance} =~ /$_->{regexp}/) {
|
||||
push @{$exits}, $self->{perfdata}->threshold_check(value => $options{value}, threshold => [ { label => $_->{label}, exit_litteral => $_->{threshold} } ]);
|
||||
$thresholds->{$_->{threshold}} = $self->{perfdata}->get_perfdata_for_output(label => $_->{label});
|
||||
$checked = 1;
|
||||
}
|
||||
}
|
||||
$status = $self->{output}->get_most_critical(status => $exits) if (scalar(@{$exits}) > 0);
|
||||
}
|
||||
|
||||
return ($status, $thresholds->{warning}, $thresholds->{critical}, $checked);
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
push @{$self->{request}}, ({ oid => $oid_enclNumber }, { oid => $oid_enclChannelShelfAddr });
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -301,15 +129,15 @@ Check Shelves hardware (temperatures, voltages, electronics, fan, power supplies
|
|||
Which component to check (Default: '.*').
|
||||
Can be: 'psu', 'fan', 'communication', 'voltage', 'temperature', 'electronics', 'raid'.
|
||||
|
||||
=item B<--exclude>
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=psu)
|
||||
Can also exclude specific instance: --exclude='psu#41239F00647-A#'
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
|
||||
Can also exclude specific instance: --filter=psu,41239F00647-A
|
||||
|
||||
=item B<--absent-problem>
|
||||
|
||||
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
|
||||
Can be specific or global: --absent-problem=fan#41239F00647-fan02#
|
||||
Can be specific or global: --absent-problem=fan,41239F00647-fan02
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
|
@ -318,19 +146,19 @@ If total (with skipped) is 0. (Default: 'critical' returns).
|
|||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,status,regexp)
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='gfc,CRITICAL,^(?!(Online)$)'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for temperatures (syntax: regexp,treshold)
|
||||
Set warning threshold for temperature, fan, voltage (syntax: type,regexp,threshold)
|
||||
Example: --warning='41239F00647-vimm46,20' --warning='41239F00647-vimm5.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for temperatures (syntax: regexp,treshold)
|
||||
Example: --critical='41239F00647-vimm46,25' --warning='41239F00647-vimm5.*,35'
|
||||
Set critical threshold for temperature, fan, voltage (syntax: type,regexp,threshold)
|
||||
Example: --critical='temperature,.*,25' --warning='temperature,.*,35'
|
||||
|
||||
=back
|
||||
|
||||
|
|
Loading…
Reference in New Issue