enhance hp bladechassis snmp

This commit is contained in:
garnier-quentin 2019-07-03 13:44:43 +02:00
parent 8f31b5c810
commit ac85e08d71
9 changed files with 337 additions and 517 deletions

View File

@ -37,74 +37,72 @@ my %present_map = (
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB 4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
); );
my $mapping = {
blade_name => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.4' }, # cpqRackServerBladeName
blade_part => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.6' }, # cpqRackServerBladePartNumber
blade_status => { oid => '.1.3.6.1.4.1.232.22.2.3.1.3.1.11', map => \%map_conditions }, # cpqRackServerBladeStatus (v2)
blade_spare => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.21' }, # cpqRackServerBladeSparePartNumber
blade_productid => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.17' }, # cpqRackServerBladeProductId
blade_diago => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.24' }, # cpqRackServerBladeFaultDiagnosticString (v2)
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; $self->{components}->{blade} = {name => 'blades', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking blades"); $self->{output}->output_add(long_msg => "checking blades");
return if ($self->check_exclude(section => 'blade')); return if ($self->check_filter(section => 'blade'));
my $oid_cpqRackServerBladePresent = '.1.3.6.1.4.1.232.22.2.4.1.1.1.12'; my $oid_cpqRackServerBladePresent = '.1.3.6.1.4.1.232.22.2.4.1.1.1.12';
my $oid_cpqRackServerBladeIndex = '.1.3.6.1.4.1.232.22.2.4.1.1.1.3';
my $oid_cpqRackServerBladeName = '.1.3.6.1.4.1.232.22.2.4.1.1.1.4';
my $oid_cpqRackServerBladePartNumber = '.1.3.6.1.4.1.232.22.2.4.1.1.1.6';
my $oid_cpqRackServerBladeSparePartNumber = '.1.3.6.1.4.1.232.22.2.4.1.1.1.7';
my $oid_cpqRackServerBladeProductId = '.1.3.6.1.4.1.232.22.2.4.1.1.1.17';
my $oid_cpqRackServerBladeStatus = '.1.3.6.1.4.1.232.22.2.4.1.1.1.21'; # v2
my $oid_cpqRackServerBladeFaultDiagnosticString = '.1.3.6.1.4.1.232.22.2.4.1.1.1.24'; # v2
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackServerBladePresent); my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackServerBladePresent);
return if (scalar(keys %$result) <= 0); return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = (); my @get_oids = ();
my @oids_end = (); my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /\.([0-9]+)$/; $key =~ /\.([0-9]+)$/;
my $oid_end = $1; my $oid_end = $1;
next if ($present_map{$result->{$key}} ne 'present' && next if ($present_map{$snmp_result->{$key}} ne 'present' &&
$self->absent_problem(section => 'blade', instance => $oid_end)); $self->absent_problem(section => 'blade', instance => $oid_end));
push @oids_end, $oid_end; push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackServerBladeIndex . "." . $oid_end, $oid_cpqRackServerBladeName . "." . $oid_end, push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
$oid_cpqRackServerBladePartNumber . "." . $oid_end, $oid_cpqRackServerBladeSparePartNumber . "." . $oid_end,
$oid_cpqRackServerBladeProductId . "." . $oid_end,
$oid_cpqRackServerBladeStatus . "." . $oid_end, $oid_cpqRackServerBladeFaultDiagnosticString . "." . $oid_end;
} }
$result = $self->{snmp}->get_leef(oids => \@get_oids); $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) { foreach (@oids_end) {
my $blade_index = $result->{$oid_cpqRackServerBladeIndex . '.' . $_}; my $blade_index = $_;
my $blade_status = defined($result->{$oid_cpqRackServerBladeStatus . '.' . $_}) ? $result->{$oid_cpqRackServerBladeStatus . '.' . $_} : '';
my $blade_name = $result->{$oid_cpqRackServerBladeName . '.' . $_}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $blade_index);
my $blade_part = $result->{$oid_cpqRackServerBladePartNumber . '.' . $_}; next if ($self->check_filter(section => 'blade', instance => $blade_index));
my $blade_spare = $result->{$oid_cpqRackServerBladeSparePartNumber . '.' . $_};
my $blade_productid = $result->{$oid_cpqRackServerBladeProductId . '.' . $_};
my $blade_diago = defined($result->{$oid_cpqRackServerBladeFaultDiagnosticString . '.' . $_}) ? $result->{$oid_cpqRackServerBladeFaultDiagnosticString . '.' . $_} : '';
next if ($self->check_exclude(section => 'blade', instance => $blade_index));
$self->{components}->{blade}->{total}++; $self->{components}->{blade}->{total}++;
if ($blade_status eq '') { if (!defined($result->{blade_status})) {
$self->{output}->output_add(long_msg => sprintf("Skipping Blade %d (%s, %s). Cant get status.", $self->{output}->output_add(long_msg => sprintf("skipping blade '%s' (%s, %s). Cant get status.",
$blade_index, $blade_name, $blade_productid)); $blade_index, $result->{blade_name}, $result->{blade_productid}));
next; next;
} }
$self->{output}->output_add(long_msg => sprintf("Blade %d (%s, %s) status is %s [part: %s, spare: %s]%s.", $self->{output}->output_add(
$blade_index, $blade_name, $blade_productid, long_msg => sprintf("blade '%s' (%s, %s) status is %s [part: %s, spare: %s]%s.",
$map_conditions{$blade_status}, $blade_index, $result->{blade_name}, $result->{blade_productid},
$blade_part, $blade_spare, $result->{blade_status},
($blade_diago ne '') ? " (Diagnostic '$blade_diago')" : '' $result->{blade_part}, $result->{blade_spare},
)); defined($result->{blade_diago}) ? " (Diagnostic '$result->{blade_diago}')" : ''
my $exit = $self->get_severity(section => 'blade', value => $map_conditions{$blade_status}); )
);
my $exit = $self->get_severity(label => 'default', section => 'blade', instance => $blade_index, value => $result->{blade_status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Blade %d (%s, %s) status is %s", severity => $exit,
$blade_index, $blade_name, $blade_productid, short_msg => sprintf("Blade '%s' (%s, %s) status is %s",
$map_conditions{$blade_status} $blade_index, $result->{blade_name}, $result->{blade_productid},
)); $result->{blade_status}
)
);
} }
} }
} }
1; 1;

View File

@ -23,42 +23,65 @@ package hardware::server::hp::bladechassis::snmp::mode::components::enclosure;
use strict; use strict;
use warnings; use warnings;
my %map_conditions = ( my $map_conditions = {
1 => 'other', 1 => 'other',
2 => 'ok', 2 => 'ok',
3 => 'degraded', 3 => 'degraded',
4 => 'failed', 4 => 'failed',
); };
my $mapping = {
cpqRackCommonEnclosureSparePartNumber => { oid => '.1.3.6.1.4.1.232.22.2.3.1.1.1.6' },
cpqRackCommonEnclosureSerialNum => { oid => '.1.3.6.1.4.1.232.22.2.3.1.1.1.7' },
cpqRackCommonEnclosureFWRev => { oid => '.1.3.6.1.4.1.232.22.2.3.1.1.1.8' },
cpqRackCommonEnclosureCondition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.1.1.16', map => $map_conditions },
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
my $oid_cpqRackCommonEnclosurePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.1.1.5.1';
my $oid_cpqRackCommonEnclosureSparePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.1.1.6.1';
my $oid_cpqRackCommonEnclosureSerialNum = '.1.3.6.1.4.1.232.22.2.3.1.1.1.7.1';
my $oid_cpqRackCommonEnclosureFWRev = '.1.3.6.1.4.1.232.22.2.3.1.1.1.8.1';
my $oid_cpqRackCommonEnclosureCondition = '.1.3.6.1.4.1.232.22.2.3.1.1.1.16.1';
$self->{components}->{enclosure} = {name => 'enclosure', total => 0, skip => 0}; $self->{components}->{enclosure} = {name => 'enclosure', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking enclosure"); $self->{output}->output_add(long_msg => "checking enclosure");
return if ($self->check_exclude(section => 'enclosure')); return if ($self->check_filter(section => 'enclosure'));
my $result = $self->{snmp}->get_leef(oids => [$oid_cpqRackCommonEnclosurePartNumber, $oid_cpqRackCommonEnclosureSparePartNumber, my $oid_cpqRackCommonEnclosurePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.1.1.5';
$oid_cpqRackCommonEnclosureSerialNum, $oid_cpqRackCommonEnclosureFWRev, my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosurePartNumber);
$oid_cpqRackCommonEnclosureCondition], nothing_quit => 1); return if (scalar(keys %$snmp_result) <= 0);
$self->{components}->{enclosure}->{total}++;
my @get_oids = ();
$self->{output}->output_add(long_msg => sprintf("Enclosure overall health condition is %s [part: %s, spare: %s, sn: %s, fw: %s].", my @oids_end = ();
$map_conditions{$result->{$oid_cpqRackCommonEnclosureCondition}}, foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$result->{$oid_cpqRackCommonEnclosurePartNumber}, $key =~ /^$oid_cpqRackCommonEnclosurePartNumber\.(.*)$/;
$result->{$oid_cpqRackCommonEnclosureSparePartNumber}, my $oid_end = $1;
$result->{$oid_cpqRackCommonEnclosureSerialNum}, push @oids_end, $oid_end;
$result->{$oid_cpqRackCommonEnclosureFWRev})); push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
my $exit = $self->get_severity(section => 'enclosure', value => $map_conditions{$result->{$oid_cpqRackCommonEnclosureCondition}}); }
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, my $snmp_result2 = $self->{snmp}->get_leef(oids => \@get_oids);
short_msg => sprintf("Enclosure overall health condition is %s", $map_conditions{$result->{$oid_cpqRackCommonEnclosureCondition}})); foreach (@oids_end) {
my $instance = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result2, instance => $instance);
next if ($self->check_filter(section => 'enclosure', instance => $instance));
$self->{components}->{enclosure}->{total}++;
$self->{output}->output_add(long_msg =>
sprintf("enclosure '%s' overall health condition is %s [part: %s, spare: %s, sn: %s, fw: %s].",
$instance,
$result->{cpqRackCommonEnclosureCondition},
$snmp_result->{$oid_cpqRackCommonEnclosurePartNumber . '.' . $instance},
$result->{cpqRackCommonEnclosureSparePartNumber},
$result->{cpqRackCommonEnclosureSerialNum},
$result->{cpqRackCommonEnclosureFWRev}
)
);
my $exit = $self->get_severity(label => 'default', section => 'enclosure', value => $$result->{cpqRackCommonEnclosureCondition});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Enclosure '%s' overall health condition is %s", $instance, $result->{cpqRackCommonEnclosureCondition}));
}
} }
} }
1; 1;

View File

@ -37,53 +37,53 @@ my %present_map = (
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB 4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
); );
my $mapping = {
fan_part => { oid => '.1.3.6.1.4.1.232.22.2.3.1.3.1.6' }, # cpqRackCommonEnclosureFanPartNumber
fan_spare => { oid => '.1.3.6.1.4.1.232.22.2.3.1.3.1.7' }, # cpqRackCommonEnclosureFanSparePartNumber
fan_condition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.3.1.11', map => \%map_conditions }, # cpqRackCommonEnclosureFanCondition
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking fans"); $self->{output}->output_add(long_msg => "checking fans");
return if ($self->check_exclude(section => 'fan')); return if ($self->check_filter(section => 'fan'));
my $oid_cpqRackCommonEnclosureFanPresent = '.1.3.6.1.4.1.232.22.2.3.1.3.1.8'; my $oid_cpqRackCommonEnclosureFanPresent = '.1.3.6.1.4.1.232.22.2.3.1.3.1.8';
my $oid_cpqRackCommonEnclosureFanIndex = '.1.3.6.1.4.1.232.22.2.3.1.3.1.3';
my $oid_cpqRackCommonEnclosureFanPartNumber = '.1.3.6.1.4.1.232.22.2.3.1.3.1.6';
my $oid_cpqRackCommonEnclosureFanSparePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.3.1.7';
my $oid_cpqRackCommonEnclosureFanCondition = '.1.3.6.1.4.1.232.22.2.3.1.3.1.11';
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFanPresent); my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFanPresent);
return if (scalar(keys %$result) <= 0); return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = (); my @get_oids = ();
my @oids_end = (); my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /\.([0-9]+)$/; $key =~ /\.([0-9]+)$/;
my $oid_end = $1; my $oid_end = $1;
next if ($present_map{$result->{$key}} ne 'present' && next if ($present_map{$snmp_result->{$key}} ne 'present' &&
$self->absent_problem(section => 'fan', instance => $oid_end)); $self->absent_problem(section => 'fan', instance => $oid_end));
push @oids_end, $oid_end; push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackCommonEnclosureFanIndex . "." . $oid_end, $oid_cpqRackCommonEnclosureFanPartNumber . "." . $oid_end, push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
$oid_cpqRackCommonEnclosureFanSparePartNumber . "." . $oid_end, $oid_cpqRackCommonEnclosureFanCondition . "." . $oid_end;
} }
$result = $self->{snmp}->get_leef(oids => \@get_oids); $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) { foreach (@oids_end) {
my $fan_index = $result->{$oid_cpqRackCommonEnclosureFanIndex . '.' . $_}; my $fan_index = $_;
my $fan_condition = $result->{$oid_cpqRackCommonEnclosureFanCondition . '.' . $_};
my $fan_part = $result->{$oid_cpqRackCommonEnclosureFanPartNumber . '.' . $_}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $fan_index);
my $fan_spare = $result->{$oid_cpqRackCommonEnclosureFanSparePartNumber . '.' . $_}; next if ($self->check_filter(section => 'fan', instance => $fan_index));
next if ($self->check_exclude(section => 'fan', instance => $fan_index));
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan %d condition is %s [part: %s, spare: %s].", $self->{output}->output_add(long_msg => sprintf("fan '%s' condition is %s [part: %s, spare: %s].",
$fan_index, $map_conditions{$fan_condition}, $fan_index, $result->{fan_condition},
$fan_part, $fan_spare)); $result->{fan_part}, $result->{fan_spare}));
my $exit = $self->get_severity(section => 'fan', value => $map_conditions{$fan_condition}); my $exit = $self->get_severity(label => 'default', section => 'fan', instance => $fan_index, value => $result->{fan_condition});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan %d condition is %s", $fan_index, $map_conditions{$fan_condition})); short_msg => sprintf("Fan '%s' condition is %s", $fan_index, $result->{fan_condition}));
} }
} }
} }
1; 1;

View File

@ -37,54 +37,55 @@ my %present_map = (
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB 4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
); );
my $mapping = {
fuse_name => { oid => '.1.3.6.1.4.1.232.22.2.3.1.4.1.4' }, # cpqRackCommonEnclosureFuseEnclosureName
fuse_location => { oid => '.1.3.6.1.4.1.232.22.2.3.1.4.1.5' }, # cpqRackCommonEnclosureFuseLocation
fuse_condition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.4.1.7', map => \%map_conditions }, # cpqRackCommonEnclosureFuseCondition
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{components}->{fuse} = {name => 'fuses', total => 0, skip => 0}; $self->{components}->{fuse} = {name => 'fuses', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking fuse"); $self->{output}->output_add(long_msg => "checking fuse");
return if ($self->check_exclude(section => 'fuse')); return if ($self->check_filter(section => 'fuse'));
my $oid_cpqRackCommonEnclosureFusePresent = '.1.3.6.1.4.1.232.22.2.3.1.4.1.6'; my $oid_cpqRackCommonEnclosureFusePresent = '.1.3.6.1.4.1.232.22.2.3.1.4.1.6';
my $oid_cpqRackCommonEnclosureFuseIndex = '.1.3.6.1.4.1.232.22.2.3.1.4.1.3';
my $oid_cpqRackCommonEnclosureFuseEnclosureName = '.1.3.6.1.4.1.232.22.2.3.1.4.1.4';
my $oid_cpqRackCommonEnclosureFuseLocation = '.1.3.6.1.4.1.232.22.2.3.1.4.1.5';
my $oid_cpqRackCommonEnclosureFuseCondition = '.1.3.6.1.4.1.232.22.2.3.1.4.1.7';
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFusePresent); my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFusePresent);
return if (scalar(keys %$result) <= 0); return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = (); my @get_oids = ();
my @oids_end = (); my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /\.([0-9]+)$/; $key =~ /^$oid_cpqRackCommonEnclosureFusePresent\.(.*)$/;
my $oid_end = $1; my $oid_end = $1;
next if ($present_map{$result->{$key}} ne 'present' && next if ($present_map{$snmp_result->{$key}} ne 'present' &&
$self->absent_problem(section => 'fuse', instance => $oid_end)); $self->absent_problem(section => 'fuse', instance => $oid_end));
push @oids_end, $oid_end; push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackCommonEnclosureFuseIndex . "." . $oid_end, $oid_cpqRackCommonEnclosureFuseEnclosureName . "." . $oid_end, push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
$oid_cpqRackCommonEnclosureFuseLocation . "." . $oid_end, $oid_cpqRackCommonEnclosureFuseCondition . "." . $oid_end;
} }
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) { foreach (@oids_end) {
my $fuse_index = $result->{$oid_cpqRackCommonEnclosureFuseIndex . '.' . $_}; my $fuse_index = $_;
my $fuse_name = $result->{$oid_cpqRackCommonEnclosureFuseEnclosureName . '.' . $_};
my $fuse_location = $result->{$oid_cpqRackCommonEnclosureFuseLocation . '.' . $_};
my $fuse_condition = $result->{$oid_cpqRackCommonEnclosureFuseCondition . '.' . $_};
next if ($self->check_exclude(section => 'fuse', instance => $fuse_index)); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $fuse_index);
next if ($self->check_filter(section => 'fuse', instance => $fuse_index));
$self->{components}->{fuse}->{total}++; $self->{components}->{fuse}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fuse %d status is %s [name: %s, location: %s].", $self->{output}->output_add(long_msg => sprintf("fuse '%s' status is %s [name: %s, location: %s].",
$fuse_index, $map_conditions{$fuse_condition}, $fuse_index, $result->{fuse_condition},
$fuse_name, $fuse_location)); $result->{fuse_name}, $result->{fuse_location}));
my $exit = $self->get_severity(section => 'fuse', value => $map_conditions{$fuse_condition}); my $exit = $self->get_severity(label => 'default', section => 'fuse', instance => $fuse_index, value => $result->{fuse_condition});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fuse %d status is %s", short_msg => sprintf("Fuse '%s' status is %s",
$fuse_index, $map_conditions{$fuse_condition})); $fuse_index, $result->{fuse_condition}));
} }
} }
} }
1; 1;

View File

@ -31,69 +31,57 @@ my %map_conditions = (
4 => 'failed', 4 => 'failed',
); );
my %conditions = (
0 => ['other', 'UNKNOWN'], # maybe on standby mode only!!
1 => ['other', 'CRITICAL'],
2 => ['ok', 'OK'],
3 => ['degraded', 'WARNING'],
4 => ['failed', 'CRITICAL'],
);
my %map_role = ( my %map_role = (
1 => 'Standby', 1 => 'Standby',
2 => 'Active', 2 => 'Active',
); );
my $mapping = {
man_part => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.6' }, # cpqRackCommonEnclosureManagerPartNumber
man_spare => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.7' }, # cpqRackCommonEnclosureManagerSparePartNumber
man_serial => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.8' }, # cpqRackCommonEnclosureManagerSerialNum
man_role => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.9', map => \%map_role }, # cpqRackCommonEnclosureManagerRole
man_condition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.12', map => \%map_conditions }, # cpqRackCommonEnclosureManagerConditio
};
sub check { sub check {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{components}->{manager} = {name => 'managers', total => 0, skip => 0}; $self->{components}->{manager} = { name => 'managers', total => 0, skip => 0 };
return if ($self->check_exclude(section => 'manager')); return if ($self->check_filter(section => 'manager'));
$self->{output}->output_add(long_msg => "checking managers");
# No check if OK
if ((!defined($options{force}) || $options{force} != 1) && $self->{output}->is_status(compare => 'ok', litteral => 1)) {
return ;
}
$self->{output}->output_add(long_msg => "Checking managers");
my $oid_cpqRackCommonEnclosureManagerIndex = '.1.3.6.1.4.1.232.22.2.3.1.6.1.3'; my $oid_cpqRackCommonEnclosureManagerIndex = '.1.3.6.1.4.1.232.22.2.3.1.6.1.3';
my $oid_cpqRackCommonEnclosureManagerPartNumber = '.1.3.6.1.4.1.232.22.2.3.1.6.1.6'; my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureManagerIndex);
my $oid_cpqRackCommonEnclosureManagerSparePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.6.1.7'; return if (scalar(keys %$snmp_result) <= 0);
my $oid_cpqRackCommonEnclosureManagerSerialNum = '.1.3.6.1.4.1.232.22.2.3.1.6.1.8';
my $oid_cpqRackCommonEnclosureManagerRole = '.1.3.6.1.4.1.232.22.2.3.1.6.1.9';
my $oid_cpqRackCommonEnclosureManagerCondition = '.1.3.6.1.4.1.232.22.2.3.1.6.1.12';
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureManagerIndex); my @get_oids = ();
return if (scalar(keys %$result) <= 0); my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$self->{snmp}->load(oids => [$oid_cpqRackCommonEnclosureManagerPartNumber, $oid_cpqRackCommonEnclosureManagerSparePartNumber, $key =~ /^$oid_cpqRackCommonEnclosureManagerIndex\.(.*)$/;
$oid_cpqRackCommonEnclosureManagerSerialNum, $oid_cpqRackCommonEnclosureManagerRole, my $oid_end = $1;
$oid_cpqRackCommonEnclosureManagerCondition], push @oids_end, $oid_end;
instances => [keys %$result]); push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
my $result2 = $self->{snmp}->get_leef(); }
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)$/; $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
my $instance = $1; foreach (@oids_end) {
my $instance = $_;
my $man_part = $result2->{$oid_cpqRackCommonEnclosureManagerPartNumber . '.' . $instance}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
my $man_spare = $result2->{$oid_cpqRackCommonEnclosureManagerSparePartNumber . '.' . $instance};
my $man_serial = $result2->{$oid_cpqRackCommonEnclosureManagerSerialNum . '.' . $instance};
my $man_role = $result2->{$oid_cpqRackCommonEnclosureManagerRole . '.' . $instance};
my $man_condition = $result2->{$oid_cpqRackCommonEnclosureManagerCondition . '.' . $instance};
next if ($self->check_exclude(section => 'manager', instance => $instance)); next if ($self->check_filter(section => 'manager', instance => $instance));
$self->{components}->{manager}->{total}++; $self->{components}->{manager}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Enclosure management module %d is %s, status is %s [serial: %s, part: %s, spare: %s].", $self->{output}->output_add(long_msg => sprintf("enclosure management module '%s' is %s, status is %s [serial: %s, part: %s, spare: %s].",
$instance, $map_conditions{$man_condition}, $map_role{$man_role}, $instance, $result->{man_condition}, $result->{man_role},
$man_serial, $man_part, $man_spare)); $result->{man_serial}, $result->{man_part}, $result->{man_spare}));
my $exit = $self->get_severity(section => 'manager', value => $map_conditions{$man_condition}); my $exit = $self->get_severity(label => 'default', section => 'manager', instance => $instance, value => $result->{man_condition});
if ($man_role == 2 && !$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if ($result->{man_role} eq 'Active' && !$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Enclosure management module %d is %s, status is %s", short_msg => sprintf("Enclosure management module '%s' is %s, status is %s",
$instance, $map_conditions{$man_condition}, $map_role{$man_role})); $instance, $result->{man_condition}, $result->{man_role}));
} }
} }
} }
1; 1;

View File

@ -39,53 +39,51 @@ my %device_type = (
6 => 'pciexpress', 6 => 'pciexpress',
); );
my $mapping = {
nc_model => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.6' }, # cpqRackNetConnectorModel
nc_serial => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.7' }, # cpqRackNetConnectorSerialNum
nc_part => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.8' }, # cpqRackNetConnectorPartNumber
nc_spare => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.9' }, # cpqRackNetConnectorSparePartNumber
nc_device => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.17', map => \%device_type }, # cpqRackNetConnectorDeviceType
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{components}->{network} = {name => 'network connectors', total => 0, skip => 0}; $self->{components}->{network} = {name => 'network connectors', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking network connectors"); $self->{output}->output_add(long_msg => "checking network connectors");
return if ($self->check_exclude(section => 'network')); return if ($self->check_filter(section => 'network'));
my $oid_cpqRackNetConnectorPresent = '.1.3.6.1.4.1.232.22.2.6.1.1.1.13'; my $oid_cpqRackNetConnectorPresent = '.1.3.6.1.4.1.232.22.2.6.1.1.1.13';
my $oid_cpqRackNetConnectorIndex = '.1.3.6.1.4.1.232.22.2.6.1.1.1.3';
my $oid_cpqRackNetConnectorModel = '.1.3.6.1.4.1.232.22.2.6.1.1.1.6';
my $oid_cpqRackNetConnectorSerialNum = '.1.3.6.1.4.1.232.22.2.6.1.1.1.7';
my $oid_cpqRackNetConnectorPartNumber = '.1.3.6.1.4.1.232.22.2.6.1.1.1.8';
my $oid_cpqRackNetConnectorSparePartNumber = '.1.3.6.1.4.1.232.22.2.6.1.1.1.9';
my $oid_cpqRackNetConnectorDeviceType = '.1.3.6.1.4.1.232.22.2.6.1.1.1.17';
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackNetConnectorPresent); my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackNetConnectorPresent);
return if (scalar(keys %$result) <= 0); return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = (); my @get_oids = ();
my @oids_end = (); my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
next if ($present_map{$result->{$key}} ne 'present'); next if ($present_map{$snmp_result->{$key}} ne 'present');
$key =~ /\.([0-9]+)$/; $key =~ /^$oid_cpqRackNetConnectorPresent\.(.*)$/;
my $oid_end = $1; my $oid_end = $1;
push @oids_end, $oid_end; push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackNetConnectorIndex . "." . $oid_end, $oid_cpqRackNetConnectorModel . "." . $oid_end, push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
$oid_cpqRackNetConnectorSerialNum . "." . $oid_end, $oid_cpqRackNetConnectorPartNumber . "." . $oid_end,
$oid_cpqRackNetConnectorSparePartNumber . "." . $oid_end, $oid_cpqRackNetConnectorDeviceType . "." . $oid_end;
} }
$result = $self->{snmp}->get_leef(oids => \@get_oids); $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) { foreach (@oids_end) {
my $nc_index = $result->{$oid_cpqRackNetConnectorIndex . '.' . $_}; my $nc_index = $_;
my $nc_model = $result->{$oid_cpqRackNetConnectorModel . '.' . $_}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
my $nc_serial = $result->{$oid_cpqRackNetConnectorSerialNum . '.' . $_};
my $nc_part = $result->{$oid_cpqRackNetConnectorPartNumber . '.' . $_}; next if ($self->check_filter(section => 'network', instance => $nc_index));
my $nc_spare = $result->{$oid_cpqRackNetConnectorSparePartNumber . '.' . $_};
my $nc_device = $result->{$oid_cpqRackNetConnectorDeviceType . '.' . $_};
next if ($self->check_exclude(section => 'network', instance => $nc_index));
$self->{components}->{network}->{total}++; $self->{components}->{network}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Network Connector %d (%s) type '%s' is present [serial: %s, part: %s, spare: %s].", $self->{output}->output_add(
$nc_index, $nc_model, long_msg => sprintf("network connector '%s' (%s) type '%s' is present [serial: %s, part: %s, spare: %s].",
$device_type{$nc_device}, $nc_index, $result->{nc_model},
$nc_serial, $nc_part, $nc_spare $result->{nc_device},
)); $result->{nc_serial}, $result->{nc_part}, $result->{nc_spare}
)
);
} }
} }
1; 1;

View File

@ -64,6 +64,18 @@ my %inputline_status_map = (
6 => 'linePowerLoss', 6 => 'linePowerLoss',
); );
my $mapping = {
psu_status => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.14', map => \%psu_status_map }, # cpqRackPowerSupplyStatus
psu_serial => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.5' }, # cpqRackPowerSupplySerialNum
psu_part => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.6' }, # cpqRackPowerSupplyPartNumber
psu_spare => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.7' }, # cpqRackPowerSupplySparePartNumber
psu_inputlinestatus => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.15', map => \%inputline_status_map }, # cpqRackPowerSupplyInputLineStatus
psu_condition => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.17', map => \%map_conditions }, # cpqRackPowerSupplyCondition
psu_pwrout => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.10' }, # cpqRackPowerSupplyCurPwrOutput in Watts
psu_intemp => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.12' }, # cpqRackPowerSupplyIntakeTemp
psu_exhtemp => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.13' }, # cpqRackPowerSupplyExhaustTemp
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
@ -71,91 +83,72 @@ sub check {
# We check 'cpqRackPowerSupplyTable' (unitary) # We check 'cpqRackPowerSupplyTable' (unitary)
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking power supplies"); $self->{output}->output_add(long_msg => "checking power supplies");
return if ($self->check_exclude(section => 'psu')); return if ($self->check_filter(section => 'psu'));
my $oid_cpqRackPowerSupplyPresent = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16'; my $oid_cpqRackPowerSupplyPresent = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16';
my $oid_cpqRackPowerSupplyIndex = '.1.3.6.1.4.1.232.22.2.5.1.1.1.3';
my $oid_cpqRackPowerSupplySerialNum = '.1.3.6.1.4.1.232.22.2.5.1.1.1.5';
my $oid_cpqRackPowerSupplyPartNumber = '.1.3.6.1.4.1.232.22.2.5.1.1.1.6';
my $oid_cpqRackPowerSupplySparePartNumber = '.1.3.6.1.4.1.232.22.2.5.1.1.1.7';
my $oid_cpqRackPowerSupplyStatus = '.1.3.6.1.4.1.232.22.2.5.1.1.1.14';
my $oid_cpqRackPowerSupplyInputLineStatus = '.1.3.6.1.4.1.232.22.2.5.1.1.1.15';
my $oid_cpqRackPowerSupplyCondition = '.1.3.6.1.4.1.232.22.2.5.1.1.1.17';
my $oid_cpqRackPowerSupplyCurPwrOutput = '.1.3.6.1.4.1.232.22.2.5.1.1.1.10'; # Watts
my $oid_cpqRackPowerSupplyIntakeTemp = '.1.3.6.1.4.1.232.22.2.5.1.1.1.12';
my $oid_cpqRackPowerSupplyExhaustTemp = '.1.3.6.1.4.1.232.22.2.5.1.1.1.13';
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackPowerSupplyPresent); my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackPowerSupplyPresent);
return if (scalar(keys %$result) <= 0); return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = (); my @get_oids = ();
my @oids_end = (); my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) { foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /\.([0-9]+)$/; $key =~ /^$oid_cpqRackPowerSupplyPresent\.(.*)$/;
my $oid_end = $1; my $oid_end = $1;
next if ($present_map{$result->{$key}} ne 'present' && next if ($present_map{$snmp_result->{$key}} ne 'present' &&
$self->absent_problem(section => 'psu', instance => $oid_end)); $self->absent_problem(section => 'psu', instance => $oid_end));
push @oids_end, $oid_end; push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackPowerSupplyIndex . "." . $oid_end, $oid_cpqRackPowerSupplySerialNum . "." . $oid_end, push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
$oid_cpqRackPowerSupplyPartNumber . "." . $oid_end, $oid_cpqRackPowerSupplySparePartNumber . "." . $oid_end,
$oid_cpqRackPowerSupplyStatus . "." . $oid_end, $oid_cpqRackPowerSupplyInputLineStatus . "." . $oid_end,
$oid_cpqRackPowerSupplyCondition . "." . $oid_end, $oid_cpqRackPowerSupplyCurPwrOutput . "." . $oid_end,
$oid_cpqRackPowerSupplyIntakeTemp . "." . $oid_end, $oid_cpqRackPowerSupplyExhaustTemp . "." . $oid_end;
} }
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
my $total_watts = 0; my $total_watts = 0;
foreach (@oids_end) { foreach (@oids_end) {
my $psu_index = $result->{$oid_cpqRackPowerSupplyIndex . '.' . $_}; my $psu_index = $_;
my $psu_status = $result->{$oid_cpqRackPowerSupplyStatus . '.' . $_}; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
my $psu_serial = $result->{$oid_cpqRackPowerSupplySerialNum . '.' . $_};
my $psu_part = $result->{$oid_cpqRackPowerSupplyPartNumber . '.' . $_}; next if ($self->check_filter(section => 'psu', instance => $psu_index));
my $psu_spare = $result->{$oid_cpqRackPowerSupplySparePartNumber . '.' . $_};
my $psu_inputlinestatus = $result->{$oid_cpqRackPowerSupplyInputLineStatus . '.' . $_};
my $psu_condition = $result->{$oid_cpqRackPowerSupplyCondition . '.' . $_};
my $psu_pwrout = $result->{$oid_cpqRackPowerSupplyCurPwrOutput . '.' . $_};
my $psu_intemp = $result->{$oid_cpqRackPowerSupplyIntakeTemp . '.' . $_};
my $psu_exhtemp = $result->{$oid_cpqRackPowerSupplyExhaustTemp . '.' . $_};
next if ($self->check_exclude(section => 'psu', instance => $psu_index)); $total_watts += $result->{psu_pwrout};
$total_watts += $psu_pwrout;
$self->{components}->{psu}->{total}++; $self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("PSU %d status is %s [serial: %s, part: %s, spare: %s] (input line status %s) (status %s).", $self->{output}->output_add(
$psu_index, $map_conditions{$psu_condition}, long_msg => sprintf("psu '%s' status is %s [serial: %s, part: %s, spare: %s] (input line status %s) (status %s).",
$psu_serial, $psu_part, $psu_spare, $psu_index, $result->{psu_condition},
$inputline_status_map{$psu_inputlinestatus}, $result->{psu_serial}, $result->{psu_part}, $result->{psu_spare},
$psu_status_map{$psu_status} $result->{psu_inputlinestatus},
)); $result->{psu_status}
)
);
my $exit = $self->get_severity(section => 'psu', value => $map_conditions{$psu_condition}); my $exit = $self->get_severity(label => 'default', section => 'psu', instance => $psu_index, value => $result->{psu_condition});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("PSU %d status is %s", short_msg => sprintf("PSU '%s' status is %s",
$psu_index, $map_conditions{$psu_condition})); $psu_index, $result->{psu_condition}));
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'psu_power', unit => 'W', label => 'psu_power', unit => 'W',
nlabel => 'hardware.powersupply.power.watt', nlabel => 'hardware.powersupply.power.watt',
instances => $psu_index, instances => $psu_index,
value => $psu_pwrout value => $result->{psu_pwrout}
); );
if (defined($psu_intemp) && $psu_intemp != -1) { if (defined($result->{psu_intemp}) && $result->{psu_intemp} != -1) {
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'psu_temp', unit => 'C', label => 'psu_temp', unit => 'C',
nlabel => 'hardware.powersupply.temperature.celsius', nlabel => 'hardware.powersupply.temperature.celsius',
instances => [$psu_index, 'intake'], instances => [$psu_index, 'intake'],
value => $psu_intemp value => $result->{psu_intemp}
); );
} }
if (defined($psu_exhtemp) && $psu_exhtemp != -1) { if (defined($result->{psu_exhtemp}) && $result->{psu_exhtemp} != -1) {
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'psu_temp', unit => 'C', label => 'psu_temp', unit => 'C',
nlabel => 'hardware.powersupply.temperature.celsius', nlabel => 'hardware.powersupply.temperature.celsius',
instances => [$psu_index, 'exhaust'], instances => [$psu_index, 'exhaust'],
value => $psu_exhtemp value => $result->{psu_exhtemp}
); );
} }
} }

View File

@ -23,87 +23,81 @@ package hardware::server::hp::bladechassis::snmp::mode::components::temperature;
use strict; use strict;
use warnings; use warnings;
my %map_conditions = ( my $map_conditions = {
1 => 'other', 1 => 'other',
2 => 'ok', 2 => 'ok',
3 => 'degraded', 3 => 'degraded',
4 => 'failed', 4 => 'failed',
); };
my %present_map = ( my $map_temp_type = {
1 => 'other',
2 => 'absent',
3 => 'present',
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
);
my %map_temp_type = (
1 => 'other', 1 => 'other',
5 => 'blowout', 5 => 'blowout',
9 => 'caution', 9 => 'caution',
15 => 'critical', 15 => 'critical',
); };
my $mapping = {
temp_name => { oid => '.1.3.6.1.4.1.232.22.2.3.1.2.1.4' }, # cpqRackCommonEnclosureTempSensorEnclosureName
temp_location => { oid => '.1.3.6.1.4.1.232.22.2.3.1.2.1.5' }, # cpqRackCommonEnclosureTempLocation
temp_current => { oid => '.1.3.6.1.4.1.232.22.2.3.1.2.1.6' }, # cpqRackCommonEnclosureTempCurrent
temp_threshold => { oid => '.1.3.6.1.4.1.232.22.2.3.1.2.1.7' }, # cpqRackCommonEnclosureTempThreshold
temp_condition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.2.1.8', map => $map_conditions }, # cpqRackCommonEnclosureTempCondition
temp_type => { oid => '.1.3.6.1.4.1.232.22.2.3.1.2.1.9', map => $map_temp_type }, # cpqRackCommonEnclosureTempType
};
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
$self->{output}->output_add(long_msg => "Checking temperatures"); $self->{output}->output_add(long_msg => "checking temperatures");
return if ($self->check_exclude(section => 'temperature')); return if ($self->check_filter(section => 'temperature'));
my $oid_cpqRackCommonEnclosureTempSensorIndex = '.1.3.6.1.4.1.232.22.2.3.1.2.1.3'; my $oid_cpqRackCommonEnclosureTempSensorIndex = '.1.3.6.1.4.1.232.22.2.3.1.2.1.3';
my $oid_cpqRackCommonEnclosureTempSensorEnclosureName = '.1.3.6.1.4.1.232.22.2.3.1.2.1.4';
my $oid_cpqRackCommonEnclosureTempLocation = '.1.3.6.1.4.1.232.22.2.3.1.2.1.5';
my $oid_cpqRackCommonEnclosureTempCurrent = '.1.3.6.1.4.1.232.22.2.3.1.2.1.6';
my $oid_cpqRackCommonEnclosureTempThreshold = '.1.3.6.1.4.1.232.22.2.3.1.2.1.7';
my $oid_cpqRackCommonEnclosureTempCondition = '.1.3.6.1.4.1.232.22.2.3.1.2.1.8';
my $oid_cpqRackCommonEnclosureTempType = '.1.3.6.1.4.1.232.22.2.3.1.2.1.9';
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureTempSensorIndex); my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureTempSensorIndex);
return if (scalar(keys %$result) <= 0); return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = ();
my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /^$oid_cpqRackCommonEnclosureTempSensorIndex\.(.*)$/;
my $oid_end = $1;
push @oids_end, $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$self->{snmp}->load(oids => [$oid_cpqRackCommonEnclosureTempSensorEnclosureName, $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
$oid_cpqRackCommonEnclosureTempLocation, foreach (@oids_end) {
$oid_cpqRackCommonEnclosureTempCurrent, $oid_cpqRackCommonEnclosureTempThreshold, my $temp_index = $_;
$oid_cpqRackCommonEnclosureTempCondition, $oid_cpqRackCommonEnclosureTempType], my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $temp_index);
instances => [keys %$result]);
my $result2 = $self->{snmp}->get_leef();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /\.(\d+)$/;
my $temp_index = $1;
my $temp_name = $result2->{$oid_cpqRackCommonEnclosureTempSensorEnclosureName . '.' . $temp_index};
my $temp_location = $result2->{$oid_cpqRackCommonEnclosureTempLocation . '.' . $temp_index};
my $temp_current = $result2->{$oid_cpqRackCommonEnclosureTempCurrent . '.' . $temp_index};
my $temp_threshold = $result2->{$oid_cpqRackCommonEnclosureTempThreshold . '.' . $temp_index};
my $temp_condition = $result2->{$oid_cpqRackCommonEnclosureTempCondition . '.' . $temp_index};
my $temp_type = $result2->{$oid_cpqRackCommonEnclosureTempType . '.' . $temp_index};
if ($temp_current == -1) { if ($result->{temp_current} == -1) {
$self->{output}->output_add(long_msg => sprintf("Skipping instance $temp_index: current -1")); $self->{output}->output_add(long_msg => sprintf("skipping instance $temp_index: current -1"), debug => 1);
next; next;
} }
next if ($self->check_exclude(section => 'temperature', instance => $temp_index)); next if ($self->check_filter(section => 'temperature', instance => $temp_index));
$self->{components}->{temperature}->{total}++; $self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature %d status is %s [name: %s, location: %s] (value = %s, threshold = %s%s).", $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is %s [name: %s, location: %s] (value = %s, threshold = %s%s).",
$temp_index, $map_conditions{$temp_condition}, $temp_index, $result->{temp_condition},
$temp_name, $temp_location, $result->{temp_name}, $result->{temp_location},
$temp_current, $temp_threshold, $result->{temp_current}, $result->{temp_threshold},
defined($map_temp_type{$temp_type}) ? ", status type = " . $map_temp_type{$temp_type} : '')); defined($result->{temp_type}) ? ", status type = " . $result->{temp_type} : ''));
my $exit = $self->get_severity(section => 'temperature', value => $map_conditions{$temp_condition}); my $exit = $self->get_severity(label => 'default', section => 'temperature', instance => $temp_index, value => $result->{temp_condition});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature %d status is %s", short_msg => sprintf("Temperature '%s' status is %s",
$temp_index, $map_conditions{$temp_condition})); $temp_index, $result->{temp_condition}));
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => "temp", unit => 'C', label => "temp", unit => 'C',
nlabel => 'hardware.temperature.celsius', nlabel => 'hardware.temperature.celsius',
instances => $temp_index, instances => $temp_index,
value => $temp_current, value => $result->{temp_current},
warning => $temp_threshold warning => $result->{temp_threshold}
); );
} }
} }

View File

@ -20,252 +20,77 @@
package hardware::server::hp::bladechassis::snmp::mode::hardware; package hardware::server::hp::bladechassis::snmp::mode::hardware;
use base qw(centreon::plugins::mode); use base qw(centreon::plugins::templates::hardware);
use strict; use strict;
use warnings; use warnings;
use hardware::server::hp::bladechassis::snmp::mode::components::enclosure; use centreon::plugins::misc;
use hardware::server::hp::bladechassis::snmp::mode::components::manager;
use hardware::server::hp::bladechassis::snmp::mode::components::fan;
use hardware::server::hp::bladechassis::snmp::mode::components::blade;
use hardware::server::hp::bladechassis::snmp::mode::components::network;
use hardware::server::hp::bladechassis::snmp::mode::components::psu;
use hardware::server::hp::bladechassis::snmp::mode::components::temperature;
use hardware::server::hp::bladechassis::snmp::mode::components::fuse;
my $thresholds = { sub set_system {
temperature => [ my ($self, %options) = @_;
['other', 'CRITICAL'],
['ok', 'OK'], $self->{regexp_threshold_overload_check_section_option} =
['degraded', 'WARNING'], '^(enclosure|manager|fan|blade|network|psu|temperature|fuse)$';
['failed', 'CRITICAL'],
], $self->{cb_hook2} = 'snmp_execute';
blade => [
['other', 'CRITICAL'], $self->{thresholds} = {
['ok', 'OK'], default => [
['degraded', 'WARNING'], ['other', 'CRITICAL'],
['failed', 'CRITICAL'], ['ok', 'OK'],
], ['degraded', 'WARNING'],
enclosure => [ ['failed', 'CRITICAL'],
['other', 'CRITICAL'], ],
['ok', 'OK'], };
['degraded', 'WARNING'],
['failed', 'CRITICAL'], $self->{components_exec_load} = 0;
],
fan => [ $self->{components_path} = 'hardware::server::hp::bladechassis::snmp::mode::components';
['other', 'CRITICAL'], $self->{components_module} = [
['ok', 'OK'], 'enclosure', 'manager', 'fan', 'blade', 'network', 'psu', 'temperature', 'fuse'
['degraded', 'WARNING'], ];
['failed', 'CRITICAL'], }
],
fuse => [ sub snmp_execute {
['other', 'CRITICAL'], my ($self, %options) = @_;
['ok', 'OK'],
['degraded', 'WARNING'], $self->{snmp} = $options{snmp};
['failed', 'CRITICAL'], }
],
manager => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
psu => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
};
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {});
{
"exclude:s" => { name => 'exclude' },
"absent-problem:s" => { name => 'absent' },
"component:s" => { name => 'component', default => 'all' },
"no-component:s" => { name => 'no_component' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{components} = {};
$self->{no_components} = undef;
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $status, $filter) = ($1, $2, $3);
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
if (defined($self->{option_results}->{no_component})) {
if ($self->{option_results}->{no_component} ne '') {
$self->{no_components} = $self->{option_results}->{no_component};
} else {
$self->{no_components} = 'critical';
}
}
}
sub global {
my ($self, %options) = @_;
hardware::server::hp::bladechassis::snmp::mode::components::enclosure::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::manager::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::fan::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::blade::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::network::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::psu::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::temperature::check($self);
hardware::server::hp::bladechassis::snmp::mode::components::fuse::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 'enclosure') {
hardware::server::hp::bladechassis::snmp::mode::components::enclosure::check($self);
} elsif ($self->{option_results}->{component} eq 'manager') {
hardware::server::hp::bladechassis::snmp::mode::components::manager::check($self, force => 1);
} elsif ($self->{option_results}->{component} eq 'fan') {
hardware::server::hp::bladechassis::snmp::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'blade') {
hardware::server::hp::bladechassis::snmp::mode::components::blade::check($self);
} elsif ($self->{option_results}->{component} eq 'network') {
hardware::server::hp::bladechassis::snmp::mode::components::network::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
hardware::server::hp::bladechassis::snmp::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
hardware::server::hp::bladechassis::snmp::mode::components::temperature::check($self);
} elsif ($self->{option_results}->{component} eq 'fuse') {
hardware::server::hp::bladechassis::snmp::mode::components::fuse::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 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $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)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, %options) = @_;
if (defined($options{instance})) {
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
$self->{components}->{$options{section}}->{skip}++;
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
}
return 0;
}
sub absent_problem {
my ($self, %options) = @_;
if (defined($self->{option_results}->{absent}) &&
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Component '%s' instance '%s' is not present",
$options{section}, $options{instance}));
}
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
$self->{components}->{$options{section}}->{skip}++;
return 1;
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'UNKNOWN'; # default
if (defined($self->{overload_th}->{$options{section}})) {
foreach (@{$self->{overload_th}->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i) {
$status = $_->{status};
return $status;
}
}
}
foreach (@{$thresholds->{$options{section}}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
1; 1;
__END__ __END__
=head1 MODE =head1 MODE
Check Hardware (Fans, Power Supplies, Blades, Temperatures, Fuses). Check hardware.
=over 8 =over 8
=item B<--component> =item B<--component>
Which component to check (Default: 'all'). Which component to check (Default: '.*').
Can be: 'enclosure', 'manager', 'fan', 'blade', 'network', 'psu', 'temperature', 'fuse'. Can be: 'enclosure', 'manager', 'fan', 'blade', 'network', 'psu', 'temperature', 'fuse'.
=item B<--exclude> =item B<--filter>
Exclude some parts (comma seperated list) (Example: --exclude=temperature,psu). Exclude some parts (comma seperated list) (Example: --filter=psu)
Can also exclude specific instance: --exclude=temperature#1# Can also exclude specific instance: --filter=temperature,1
=item B<--absent-problem> =item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list) Return an error if an entity is not 'present' (default is skipping)
Can be specific or global: --absent-problem=blade#12# Can be specific or global: --absent-problem="blade,12"
=item B<--no-component> =item B<--no-component>
@ -274,7 +99,7 @@ If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload> =item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp) Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays). It used before default thresholds (order stays).
Example: --threshold-overload='temperature,OK,other' Example: --threshold-overload='temperature,OK,other'