Fix #802
This commit is contained in:
parent
e04516dc45
commit
a85703e610
|
@ -442,4 +442,4 @@ Example: --critical='xxxxx,.*,40'
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -24,40 +24,59 @@ use strict;
|
|||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my $mapping = {
|
||||
fanDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.3.2.1.2' },
|
||||
fanSpeed => { oid => '.1.3.6.1.4.1.2.3.51.3.1.3.2.1.3' },
|
||||
};
|
||||
my $oid_fanEntry = '.1.3.6.1.4.1.2.3.51.3.1.3.2.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_fanEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{components}->{fans} = {name => 'fans', total => 0};
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
return if ($self->check_exclude('fans'));
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
my $oid_fanEntry = '.1.3.6.1.4.1.2.3.51.3.1.3.2.1';
|
||||
my $oid_fanDescr = '.1.3.6.1.4.1.2.3.51.3.1.3.2.1.2';
|
||||
my $oid_fanSpeed = '.1.3.6.1.4.1.2.3.51.3.1.3.2.1.3';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_fanEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_fanDescr\.(\d+)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{fanSpeed}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $fan_descr = centreon::plugins::misc::trim($result->{$oid_fanDescr . '.' . $instance});
|
||||
my $fan_speed = centreon::plugins::misc::trim($result->{$oid_fanSpeed . '.' . $instance});
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanEntry}, instance => $instance);
|
||||
$result->{fanDescr} = centreon::plugins::misc::trim($result->{fanDescr});
|
||||
$result->{fanSpeed} = centreon::plugins::misc::trim($result->{fanSpeed});
|
||||
|
||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
|
||||
$self->{components}->{fans}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' speed is %s.",
|
||||
$fan_descr, $fan_speed));
|
||||
if ($fan_speed =~ /offline/i) {
|
||||
$self->{output}->output_add(severity => 'WARNING',
|
||||
short_msg => sprintf("Fan '%s' is offline", $fan_descr));
|
||||
} else {
|
||||
$fan_speed =~ /(\d+)/;
|
||||
$self->{output}->perfdata_add(label => 'fan_' . $fan_descr, unit => '%',
|
||||
value => $1,
|
||||
min => 0, max => 100);
|
||||
$self->{components}->{fan}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' speed is '%s' [instance = %s]",
|
||||
$result->{fanDescr}, $result->{fanSpeed}, $instance));
|
||||
if ($result->{fanSpeed} =~ /offline/i) {
|
||||
my $exit = $self->get_severity(section => 'fan', value => $result->{fanSpeed});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' is offline", $result->{fanDescr}));
|
||||
}
|
||||
}
|
||||
|
||||
next if ($result->{fanSpeed} !~ /(\d+)/);
|
||||
|
||||
my $fan_speed = $1;
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $fan_speed);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' is '%s' %%", $result->{fanDescr}, $fan_speed));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'fan_' . $result->{fanDescr}, unit => '%',
|
||||
value => $fan_speed,
|
||||
warning => $warn,
|
||||
critical => $crit, min => 0, max => 100
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
#
|
||||
# Copyright 2017 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::global;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_global_status = (
|
||||
0 => 'non recoverable',
|
||||
2 => 'critical',
|
||||
4 => 'non critical',
|
||||
255 => 'nominal',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
systemHealthStat => { oid => '.1.3.6.1.4.1.2.3.51.3.1.4.1', map => \%map_global_status },
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $mapping->{systemHealthStat}->{oid} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking system health");
|
||||
$self->{components}->{global} = {name => 'system health', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'global'));
|
||||
|
||||
return if (!defined($self->{results}->{$mapping->{systemHealthStat}->{oid}}) || scalar(keys %{$self->{results}->{$mapping->{systemHealthStat}->{oid}}}) <= 0);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{systemHealthStat}->{oid}}, instance => '0');
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("system health status is '%s'",
|
||||
$result->{systemHealthStat}));
|
||||
my $exit = $self->get_severity(section => 'global', value => $result->{systemHealthStat});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("System health status is '%s'.",
|
||||
$result->{systemHealthStat}));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,51 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::globalstatus;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %states = (
|
||||
0 => ['non recoverable', 'CRITICAL'],
|
||||
2 => ['critical', 'CRITICAL'],
|
||||
4 => ['non critical', 'WARNING'],
|
||||
255 => ['nominal', 'OK'],
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
my $oid_systemHealthStat = '.1.3.6.1.4.1.2.3.51.3.1.4.1.0';
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_systemHealthStat], nothing_quit => 1);
|
||||
|
||||
$self->{components}->{global} = {name => 'system health', total => 1};
|
||||
$self->{output}->output_add(long_msg => sprintf("System health status is '%s'.",
|
||||
${$states{$result->{$oid_systemHealthStat}}}[0]));
|
||||
if (${$states{$result->{$oid_systemHealthStat}}}[1] ne 'OK') {
|
||||
$self->{output}->output_add(severity => ${$states{$result->{$oid_systemHealthStat}}}[1],
|
||||
short_msg => sprintf("System health status is '%s'.",
|
||||
${$states{$result->{$oid_systemHealthStat}}}[0]));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -24,59 +24,66 @@ use strict;
|
|||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my $mapping = {
|
||||
tempDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.2' },
|
||||
tempReading => { oid => '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.3' },
|
||||
tempCritLimitHigh => { oid => '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.6' },
|
||||
tempNonCritLimitHigh => { oid => '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.7' },
|
||||
tempCritLimitLow => { oid => '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.9' },
|
||||
tempNonCritLimitLow => { oid => '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.10' },
|
||||
};
|
||||
my $oid_tempEntry = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_tempEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{components}->{temperatures} = {name => 'temperatures', total => 0};
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
return if ($self->check_exclude('temperatures'));
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
my $oid_tempEntry = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1';
|
||||
my $oid_tempDescr = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.2';
|
||||
my $oid_tempReading = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.3';
|
||||
my $oid_tempCritLimitHigh = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.6';
|
||||
my $oid_tempNonCritLimitHigh = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.7';
|
||||
my $oid_tempCritLimitLow = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.9';
|
||||
my $oid_tempNonCritLimitLow = '.1.3.6.1.4.1.2.3.51.3.1.1.2.1.10';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_tempEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_tempDescr\.(\d+)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_tempEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{tempDescr}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $temp_descr = centreon::plugins::misc::trim($result->{$oid_tempDescr . '.' . $instance});
|
||||
my $temp_value = $result->{$oid_tempReading . '.' . $instance};
|
||||
my $temp_crit_high = $result->{$oid_tempCritLimitHigh . '.' . $instance};
|
||||
my $temp_warn_high = $result->{$oid_tempNonCritLimitHigh . '.' . $instance};
|
||||
my $temp_crit_low = $result->{$oid_tempCritLimitLow . '.' . $instance};
|
||||
my $temp_warn_low = $result->{$oid_tempNonCritLimitLow . '.' . $instance};
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_tempEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
$result->{tempDescr} = centreon::plugins::misc::trim($result->{tempDescr});
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' value is %s C [instance: %s].",
|
||||
$result->{tempDescr}, $result->{tempReading}, $instance));
|
||||
|
||||
my $warn_threshold = '';
|
||||
$warn_threshold = $temp_warn_low . ':' . $temp_warn_high;
|
||||
my $crit_threshold = '';
|
||||
$crit_threshold = $temp_crit_low . ':' . $temp_crit_high;
|
||||
|
||||
$self->{perfdata}->threshold_validate(label => 'warning_' . $instance, value => $warn_threshold);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical_' . $instance, value => $crit_threshold);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $temp_value, threshold => [ { label => 'critical_' . $instance, 'exit_litteral' => 'critical' }, { label => 'warning_' . $instance, exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{components}->{temperatures}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' value is %s C.",
|
||||
$temp_descr, $temp_value));
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' value is %s C", $temp_descr, $temp_value));
|
||||
if (defined($result->{tempReading})) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{tempReading});
|
||||
if ($checked == 0) {
|
||||
my $warn_th = $result->{tempNonCritLimitLow} . ':' . $result->{tempNonCritLimitHigh};
|
||||
my $crit_th = $result->{tempCritLimitLow} . ':' . $result->{tempCritLimitHigh};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
$exit = $self->{perfdata}->threshold_check(
|
||||
value => $result->{tempReading},
|
||||
threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
|
||||
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' is %s C", $result->{tempDescr}, $result->{tempReading}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => "temp_" . $result->{tempDescr}, unit => 'C',
|
||||
value => $result->{tempReading},
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'temp_' . $temp_descr, unit => 'C',
|
||||
value => $temp_value,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_' . $instance),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_' . $instance),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -24,61 +24,66 @@ use strict;
|
|||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my $mapping = {
|
||||
voltDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.2' },
|
||||
voltReading => { oid => '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.3' },
|
||||
voltCritLimitHigh => { oid => '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.6' },
|
||||
voltNonCritLimitHigh => { oid => '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.7' },
|
||||
voltCritLimitLow => { oid => '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.9' },
|
||||
voltNonCritLimitLow => { oid => '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.10' },
|
||||
};
|
||||
my $oid_voltEntry = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_voltEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{components}->{voltages} = {name => 'voltages', total => 0};
|
||||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
return if ($self->check_exclude('voltages'));
|
||||
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'voltage'));
|
||||
|
||||
my $oid_voltEntry = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1';
|
||||
my $oid_voltDescr = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.2';
|
||||
my $oid_voltReading = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.3';
|
||||
my $oid_voltCritLimitHigh = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.6';
|
||||
my $oid_voltNonCritLimitHigh = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.7';
|
||||
my $oid_voltCritLimitLow = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.9';
|
||||
my $oid_voltNonCritLimitLow = '.1.3.6.1.4.1.2.3.51.3.1.2.2.1.10';
|
||||
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_voltEntry);
|
||||
return if (scalar(keys %$result) <= 0);
|
||||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_voltDescr\.(\d+)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_voltEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{voltDescr}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
|
||||
my $volt_descr = centreon::plugins::misc::trim($result->{$oid_voltDescr . '.' . $instance});
|
||||
my $volt_value = $result->{$oid_voltReading . '.' . $instance};
|
||||
my $volt_crit_high = $result->{$oid_voltCritLimitHigh . '.' . $instance};
|
||||
my $volt_warn_high = $result->{$oid_voltNonCritLimitHigh . '.' . $instance};
|
||||
my $volt_crit_low = $result->{$oid_voltCritLimitLow . '.' . $instance};
|
||||
my $volt_warn_low = $result->{$oid_voltNonCritLimitLow . '.' . $instance};
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_voltEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'voltage', instance => $instance));
|
||||
$result->{voltDescr} = centreon::plugins::misc::trim($result->{voltDescr});
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("voltage '%s' value is %s [instance: %s].",
|
||||
$result->{voltDescr}, $result->{voltReading}, $instance));
|
||||
|
||||
my $warn_threshold = '';
|
||||
$warn_threshold = $volt_warn_low . ':' if ($volt_warn_low != 0);
|
||||
$warn_threshold .= $volt_warn_high if ($volt_warn_high != 0);
|
||||
my $crit_threshold = '';
|
||||
$crit_threshold = $volt_crit_low . ':' if ($volt_crit_low != 0);
|
||||
$crit_threshold .= $volt_crit_high if ($volt_crit_high != 0);
|
||||
|
||||
$self->{perfdata}->threshold_validate(label => 'warning_' . $instance, value => $warn_threshold);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical_' . $instance, value => $crit_threshold);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $volt_value, threshold => [ { label => 'critical_' . $instance, 'exit_litteral' => 'critical' }, { label => 'warning_' . $instance, exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{components}->{temperatures}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' value is %s.",
|
||||
$volt_descr, $volt_value));
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' value is %s", $volt_descr, $volt_value));
|
||||
if (defined($result->{voltReading})) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltReading});
|
||||
if ($checked == 0) {
|
||||
my $warn_th = $result->{voltNonCritLimitLow} . ':' . $result->{voltNonCritLimitHigh};
|
||||
my $crit_th = $result->{voltCritLimitLow} . ':' . $result->{voltCritLimitHigh};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th);
|
||||
$exit = $self->{perfdata}->threshold_check(
|
||||
value => $result->{voltReading},
|
||||
threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' },
|
||||
{ label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]);
|
||||
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' is %s", $result->{voltDescr}, $result->{voltReading}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => "volt_" . $result->{voltDescr},
|
||||
value => $result->{voltReading},
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'volt_' . $volt_descr,
|
||||
value => $volt_value,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_' . $instance),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_' . $instance),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -20,15 +20,42 @@
|
|||
|
||||
package hardware::server::ibm::mgmt_cards::imm::snmp::mode::environment;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::globalstatus;
|
||||
use hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::temperature;
|
||||
use hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::voltage;
|
||||
use hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::fan;
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(global|temperature|voltage|fan)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|fan)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
global => [
|
||||
['non recoverable', 'CRITICAL'],
|
||||
['non critical', 'WARNING'],
|
||||
['critical', 'CRITICAL'],
|
||||
['nominal', 'OK'],
|
||||
],
|
||||
fan => [
|
||||
['offline', 'WARNING'],
|
||||
['.*', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'hardware::server::ibm::mgmt_cards::imm::snmp::mode::components';
|
||||
$self->{components_module} = ['global', 'temperature', 'voltage', 'fan'];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -38,78 +65,11 @@ sub new {
|
|||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"component:s" => { name => 'component', default => 'all' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub global {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::globalstatus::check($self);
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::temperature::check($self);
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::voltage::check($self);
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::fan::check($self);
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
if ($self->{option_results}->{component} eq 'all') {
|
||||
$self->global();
|
||||
} elsif ($self->{option_results}->{component} eq 'globalstatus') {
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::globalstatus::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'temperature') {
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::temperature::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'voltage') {
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::voltage::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'fan') {
|
||||
hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::fan::check($self);
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
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);
|
||||
$total_components += $self->{components}->{$comp}->{total};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components [%s] are ok.",
|
||||
$total_components,
|
||||
$display_by_component
|
||||
)
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, $section) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
@ -122,14 +82,36 @@ Check sensors (Fans, Temperatures, Voltages).
|
|||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: 'all').
|
||||
Can be: 'globalstatus', 'fan', 'temperature', 'voltage'.
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'global', 'fan', 'temperature', 'voltage'.
|
||||
|
||||
=item B<--exclude>
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=temperatures,fans).
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=temperature)
|
||||
Can also exclude specific instance: --filter=fan,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='fan,OK,offline'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
|
||||
Example: --warning='temperature,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
|
||||
Example: --critical='temperature,.*,40'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue