fix pdu apc duplicated name
This commit is contained in:
parent
7f46a861bc
commit
92182157fc
|
@ -88,9 +88,9 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"unknown-status:s" => { name => 'unknown_status', default => '' },
|
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /off/i' },
|
'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /off/i' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -134,18 +134,26 @@ sub check_rpdu {
|
||||||
my $oid_rPDUOutletStatusEntry = '.1.3.6.1.4.1.318.1.1.12.3.5.1.1';
|
my $oid_rPDUOutletStatusEntry = '.1.3.6.1.4.1.318.1.1.12.3.5.1.1';
|
||||||
my $snmp_result = $options{snmp}->get_table(oid => $oid_rPDUOutletStatusEntry, nothing_quit => 1);
|
my $snmp_result = $options{snmp}->get_table(oid => $oid_rPDUOutletStatusEntry, nothing_quit => 1);
|
||||||
|
|
||||||
|
my $duplicated = {};
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
next if ($oid !~ /^$mapping->{rPDUOutletStatusOutletState}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{rPDUOutletStatusOutletState}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
|
|
||||||
if (defined($self->{outlet}->{$result->{rPDUOutletStatusOutletName}})) {
|
my $name = $result->{rPDUOutletStatusOutletName};
|
||||||
$self->{output}->output_add(long_msg => "skipping instance '" . $result->{rPDUOutletStatusOutletName} . "' [$instance]: name duplicated");
|
$name = $instance if (defined($duplicated->{$name}));
|
||||||
next;
|
if (defined($self->{outlet}->{$name})) {
|
||||||
|
$duplicated->{$name} = 1;
|
||||||
|
my $instance2 = $self->{outlet}->{$name}->{instance};
|
||||||
|
$self->{outlet}->{$instance2} = $self->{outlet}->{$name};
|
||||||
|
$self->{outlet}->{$instance2}->{display} = $instance2;
|
||||||
|
delete $self->{outlet}->{$name};
|
||||||
|
$name = $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{outlet}->{$result->{rPDUOutletStatusOutletName}} = {
|
$self->{outlet}->{$name} = {
|
||||||
display => $result->{rPDUOutletStatusOutletName},
|
instance => $instance,
|
||||||
|
display => $name,
|
||||||
status => $result->{rPDUOutletStatusOutletState},
|
status => $result->{rPDUOutletStatusOutletState},
|
||||||
bank => $result->{rPDUOutletStatusOutletBank},
|
bank => $result->{rPDUOutletStatusOutletBank},
|
||||||
phase => $result->{rPDUOutletStatusOutletPhase},
|
phase => $result->{rPDUOutletStatusOutletPhase},
|
||||||
|
@ -183,18 +191,25 @@ sub check_rpdu2 {
|
||||||
return_type => 1,
|
return_type => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $duplicated = {};
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
next if ($oid !~ /^$mapping->{rPDU2OutletSwitchedStatusState}->{oid}\.(.*)$/);
|
next if ($oid !~ /^$mapping->{rPDU2OutletSwitchedStatusState}->{oid}\.(.*)$/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
|
|
||||||
my $name = $result->{rPDU2OutletSwitchedStatusName} . ' bank ' . $result->{rPDU2OutletSwitchedPropertiesBank};
|
my $name = $result->{rPDU2OutletSwitchedStatusName} . ' bank ' . $result->{rPDU2OutletSwitchedPropertiesBank};
|
||||||
|
$name = $instance if (defined($duplicated->{$name}));
|
||||||
if (defined($self->{outlet}->{$name})) {
|
if (defined($self->{outlet}->{$name})) {
|
||||||
$self->{output}->output_add(long_msg => "skipping instance '" . $name . "' [$instance]: name duplicated");
|
$duplicated->{$name} = 1;
|
||||||
next;
|
my $instance2 = $self->{outlet}->{$name}->{instance};
|
||||||
|
$self->{outlet}->{$instance2} = $self->{outlet}->{$name};
|
||||||
|
$self->{outlet}->{$instance2}->{display} = $instance2;
|
||||||
|
delete $self->{outlet}->{$name};
|
||||||
|
$name = $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{outlet}->{$name} = {
|
$self->{outlet}->{$name} = {
|
||||||
|
instance => $instance,
|
||||||
display => $name,
|
display => $name,
|
||||||
status => $result->{rPDU2OutletSwitchedStatusState},
|
status => $result->{rPDU2OutletSwitchedStatusState},
|
||||||
bank => '',
|
bank => '',
|
||||||
|
|
Loading…
Reference in New Issue