Merge pull request #2405 from centreon/fix-pr-2403

fix pr-2403
This commit is contained in:
qgarnier 2020-12-04 09:33:34 +01:00 committed by GitHub
commit 68ad5dbda7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 14 deletions

View File

@ -73,36 +73,48 @@ sub new {
return $self; return $self;
} }
my $states = { my $map_status = {
1 => 'other', 2 => 'unknown', 1 => 'other', 2 => 'unknown',
3 => 'ok', 4 => 'nonCritical', 3 => 'ok', 4 => 'nonCritical',
5 => 'critical', 6 => 'nonRecoverable' 5 => 'critical', 6 => 'nonRecoverable'
}; };
my $mapping = {
global_status => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.6', map => $map_status }, # productIDGlobalStatus
build_number => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.7' } # productIDBuildNumber
};
my $mapping_ctrl = {
ctrl_model => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1.7' } # scCtlrModel
};
my $oid_scCtlrEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1';
my $oid_storageCenterObjects = '.1.3.6.1.4.1.674.11000.2000.500.1.2';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $oid_ctlrOneModel = '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1.7.1'; my $snmp_result = $options{snmp}->get_multiple_table(
my $oid_ctlrTwoModel = '.1.3.6.1.4.1.674.11000.2000.500.1.2.13.1.7.2';
my $oid_buildNumber = '.1.3.6.1.4.1.674.11000.2000.500.1.2.7.0';
my $oid_globalStatus = '.1.3.6.1.4.1.674.11000.2000.500.1.2.6.0';
my $snmp_result = $options{snmp}->get_leef(
oids => [ oids => [
$oid_ctlrOneModel, $oid_ctlrTwoModel, $oid_buildNumber, $oid_globalStatus { oid => $oid_storageCenterObjects, start => $mapping->{global_status}->{oid}, end => $mapping->{build_number}->{oid} },
{ oid => $oid_scCtlrEntry, start => $mapping_ctrl->{ctrl_model}->{oid}, end => $mapping_ctrl->{ctrl_model}->{oid} }
], ],
nothing_quit => 1 nothing_quit => 1
); );
my $global_status = $states->{ $snmp_result->{$oid_globalStatus} }; my $display = '';
foreach (keys %{$snmp_result->{$oid_scCtlrEntry}}) {
my $display = $snmp_result->{$oid_ctlrOneModel}; next if (! /^$mapping_ctrl->{ctrl_model}->{oid}\.(.*)$/);
if (!defined($display)) { my $result = $self->{snmp}->map_instance(mapping => $mapping_ctrl, results => $snmp_result->{$oid_scCtlrEntry}, instance => $1);
$display = $snmp_result->{$oid_ctlrTwoModel}; $display = $result->{ctrl_model};
last if (length($display));
} }
$display .= '.' . $snmp_result->{$oid_buildNumber};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_storageCenterObjects}, instance => 0);
$display .= '.' . $result->{build_number};
$self->{global} = { $self->{global} = {
display => $display, display => $display,
status => $global_status status => $result->{global_status}
}; };
} }