enhance hp bladechassis snmp

This commit is contained in:
garnier-quentin 2019-07-03 13:44:43 +02:00
parent 308d1549cd
commit 9ecbd62a24
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
);
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 {
my ($self) = @_;
$self->{components}->{blade} = {name => 'blades', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking blades");
return if ($self->check_exclude(section => 'blade'));
$self->{output}->output_add(long_msg => "checking blades");
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_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);
return if (scalar(keys %$result) <= 0);
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackServerBladePresent);
return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = ();
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]+)$/;
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));
push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackServerBladeIndex . "." . $oid_end, $oid_cpqRackServerBladeName . "." . $oid_end,
$oid_cpqRackServerBladePartNumber . "." . $oid_end, $oid_cpqRackServerBladeSparePartNumber . "." . $oid_end,
$oid_cpqRackServerBladeProductId . "." . $oid_end,
$oid_cpqRackServerBladeStatus . "." . $oid_end, $oid_cpqRackServerBladeFaultDiagnosticString . "." . $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) {
my $blade_index = $result->{$oid_cpqRackServerBladeIndex . '.' . $_};
my $blade_status = defined($result->{$oid_cpqRackServerBladeStatus . '.' . $_}) ? $result->{$oid_cpqRackServerBladeStatus . '.' . $_} : '';
my $blade_name = $result->{$oid_cpqRackServerBladeName . '.' . $_};
my $blade_part = $result->{$oid_cpqRackServerBladePartNumber . '.' . $_};
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));
my $blade_index = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $blade_index);
next if ($self->check_filter(section => 'blade', instance => $blade_index));
$self->{components}->{blade}->{total}++;
if ($blade_status eq '') {
$self->{output}->output_add(long_msg => sprintf("Skipping Blade %d (%s, %s). Cant get status.",
$blade_index, $blade_name, $blade_productid));
if (!defined($result->{blade_status})) {
$self->{output}->output_add(long_msg => sprintf("skipping blade '%s' (%s, %s). Cant get status.",
$blade_index, $result->{blade_name}, $result->{blade_productid}));
next;
}
$self->{output}->output_add(long_msg => sprintf("Blade %d (%s, %s) status is %s [part: %s, spare: %s]%s.",
$blade_index, $blade_name, $blade_productid,
$map_conditions{$blade_status},
$blade_part, $blade_spare,
($blade_diago ne '') ? " (Diagnostic '$blade_diago')" : ''
));
my $exit = $self->get_severity(section => 'blade', value => $map_conditions{$blade_status});
$self->{output}->output_add(
long_msg => sprintf("blade '%s' (%s, %s) status is %s [part: %s, spare: %s]%s.",
$blade_index, $result->{blade_name}, $result->{blade_productid},
$result->{blade_status},
$result->{blade_part}, $result->{blade_spare},
defined($result->{blade_diago}) ? " (Diagnostic '$result->{blade_diago}')" : ''
)
);
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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Blade %d (%s, %s) status is %s",
$blade_index, $blade_name, $blade_productid,
$map_conditions{$blade_status}
));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Blade '%s' (%s, %s) status is %s",
$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 warnings;
my %map_conditions = (
my $map_conditions = {
1 => 'other',
2 => 'ok',
3 => 'degraded',
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 {
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->{output}->output_add(long_msg => "Checking enclosure");
return if ($self->check_exclude(section => 'enclosure'));
my $result = $self->{snmp}->get_leef(oids => [$oid_cpqRackCommonEnclosurePartNumber, $oid_cpqRackCommonEnclosureSparePartNumber,
$oid_cpqRackCommonEnclosureSerialNum, $oid_cpqRackCommonEnclosureFWRev,
$oid_cpqRackCommonEnclosureCondition], nothing_quit => 1);
$self->{components}->{enclosure}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Enclosure overall health condition is %s [part: %s, spare: %s, sn: %s, fw: %s].",
$map_conditions{$result->{$oid_cpqRackCommonEnclosureCondition}},
$result->{$oid_cpqRackCommonEnclosurePartNumber},
$result->{$oid_cpqRackCommonEnclosureSparePartNumber},
$result->{$oid_cpqRackCommonEnclosureSerialNum},
$result->{$oid_cpqRackCommonEnclosureFWRev}));
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,
short_msg => sprintf("Enclosure overall health condition is %s", $map_conditions{$result->{$oid_cpqRackCommonEnclosureCondition}}));
$self->{output}->output_add(long_msg => "checking enclosure");
return if ($self->check_filter(section => 'enclosure'));
my $oid_cpqRackCommonEnclosurePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.1.1.5';
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosurePartNumber);
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_cpqRackCommonEnclosurePartNumber\.(.*)$/;
my $oid_end = $1;
push @oids_end, $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
my $snmp_result2 = $self->{snmp}->get_leef(oids => \@get_oids);
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
);
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 {
my ($self) = @_;
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking fans");
return if ($self->check_exclude(section => 'fan'));
$self->{output}->output_add(long_msg => "checking fans");
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_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);
return if (scalar(keys %$result) <= 0);
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFanPresent);
return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = ();
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]+)$/;
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));
push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackCommonEnclosureFanIndex . "." . $oid_end, $oid_cpqRackCommonEnclosureFanPartNumber . "." . $oid_end,
$oid_cpqRackCommonEnclosureFanSparePartNumber . "." . $oid_end, $oid_cpqRackCommonEnclosureFanCondition . "." . $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) {
my $fan_index = $result->{$oid_cpqRackCommonEnclosureFanIndex . '.' . $_};
my $fan_condition = $result->{$oid_cpqRackCommonEnclosureFanCondition . '.' . $_};
my $fan_part = $result->{$oid_cpqRackCommonEnclosureFanPartNumber . '.' . $_};
my $fan_spare = $result->{$oid_cpqRackCommonEnclosureFanSparePartNumber . '.' . $_};
next if ($self->check_exclude(section => 'fan', instance => $fan_index));
my $fan_index = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $fan_index);
next if ($self->check_filter(section => 'fan', instance => $fan_index));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan %d condition is %s [part: %s, spare: %s].",
$fan_index, $map_conditions{$fan_condition},
$fan_part, $fan_spare));
my $exit = $self->get_severity(section => 'fan', value => $map_conditions{$fan_condition});
$self->{output}->output_add(long_msg => sprintf("fan '%s' condition is %s [part: %s, spare: %s].",
$fan_index, $result->{fan_condition},
$result->{fan_part}, $result->{fan_spare}));
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)) {
$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
);
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 {
my ($self) = @_;
$self->{components}->{fuse} = {name => 'fuses', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking fuse");
return if ($self->check_exclude(section => 'fuse'));
$self->{output}->output_add(long_msg => "checking 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_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);
return if (scalar(keys %$result) <= 0);
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFusePresent);
return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = ();
my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /\.([0-9]+)$/;
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /^$oid_cpqRackCommonEnclosureFusePresent\.(.*)$/;
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));
push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackCommonEnclosureFuseIndex . "." . $oid_end, $oid_cpqRackCommonEnclosureFuseEnclosureName . "." . $oid_end,
$oid_cpqRackCommonEnclosureFuseLocation . "." . $oid_end, $oid_cpqRackCommonEnclosureFuseCondition . "." . $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) {
my $fuse_index = $result->{$oid_cpqRackCommonEnclosureFuseIndex . '.' . $_};
my $fuse_name = $result->{$oid_cpqRackCommonEnclosureFuseEnclosureName . '.' . $_};
my $fuse_location = $result->{$oid_cpqRackCommonEnclosureFuseLocation . '.' . $_};
my $fuse_condition = $result->{$oid_cpqRackCommonEnclosureFuseCondition . '.' . $_};
my $fuse_index = $_;
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->{output}->output_add(long_msg => sprintf("Fuse %d status is %s [name: %s, location: %s].",
$fuse_index, $map_conditions{$fuse_condition},
$fuse_name, $fuse_location));
my $exit = $self->get_severity(section => 'fuse', value => $map_conditions{$fuse_condition});
$self->{output}->output_add(long_msg => sprintf("fuse '%s' status is %s [name: %s, location: %s].",
$fuse_index, $result->{fuse_condition},
$result->{fuse_name}, $result->{fuse_location}));
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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fuse %d status is %s",
$fuse_index, $map_conditions{$fuse_condition}));
short_msg => sprintf("Fuse '%s' status is %s",
$fuse_index, $result->{fuse_condition}));
}
}
}
1;
1;

View File

@ -31,69 +31,57 @@ my %map_conditions = (
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 = (
1 => 'Standby',
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 {
my ($self, %options) = @_;
$self->{components}->{manager} = {name => 'managers', total => 0, skip => 0};
return if ($self->check_exclude(section => 'manager'));
$self->{components}->{manager} = { name => 'managers', total => 0, skip => 0 };
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_cpqRackCommonEnclosureManagerPartNumber = '.1.3.6.1.4.1.232.22.2.3.1.6.1.6';
my $oid_cpqRackCommonEnclosureManagerSparePartNumber = '.1.3.6.1.4.1.232.22.2.3.1.6.1.7';
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 $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureManagerIndex);
return if (scalar(keys %$snmp_result) <= 0);
my $result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureManagerIndex);
return if (scalar(keys %$result) <= 0);
$self->{snmp}->load(oids => [$oid_cpqRackCommonEnclosureManagerPartNumber, $oid_cpqRackCommonEnclosureManagerSparePartNumber,
$oid_cpqRackCommonEnclosureManagerSerialNum, $oid_cpqRackCommonEnclosureManagerRole,
$oid_cpqRackCommonEnclosureManagerCondition],
instances => [keys %$result]);
my $result2 = $self->{snmp}->get_leef();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /(\d+)$/;
my $instance = $1;
my $man_part = $result2->{$oid_cpqRackCommonEnclosureManagerPartNumber . '.' . $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};
my @get_oids = ();
my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /^$oid_cpqRackCommonEnclosureManagerIndex\.(.*)$/;
my $oid_end = $1;
push @oids_end, $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) {
my $instance = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($self->check_exclude(section => 'manager', instance => $instance));
next if ($self->check_filter(section => 'manager', instance => $instance));
$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].",
$instance, $map_conditions{$man_condition}, $map_role{$man_role},
$man_serial, $man_part, $man_spare));
my $exit = $self->get_severity(section => 'manager', value => $map_conditions{$man_condition});
if ($man_role == 2 && !$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(long_msg => sprintf("enclosure management module '%s' is %s, status is %s [serial: %s, part: %s, spare: %s].",
$instance, $result->{man_condition}, $result->{man_role},
$result->{man_serial}, $result->{man_part}, $result->{man_spare}));
my $exit = $self->get_severity(label => 'default', section => 'manager', instance => $instance, value => $result->{man_condition});
if ($result->{man_role} eq 'Active' && !$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Enclosure management module %d is %s, status is %s",
$instance, $map_conditions{$man_condition}, $map_role{$man_role}));
short_msg => sprintf("Enclosure management module '%s' is %s, status is %s",
$instance, $result->{man_condition}, $result->{man_role}));
}
}
}
1;
1;

View File

@ -39,53 +39,51 @@ my %device_type = (
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 {
my ($self) = @_;
$self->{components}->{network} = {name => 'network connectors', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking network connectors");
return if ($self->check_exclude(section => 'network'));
$self->{output}->output_add(long_msg => "checking network connectors");
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_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);
return if (scalar(keys %$result) <= 0);
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackNetConnectorPresent);
return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = ();
my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($present_map{$result->{$key}} ne 'present');
$key =~ /\.([0-9]+)$/;
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
next if ($present_map{$snmp_result->{$key}} ne 'present');
$key =~ /^$oid_cpqRackNetConnectorPresent\.(.*)$/;
my $oid_end = $1;
push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackNetConnectorIndex . "." . $oid_end, $oid_cpqRackNetConnectorModel . "." . $oid_end,
$oid_cpqRackNetConnectorSerialNum . "." . $oid_end, $oid_cpqRackNetConnectorPartNumber . "." . $oid_end,
$oid_cpqRackNetConnectorSparePartNumber . "." . $oid_end, $oid_cpqRackNetConnectorDeviceType . "." . $oid_end;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) {
my $nc_index = $result->{$oid_cpqRackNetConnectorIndex . '.' . $_};
my $nc_model = $result->{$oid_cpqRackNetConnectorModel . '.' . $_};
my $nc_serial = $result->{$oid_cpqRackNetConnectorSerialNum . '.' . $_};
my $nc_part = $result->{$oid_cpqRackNetConnectorPartNumber . '.' . $_};
my $nc_spare = $result->{$oid_cpqRackNetConnectorSparePartNumber . '.' . $_};
my $nc_device = $result->{$oid_cpqRackNetConnectorDeviceType . '.' . $_};
next if ($self->check_exclude(section => 'network', instance => $nc_index));
my $nc_index = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
next if ($self->check_filter(section => 'network', instance => $nc_index));
$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].",
$nc_index, $nc_model,
$device_type{$nc_device},
$nc_serial, $nc_part, $nc_spare
));
$self->{output}->output_add(
long_msg => sprintf("network connector '%s' (%s) type '%s' is present [serial: %s, part: %s, spare: %s].",
$nc_index, $result->{nc_model},
$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',
);
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 {
my ($self) = @_;
@ -71,91 +83,72 @@ sub check {
# We check 'cpqRackPowerSupplyTable' (unitary)
$self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking power supplies");
return if ($self->check_exclude(section => 'psu'));
$self->{output}->output_add(long_msg => "checking power supplies");
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_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);
return if (scalar(keys %$result) <= 0);
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackPowerSupplyPresent);
return if (scalar(keys %$snmp_result) <= 0);
my @get_oids = ();
my @oids_end = ();
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /\.([0-9]+)$/;
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
$key =~ /^$oid_cpqRackPowerSupplyPresent\.(.*)$/;
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));
push @oids_end, $oid_end;
push @get_oids, $oid_cpqRackPowerSupplyIndex . "." . $oid_end, $oid_cpqRackPowerSupplySerialNum . "." . $oid_end,
$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;
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
}
$result = $self->{snmp}->get_leef(oids => \@get_oids);
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
my $total_watts = 0;
foreach (@oids_end) {
my $psu_index = $result->{$oid_cpqRackPowerSupplyIndex . '.' . $_};
my $psu_status = $result->{$oid_cpqRackPowerSupplyStatus . '.' . $_};
my $psu_serial = $result->{$oid_cpqRackPowerSupplySerialNum . '.' . $_};
my $psu_part = $result->{$oid_cpqRackPowerSupplyPartNumber . '.' . $_};
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 . '.' . $_};
my $psu_index = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
next if ($self->check_filter(section => 'psu', instance => $psu_index));
next if ($self->check_exclude(section => 'psu', instance => $psu_index));
$total_watts += $psu_pwrout;
$total_watts += $result->{psu_pwrout};
$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).",
$psu_index, $map_conditions{$psu_condition},
$psu_serial, $psu_part, $psu_spare,
$inputline_status_map{$psu_inputlinestatus},
$psu_status_map{$psu_status}
));
$self->{output}->output_add(
long_msg => sprintf("psu '%s' status is %s [serial: %s, part: %s, spare: %s] (input line status %s) (status %s).",
$psu_index, $result->{psu_condition},
$result->{psu_serial}, $result->{psu_part}, $result->{psu_spare},
$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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("PSU %d status is %s",
$psu_index, $map_conditions{$psu_condition}));
short_msg => sprintf("PSU '%s' status is %s",
$psu_index, $result->{psu_condition}));
}
$self->{output}->perfdata_add(
label => 'psu_power', unit => 'W',
nlabel => 'hardware.powersupply.power.watt',
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(
label => 'psu_temp', unit => 'C',
nlabel => 'hardware.powersupply.temperature.celsius',
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(
label => 'psu_temp', unit => 'C',
nlabel => 'hardware.powersupply.temperature.celsius',
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 warnings;
my %map_conditions = (
my $map_conditions = {
1 => 'other',
2 => 'ok',
3 => 'degraded',
4 => 'failed',
);
};
my %present_map = (
1 => 'other',
2 => 'absent',
3 => 'present',
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
);
my %map_temp_type = (
my $map_temp_type = {
1 => 'other',
5 => 'blowout',
9 => 'caution',
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 {
my ($self) = @_;
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
$self->{output}->output_add(long_msg => "Checking temperatures");
return if ($self->check_exclude(section => 'temperature'));
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
$self->{output}->output_add(long_msg => "checking temperatures");
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_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);
return if (scalar(keys %$result) <= 0);
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureTempSensorIndex);
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,
$oid_cpqRackCommonEnclosureTempLocation,
$oid_cpqRackCommonEnclosureTempCurrent, $oid_cpqRackCommonEnclosureTempThreshold,
$oid_cpqRackCommonEnclosureTempCondition, $oid_cpqRackCommonEnclosureTempType],
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};
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
foreach (@oids_end) {
my $temp_index = $_;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $temp_index);
if ($temp_current == -1) {
$self->{output}->output_add(long_msg => sprintf("Skipping instance $temp_index: current -1"));
if ($result->{temp_current} == -1) {
$self->{output}->output_add(long_msg => sprintf("skipping instance $temp_index: current -1"), debug => 1);
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->{output}->output_add(long_msg => sprintf("Temperature %d status is %s [name: %s, location: %s] (value = %s, threshold = %s%s).",
$temp_index, $map_conditions{$temp_condition},
$temp_name, $temp_location,
$temp_current, $temp_threshold,
defined($map_temp_type{$temp_type}) ? ", status type = " . $map_temp_type{$temp_type} : ''));
my $exit = $self->get_severity(section => 'temperature', value => $map_conditions{$temp_condition});
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is %s [name: %s, location: %s] (value = %s, threshold = %s%s).",
$temp_index, $result->{temp_condition},
$result->{temp_name}, $result->{temp_location},
$result->{temp_current}, $result->{temp_threshold},
defined($result->{temp_type}) ? ", status type = " . $result->{temp_type} : ''));
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)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature %d status is %s",
$temp_index, $map_conditions{$temp_condition}));
short_msg => sprintf("Temperature '%s' status is %s",
$temp_index, $result->{temp_condition}));
}
$self->{output}->perfdata_add(
label => "temp", unit => 'C',
nlabel => 'hardware.temperature.celsius',
instances => $temp_index,
value => $temp_current,
warning => $temp_threshold
value => $result->{temp_current},
warning => $result->{temp_threshold}
);
}
}

View File

@ -20,252 +20,77 @@
package hardware::server::hp::bladechassis::snmp::mode::hardware;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
use hardware::server::hp::bladechassis::snmp::mode::components::enclosure;
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;
use centreon::plugins::misc;
my $thresholds = {
temperature => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
blade => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
enclosure => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
fan => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
fuse => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
manager => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
psu => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
};
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} =
'^(enclosure|manager|fan|blade|network|psu|temperature|fuse)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['other', 'CRITICAL'],
['ok', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
],
};
$self->{components_exec_load} = 0;
$self->{components_path} = 'hardware::server::hp::bladechassis::snmp::mode::components';
$self->{components_module} = [
'enclosure', 'manager', 'fan', 'blade', 'network', 'psu', 'temperature', 'fuse'
];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
}
sub new {
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;
$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;
$options{options}->add_options(arguments => {});
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;
__END__
=head1 MODE
Check Hardware (Fans, Power Supplies, Blades, Temperatures, Fuses).
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: 'all').
Which component to check (Default: '.*').
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).
Can also exclude specific instance: --exclude=temperature#1#
Exclude some parts (comma seperated list) (Example: --filter=psu)
Can also exclude specific instance: --filter=temperature,1
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=blade#12#
Return an error if an entity is not 'present' (default is skipping)
Can be specific or global: --absent-problem="blade,12"
=item B<--no-component>
@ -274,7 +99,7 @@ If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='temperature,OK,other'