enh(imm) Add some modes (#2465)

This commit is contained in:
UrBnW 2020-12-30 14:15:41 +01:00 committed by GitHub
parent 7330767303
commit c88381bb1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 275 additions and 19 deletions

View File

@ -0,0 +1,64 @@
#
# Copyright 2020 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::cpu;
use strict;
use warnings;
use centreon::plugins::misc;
my $mapping = {
cpuDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.5.20.1.2' },
cpuHealthStatus => { oid => '.1.3.6.1.4.1.2.3.51.3.1.5.20.1.11' }
};
my $oid_cpuEntry = '.1.3.6.1.4.1.2.3.51.3.1.5.20.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_cpuEntry, start => $mapping->{cpuDescr}->{oid}, end => $mapping->{cpuHealthStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cpus");
$self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0};
return if ($self->check_filter(section => 'cpu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpuEntry}})) {
next if ($oid !~ /^$mapping->{cpuDescr}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpuEntry}, instance => $instance);
next if ($self->check_filter(section => 'cpu', instance => $instance));
$self->{components}->{cpu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("CPU '%s' is '%s' [instance = %s]",
$result->{cpuDescr}, $result->{cpuHealthStatus}, $instance));
my $exit = $self->get_severity(section => 'health', value => $result->{cpuHealthStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU '%s' is '%s'", $result->{cpuDescr}, $result->{cpuHealthStatus}));
}
}
}
1;

View File

@ -0,0 +1,64 @@
#
# Copyright 2020 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::disk;
use strict;
use warnings;
use centreon::plugins::misc;
my $mapping = {
diskDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.12.2.1.2' },
diskHealthStatus => { oid => '.1.3.6.1.4.1.2.3.51.3.1.12.2.1.3' }
};
my $oid_diskEntry = '.1.3.6.1.4.1.2.3.51.3.1.12.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_diskEntry, start => $mapping->{diskDescr}->{oid}, end => $mapping->{diskHealthStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking disks");
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
return if ($self->check_filter(section => 'disk'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_diskEntry}})) {
next if ($oid !~ /^$mapping->{diskDescr}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_diskEntry}, instance => $instance);
next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Disk '%s' is '%s' [instance = %s]",
$result->{diskDescr}, $result->{diskHealthStatus}, $instance));
my $exit = $self->get_severity(section => 'health', value => $result->{diskHealthStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Disk '%s' is '%s'", $result->{diskDescr}, $result->{diskHealthStatus}));
}
}
}
1;

View File

@ -25,15 +25,16 @@ 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' },
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' },
fanHealthStatus => { oid => '.1.3.6.1.4.1.2.3.51.3.1.3.2.1.10' }
};
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, start => $mapping->{fanDescr}->{oid}, end => $mapping->{fanSpeed}->{oid} };
push @{$self->{request}}, { oid => $oid_fanEntry, start => $mapping->{fanDescr}->{oid}, end => $mapping->{fanHealthStatus}->{oid} };
}
sub check {
@ -44,7 +45,7 @@ sub check {
return if ($self->check_filter(section => 'fan'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanEntry}})) {
next if ($oid !~ /^$mapping->{fanSpeed}->{oid}\.(.*)$/);
next if ($oid !~ /^$mapping->{fanDescr}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanEntry}, instance => $instance);
$result->{fanDescr} = centreon::plugins::misc::trim($result->{fanDescr});
@ -55,20 +56,18 @@ sub check {
$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}));
}
my $exit = $self->get_severity(section => 'health', value => $result->{fanHealthStatus});
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}, $result->{fanHealthStatus}));
}
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,
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $fan_speed);
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Fan '%s' is '%s' %%", $result->{fanDescr}, $fan_speed));
}
$self->{output}->perfdata_add(

View File

@ -0,0 +1,64 @@
#
# Copyright 2020 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::memory;
use strict;
use warnings;
use centreon::plugins::misc;
my $mapping = {
memoryDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.5.21.1.2' },
memoryHealthStatus => { oid => '.1.3.6.1.4.1.2.3.51.3.1.5.21.1.8' }
};
my $oid_memoryEntry = '.1.3.6.1.4.1.2.3.51.3.1.5.21.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_memoryEntry, start => $mapping->{memoryDescr}->{oid}, end => $mapping->{memoryHealthStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking memorys");
$self->{components}->{memory} = {name => 'memorys', total => 0, skip => 0};
return if ($self->check_filter(section => 'memory'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_memoryEntry}})) {
next if ($oid !~ /^$mapping->{memoryDescr}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryEntry}, instance => $instance);
next if ($self->check_filter(section => 'memory', instance => $instance));
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Memory '%s' is '%s' [instance = %s]",
$result->{memoryDescr}, $result->{memoryHealthStatus}, $instance));
my $exit = $self->get_severity(section => 'health', value => $result->{memoryHealthStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory '%s' is '%s'", $result->{memoryDescr}, $result->{memoryHealthStatus}));
}
}
}
1;

View File

@ -0,0 +1,64 @@
#
# Copyright 2020 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::power;
use strict;
use warnings;
use centreon::plugins::misc;
my $mapping = {
powerDescr => { oid => '.1.3.6.1.4.1.2.3.51.3.1.11.2.1.2' },
powerHealthStatus => { oid => '.1.3.6.1.4.1.2.3.51.3.1.11.2.1.6' }
};
my $oid_powerEntry = '.1.3.6.1.4.1.2.3.51.3.1.11.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_powerEntry, start => $mapping->{powerDescr}->{oid}, end => $mapping->{powerHealthStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking powers");
$self->{components}->{power} = {name => 'powers', total => 0, skip => 0};
return if ($self->check_filter(section => 'power'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerEntry}})) {
next if ($oid !~ /^$mapping->{powerDescr}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerEntry}, instance => $instance);
next if ($self->check_filter(section => 'power', instance => $instance));
$self->{components}->{power}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power '%s' is '%s' [instance = %s]",
$result->{powerDescr}, $result->{powerHealthStatus}, $instance));
my $exit = $self->get_severity(section => 'health', value => $result->{powerHealthStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power '%s' is '%s'", $result->{powerDescr}, $result->{powerHealthStatus}));
}
}
}
1;

View File

@ -28,7 +28,7 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|fan)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(fan|temperature|voltage)$';
$self->{cb_hook2} = 'snmp_execute';
@ -39,14 +39,15 @@ sub set_system {
['critical', 'CRITICAL'],
['nominal', 'OK']
],
fan => [
['offline', 'WARNING'],
['.*', 'OK']
health => [
['Normal', 'OK'],
['Warning', 'WARNING'],
['.*', 'CRITICAL']
]
};
$self->{components_path} = 'hardware::server::ibm::mgmt_cards::imm::snmp::mode::components';
$self->{components_module} = ['global', 'temperature', 'voltage', 'fan'];
$self->{components_module} = ['cpu', 'disk', 'fan', 'global', 'memory', 'power', 'temperature', 'voltage'];
}
sub snmp_execute {
@ -79,7 +80,7 @@ Check sensors (Fans, Temperatures, Voltages).
=item B<--component>
Which component to check (Default: '.*').
Can be: 'global', 'fan', 'temperature', 'voltage'.
Can be: 'cpu', 'disk', 'fan', 'global', 'memory', 'power', 'temperature', 'voltage'.
=item B<--filter>