refactor huawei ibmc (#1108)
This commit is contained in:
parent
7434f86643
commit
1ccdf2c78f
|
@ -0,0 +1,86 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::component;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my %map_type = (
|
||||
1 => 'baseBoard',
|
||||
2 => 'mezzCard',
|
||||
3 => 'amcController',
|
||||
4 => 'mmcController',
|
||||
5 => 'hddBackPlane',
|
||||
6 => 'raidCard',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
componentName => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.10.50.1.1' },
|
||||
componentType => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.10.50.1.2', map => \%map_type },
|
||||
componentStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.10.50.1.5', map => \%map_status },
|
||||
};
|
||||
my $oid_componentDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.10.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_componentDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking component");
|
||||
$self->{components}->{component} = {name => 'components', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'component'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_componentDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{componentStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_componentDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'component', instance => $instance));
|
||||
next if ($result->{componentStatus} =~ /absence/);
|
||||
$self->{components}->{component}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Component '%s' of type '%s' status is '%s' [instance = %s]",
|
||||
$result->{componentName}, $result->{componentType}, $result->{componentStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'component', value => $result->{componentStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Component '%s' of type '%s' status is '%s'",
|
||||
$result->{componentName}, $result->{componentType}, $result->{componentStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,63 +1,75 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::cpu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub check {
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
cpuStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.15.50.1.6', map => \%map_status },
|
||||
cpuDevicename => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.15.50.1.10' },
|
||||
};
|
||||
my $oid_cpuDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.15.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown");
|
||||
my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown");
|
||||
|
||||
my $cpuStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.15.1.0";
|
||||
my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.15.50.1.6";
|
||||
my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.15.50.1.10";
|
||||
|
||||
my $tmpShortMessage = "";
|
||||
my $totalPresent = 0;
|
||||
my $totalComponent = 0;
|
||||
my $result = $self->{snmp}->get_table(oid => $statusTableOid);
|
||||
if (scalar(keys %$result) <= 0)
|
||||
{
|
||||
$tmpShortMessage = $tmpShortMessage."No cpu presence.";
|
||||
}else
|
||||
{
|
||||
my $endKey;
|
||||
my $temnameOid;
|
||||
my $statusOid;
|
||||
my $tmpMsg;
|
||||
my $tmpresult;
|
||||
my $v;
|
||||
foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result))
|
||||
{
|
||||
$v = $result->{$k};
|
||||
$endKey = "0";
|
||||
$temnameOid = "";
|
||||
$statusOid = "";
|
||||
$tmpMsg = "";
|
||||
$totalComponent++;
|
||||
if ($v ne "5") # cpu present
|
||||
{
|
||||
$totalPresent++;
|
||||
$k =~ /\.([0-9]+)$/;
|
||||
$endKey = $1;
|
||||
$temnameOid = $deviceTableOid.".".$endKey;
|
||||
$statusOid = $statusTableOid.".".$endKey;
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]);
|
||||
$tmpMsg = $tmpresult->{$temnameOid}.":";
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]);
|
||||
$tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." ";
|
||||
$tmpShortMessage = $tmpShortMessage.$tmpMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $self->{snmp}->get_leef(oids =>[$cpuStatusOid]);
|
||||
$tmpShortMessage = "cpuPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage;
|
||||
|
||||
$self->{output}->output_add(severity => $statusHash{$result-> {$cpuStatusOid}},
|
||||
short_msg => $tmpShortMessage );
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
push @{$self->{request}}, { oid => $oid_cpuDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking CPU");
|
||||
$self->{components}->{cpu} = {name => 'cpu', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'cpu'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpuDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{cpuStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpuDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'cpu', instance => $instance));
|
||||
next if ($result->{cpuStatus} =~ /absence/);
|
||||
$self->{components}->{cpu}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Cpu '%s' status is '%s' [instance = %s]",
|
||||
$result->{cpuDevicename}, $result->{cpuStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'cpu', value => $result->{cpuStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Cpu '%s' status is '%s'", $result->{cpuDevicename}, $result->{cpuStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,64 +1,100 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub check {
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my %map_installation_status = (
|
||||
1 => 'absence',
|
||||
2 => 'presence',
|
||||
3 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
fanSpeed => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.8.50.1.2' },
|
||||
fanPresence => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.8.50.1.3', map => \%map_installation_status },
|
||||
fanStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.8.50.1.4', map => \%map_status },
|
||||
fanDevicename => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.8.50.1.7' },
|
||||
};
|
||||
my $oid_fanDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.8.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown");
|
||||
my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown");
|
||||
|
||||
my $fanStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.3.0";
|
||||
my $presentTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.50.1.3";
|
||||
my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.50.1.4";
|
||||
my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.8.50.1.7";
|
||||
|
||||
my $tmpShortMessage = "";
|
||||
my $totalPresent = 0;
|
||||
my $totalComponent = 0;
|
||||
my $result = $self->{snmp}->get_table(oid => $presentTableOid);
|
||||
if (scalar(keys %$result) <= 0)
|
||||
{
|
||||
$tmpShortMessage = $tmpShortMessage."No fan presence.";
|
||||
}else
|
||||
{
|
||||
my $endKey;
|
||||
my $temnameOid;
|
||||
my $statusOid;
|
||||
my $tmpMsg;
|
||||
my $tmpresult;
|
||||
my $v;
|
||||
foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result))
|
||||
{
|
||||
$v = $result->{$k};
|
||||
$endKey = "0";
|
||||
$temnameOid = "";
|
||||
$statusOid = "";
|
||||
$tmpMsg = "";
|
||||
$totalComponent++;
|
||||
if ($v eq "2") # fan present
|
||||
{
|
||||
$totalPresent++;
|
||||
$k =~ /\.([0-9]+)$/;
|
||||
$endKey = $1 ;
|
||||
$temnameOid = $deviceTableOid.".".$endKey;
|
||||
$statusOid = $statusTableOid.".".$endKey;
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]);
|
||||
$tmpMsg = $tmpresult->{$temnameOid}.":";
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]);
|
||||
$tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." ";
|
||||
$tmpShortMessage = $tmpShortMessage.$tmpMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $self->{snmp}->get_leef(oids =>[$fanStatusOid]);
|
||||
$tmpShortMessage = "fanPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage;
|
||||
|
||||
$self->{output}->output_add(severity => $statusHash{$result-> {$fanStatusOid}},
|
||||
short_msg => $tmpShortMessage );
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
push @{$self->{request}}, { oid => $oid_fanDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{fanStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
next if ($result->{fanPresence} !~ /presence/);
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
if (defined($result->{fanSpeed}) && $result->{fanSpeed} =~ /[0-9]/) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, 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' speed is %s RPM", $result->{fanDevicename}, $result->{fanSpeed}));
|
||||
}
|
||||
my $perf_label = $result->{fanDevicename};
|
||||
$perf_label =~ s/ /_/g;
|
||||
$self->{output}->perfdata_add(label => 'speed_' . $perf_label, unit => 'rpm',
|
||||
value => $result->{fanSpeed},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]",
|
||||
$result->{fanDevicename}, $result->{fanStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{fanStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' status is '%s'", $result->{fanDevicename}, $result->{fanStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,100 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::harddisk;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my %map_installation_status = (
|
||||
1 => 'absence',
|
||||
2 => 'presence',
|
||||
3 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
hardDiskPresence => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.18.50.1.2', map => \%map_installation_status },
|
||||
hardDiskStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.18.50.1.3', map => \%map_status },
|
||||
hardDiskDevicename => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.18.50.1.6' },
|
||||
hardDiskTemperature => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.18.50.1.20' },
|
||||
};
|
||||
my $oid_hardDiskDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.18.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_hardDiskDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking hard disks");
|
||||
$self->{components}->{harddisk} = {name => 'hard disks', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'harddisk'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hardDiskDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{hardDiskStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hardDiskDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'harddisk', instance => $instance));
|
||||
next if ($result->{hardDiskPresence} !~ /presence/);
|
||||
$self->{components}->{harddisk}->{total}++;
|
||||
|
||||
if (defined($result->{hardDiskTemperature}) && $result->{hardDiskTemperature} =~ /[0-9]/) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'harddisk', instance => $instance, value => $result->{hardDiskTemperature});
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Hard Disk '%s' temperature is %s celsius degrees", $result->{hardDiskDevicename}, $result->{hardDiskTemperature}));
|
||||
}
|
||||
my $perf_label = $result->{hardDiskDevicename};
|
||||
$perf_label =~ s/ /_/g;
|
||||
$self->{output}->perfdata_add(label => 'temperature_' . $perf_label, unit => 'C',
|
||||
value => $result->{hardDiskTemperature},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Hard disk '%s' status is '%s' [instance = %s]",
|
||||
$result->{hardDiskDevicename}, $result->{hardDiskStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'harddisk', value => $result->{hardDiskStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Hard disk '%s' status is '%s'", $result->{hardDiskDevicename}, $result->{hardDiskStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::logicaldrive;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_state = (
|
||||
1 => 'offline',
|
||||
2 => 'partial degraded',
|
||||
3 => 'degraded',
|
||||
4 => 'optimal',
|
||||
255 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
logicalDriveRAIDControllerIndex => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.37.50.1.1' },
|
||||
logicalDriveIndex => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.37.50.1.2' },
|
||||
logicalDriveState => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.37.50.1.4', map => \%map_state },
|
||||
};
|
||||
my $oid_logicalDriveDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.37.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_logicalDriveDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking logical drives");
|
||||
$self->{components}->{logicaldrive} = {name => 'logical drives', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'logicaldrive'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_logicalDriveDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{logicalDriveState}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_logicalDriveDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'logicaldrive', instance => $instance));
|
||||
$self->{components}->{logicaldrive}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Logical drive '%s.%s' status is '%s' [instance = %s]",
|
||||
$result->{logicalDriveRAIDControllerIndex}, $result->{logicalDriveIndex}, $result->{logicalDriveState}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'logicaldrive', section => 'logicaldrive', value => $result->{logicalDriveState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Logical drive '%s.%s' status is '%s'",
|
||||
$result->{logicalDriveRAIDControllerIndex},
|
||||
$result->{logicalDriveIndex},
|
||||
$result->{logicalDriveState}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,63 +1,75 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::memory;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub check {
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
memoryStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.16.50.1.6', map => \%map_status },
|
||||
memoryDevicename => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.16.50.1.10' },
|
||||
};
|
||||
my $oid_memoryDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.16.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown");
|
||||
my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown");
|
||||
|
||||
my $memoryStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.16.1.0";
|
||||
my $statusTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.16.50.1.6";
|
||||
my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.16.50.1.10";
|
||||
|
||||
my $tmpShortMessage = "";
|
||||
my $totalPresent = 0;
|
||||
my $totalComponent = 0;
|
||||
my $result = $self->{snmp}->get_table(oid => $statusTableOid);
|
||||
if (scalar(keys %$result) <= 0)
|
||||
{
|
||||
$tmpShortMessage = $tmpShortMessage."No memory presence.";
|
||||
}else
|
||||
{
|
||||
my $endKey;
|
||||
my $temnameOid;
|
||||
my $statusOid;
|
||||
my $tmpMsg;
|
||||
my $tmpresult;
|
||||
my $v;
|
||||
foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result))
|
||||
{
|
||||
$v = $result->{$k};
|
||||
$endKey = "0";
|
||||
$temnameOid = "";
|
||||
$statusOid = "";
|
||||
$tmpMsg = "";
|
||||
$totalComponent++;
|
||||
if ($v ne "5") # memory present
|
||||
{
|
||||
$totalPresent++;
|
||||
$k =~ /\.([0-9]+)$/;
|
||||
$endKey = $1 ;
|
||||
$temnameOid = $deviceTableOid.".".$endKey;
|
||||
$statusOid = $statusTableOid.".".$endKey;
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]);
|
||||
$tmpMsg = $tmpresult->{$temnameOid}.":";
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]);
|
||||
$tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." ";
|
||||
$tmpShortMessage = $tmpShortMessage.$tmpMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $self->{snmp}->get_leef(oids =>[$memoryStatusOid]);
|
||||
$tmpShortMessage = "memoryPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage;
|
||||
|
||||
$self->{output}->output_add(severity => $statusHash{$result-> {$memoryStatusOid}},
|
||||
short_msg => $tmpShortMessage );
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
push @{$self->{request}}, { oid => $oid_memoryDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking memory");
|
||||
$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_memoryDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{memoryStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'memory', instance => $instance));
|
||||
next if ($result->{memoryStatus} =~ /absence/);
|
||||
$self->{components}->{memory}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Memory '%s' status is '%s' [instance = %s]",
|
||||
$result->{memoryDevicename}, $result->{memoryStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'memory', value => $result->{memoryStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Memory '%s' status is '%s'", $result->{memoryDevicename}, $result->{memoryStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,82 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::pcie;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my %map_installation_status = (
|
||||
1 => 'absence',
|
||||
2 => 'presence',
|
||||
3 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
pCIePresence => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.24.50.1.2', map => \%map_installation_status },
|
||||
pCIeStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.24.50.1.3', map => \%map_status },
|
||||
pCIeDevicename => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.24.50.1.7' },
|
||||
};
|
||||
my $oid_pCIeDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.24.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_pCIeDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking PCIe");
|
||||
$self->{components}->{pcie} = {name => 'pcie', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'pcie'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_pCIeDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{pCIeStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_pCIeDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'pcie', instance => $instance));
|
||||
next if ($result->{pCIePresence} !~ /presence/);
|
||||
$self->{components}->{pcie}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("PCIe '%s' status is '%s' [instance = %s]",
|
||||
$result->{pCIeDevicename}, $result->{pCIeStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'pcie', value => $result->{pCIeStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("PCIe '%s' status is '%s'", $result->{pCIeDevicename}, $result->{pCIeStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,64 +1,103 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub check {
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my %map_installation_status = (
|
||||
1 => 'absence',
|
||||
2 => 'presence',
|
||||
3 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
powerSupplyPowerRating => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.6.50.1.6' },
|
||||
powerSupplyStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.6.50.1.7', map => \%map_status },
|
||||
powerSupplyInputPower => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.6.50.1.8' },
|
||||
powerSupplyPresence => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.6.50.1.9', map => \%map_installation_status },
|
||||
powerSupplyDevicename => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.6.50.1.13' },
|
||||
};
|
||||
my $oid_powerSupplyDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.6.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical","5"=>"unknown","6"=>"unknown");
|
||||
my %eachStatus = ("1"=>"ok","2"=>"minor","3"=>"major","4"=>"critical","5"=>"absence","6"=>"unknown");
|
||||
|
||||
my $psuStatueOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.1.0";
|
||||
my $presentTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.50.1.9";
|
||||
my $statueTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.50.1.7";
|
||||
my $deviceTableOid = ".1.3.6.1.4.1.2011.2.235.1.1.6.50.1.13";
|
||||
|
||||
my $tmpShortMessage = "";
|
||||
my $totalPresent = 0;
|
||||
my $totalComponent = 0;
|
||||
my $result = $self->{snmp}->get_table(oid => $presentTableOid);
|
||||
if (scalar(keys %$result) <= 0)
|
||||
{
|
||||
$tmpShortMessage = $tmpShortMessage."No psu presence.";
|
||||
}else
|
||||
{
|
||||
my $endKey;
|
||||
my $temnameOid;
|
||||
my $statusOid;
|
||||
my $tmpMsg;
|
||||
my $tmpresult;
|
||||
my $v;
|
||||
foreach my $k ($self->{snmp}->oid_lex_sort(keys %$result))
|
||||
{
|
||||
$v = $result->{$k};
|
||||
$endKey = "0";
|
||||
$temnameOid = "";
|
||||
$statusOid = "";
|
||||
$tmpMsg = "";
|
||||
$totalComponent++;
|
||||
if ($v eq "2") # psu present
|
||||
{
|
||||
$totalPresent++;
|
||||
$k =~ /\.([0-9]+)$/;
|
||||
$endKey = $1;
|
||||
$temnameOid = $deviceTableOid.".".$endKey;
|
||||
$statusOid = $statueTableOid.".".$endKey;
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$temnameOid]);
|
||||
$tmpMsg = $tmpresult->{$temnameOid}.":";
|
||||
$tmpresult = $self->{snmp}->get_leef(oids =>[$statusOid]);
|
||||
$tmpMsg = $tmpMsg.$eachStatus{$tmpresult->{$statusOid}}." ";
|
||||
$tmpShortMessage=$tmpShortMessage.$tmpMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = $self->{snmp}->get_leef(oids =>[$psuStatueOid]);
|
||||
$tmpShortMessage = "psuPresence:".$totalPresent."\/".$totalComponent." ".$tmpShortMessage;
|
||||
|
||||
$self->{output}->output_add(severity => $statusHash{$result-> {$psuStatueOid}},
|
||||
short_msg => $tmpShortMessage );
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
push @{$self->{request}}, { oid => $oid_powerSupplyDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{powerSupplyStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||
next if ($result->{powerSupplyPresence} !~ /presence/);
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
if (defined($result->{powerSupplyInputPower}) && $result->{powerSupplyInputPower} =~ /[0-9]/ &&
|
||||
defined($result->{powerSupplyPowerRating}) && $result->{powerSupplyPowerRating} =~ /[0-9]/) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu', instance => $instance, value => $result->{powerSupplyInputPower});
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power supply '%s' power is %s watts", $result->{powerSupplyDevicename}, $result->{powerSupplyInputPower}));
|
||||
}
|
||||
my $perf_label = $result->{powerSupplyDevicename};
|
||||
$perf_label =~ s/ /_/g;
|
||||
$self->{output}->perfdata_add(label => 'power_' . $perf_label, unit => 'W',
|
||||
value => $result->{powerSupplyInputPower},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0,
|
||||
max => $result->{powerSupplyPowerRating}
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]",
|
||||
$result->{powerSupplyDevicename}, $result->{powerSupplyStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{powerSupplyStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power supply '%s' status is '%s'", $result->{powerSupplyDevicename}, $result->{powerSupplyStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,75 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::raidcontroller;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'minor',
|
||||
3 => 'major',
|
||||
4 => 'critical',
|
||||
5 => 'absence',
|
||||
6 => 'unknown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
raidControllerStatus => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.36.50.1.7', map => \%map_status },
|
||||
raidControllerComponentName => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.36.50.1.4' },
|
||||
};
|
||||
my $oid_raidControllerDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.36.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_raidControllerDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking raid controllers");
|
||||
$self->{components}->{raidcontroller} = {name => 'raidcontrollers', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'raidcontroller'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidControllerDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{raidControllerStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidControllerDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'raidcontroller', instance => $instance));
|
||||
next if ($result->{raidControllerStatus} =~ /absence/);
|
||||
$self->{components}->{raidcontroller}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Raid controller '%s' status is '%s' [instance = %s]",
|
||||
$result->{raidControllerComponentName}, $result->{raidControllerStatus}, $instance,
|
||||
));
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'Raid controller', value => $result->{raidControllerStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Raid controller '%s' status is '%s'", $result->{raidControllerComponentName}, $result->{raidControllerStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,35 +0,0 @@
|
|||
package hardware::server::huawei::ibmc::snmp::mode::components::system;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
my %statusHash = ("1"=>"ok","2"=>"warning","3"=>"warning","4"=>"critical");
|
||||
my %powerHash = ("1"=>"normalPowerOff","2"=>"powerOn","3"=>"forcedSystemReset","4"=>"forcedPowerCycle","5"=>"forcedPowerOff");
|
||||
|
||||
my $systemStatusOid = ".1.3.6.1.4.1.2011.2.235.1.1.1.1.0";
|
||||
my $deviceNameOid = ".1.3.6.1.4.1.2011.2.235.1.1.1.6.0";
|
||||
my $deviceSerialNo = ".1.3.6.1.4.1.2011.2.235.1.1.1.7.0";
|
||||
my $systemPowerState = ".1.3.6.1.4.1.2011.2.235.1.1.1.12.0";
|
||||
|
||||
my $tmpShortMessage = "";
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids =>[$systemStatusOid,$deviceNameOid,$deviceSerialNo,$systemPowerState]);
|
||||
if (scalar(keys %$result) <= 0)
|
||||
{
|
||||
$tmpShortMessage = $tmpShortMessage."Get system info failed.";
|
||||
}else
|
||||
{
|
||||
$tmpShortMessage = "deviceName:".$result->{$deviceNameOid}." deviceSerialNo:".$result->{$deviceSerialNo}." systemPowerStatus:".$powerHash{$result->{$systemPowerState}};
|
||||
}
|
||||
|
||||
|
||||
$self->{output}->output_add(severity => $statusHash{$result->{$systemStatusOid}},
|
||||
short_msg => $tmpShortMessage);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
1;
|
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::components::temperature;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $mapping = {
|
||||
temperatureObject => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.26.50.1.2' },
|
||||
temperatureReading => { oid => '.1.3.6.1.4.1.2011.2.235.1.1.26.50.1.3' },
|
||||
};
|
||||
my $oid_temperatureDescriptionEntry = '.1.3.6.1.4.1.2011.2.235.1.1.26.50.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_temperatureDescriptionEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureDescriptionEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{temperatureReading}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureDescriptionEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
next if ($result->{temperatureReading} == 65535);
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Temperature of '%s' is '%s' celsius degrees [instance = %s]",
|
||||
$result->{temperatureObject}, $result->{temperatureReading} / 10, $instance,
|
||||
));
|
||||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureReading} / 10);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature of '%s' is '%s' celsius degrees", $result->{temperatureObject}, $result->{temperatureReading} / 10));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'temperature_' . $result->{temperatureObject}, unit => 'C',
|
||||
value => $result->{temperatureReading} / 10,
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,124 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(harddisk|fan|psu|temperature)$';
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(component|cpu|harddisk|fan|logicaldrive|memory|pcie|psu|raidcontroller)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
'default' => [
|
||||
['ok', 'OK'],
|
||||
['minor', 'WARNING'],
|
||||
['major', 'CRITICAL'],
|
||||
['critical', 'CRITICAL'],
|
||||
['absence', 'UNKNOWN'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
],
|
||||
'logicaldrive' => [
|
||||
['offline', 'OK'],
|
||||
['partial degraded', 'WARNING'],
|
||||
['degraded', 'CRITICAL'],
|
||||
['optimal', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'hardware::server::huawei::ibmc::snmp::mode::components';
|
||||
$self->{components_module} = ['component', 'cpu', 'harddisk', 'fan', 'logicaldrive',
|
||||
'memory', 'pcie', 'psu', 'raidcontroller', 'temperature'];
|
||||
}
|
||||
|
||||
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) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check hardware components.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'component', 'cpu', 'harddisk', 'fan', 'logicaldrive',
|
||||
'memory', 'pcie', 'psu', 'raidcontroller', 'temperature'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=psu)
|
||||
Can also exclude specific instance: --filter=psu,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='psu,CRITICAL,^(?!(ok)$)'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold (syntax: type,regexp,threshold)
|
||||
Example: --warning='psu,.*,300'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold (syntax: type,regexp,threshold)
|
||||
Example: --critical='psu,.*,400'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -1,3 +1,22 @@
|
|||
#
|
||||
# Copyright 2018 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::huawei::ibmc::snmp::plugin;
|
||||
|
||||
|
@ -12,17 +31,18 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'hardwares' => 'hardware::server::huawei::ibmc::snmp::mode::hardwares',
|
||||
'hardware' => 'hardware::server::huawei::ibmc::snmp::mode::hardware',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
1;
|
||||
__END__
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check HUAWEI servers in SNMP.
|
||||
Check Huawei iBMC in SNMP.
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue