| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::alcatel::omniswitch::snmp::mode::components::unknown; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use network::alcatel::omniswitch::snmp::mode::components::resources qw(%oids $mapping); |
| 26 |
|
| 27 |
sub load {} |
| 28 |
|
| 29 |
sub check { |
| 30 |
my ($self) = @_; |
| 31 |
|
| 32 |
$self->{output}->output_add(long_msg => "Checking unknown"); |
| 33 |
$self->{components}->{unknown} = {name => 'unknowns', total => 0, skip => 0}; |
| 34 |
return if ($self->check_filter(section => 'unknown')); |
| 35 |
|
| 36 |
my @instances = (); |
| 37 |
foreach my $key (keys %{$self->{results}->{$oids{common}->{entPhysicalClass}}}) { |
| 38 |
if ($self->{results}->{$oids{common}->{entPhysicalClass}}->{$key} == 2) { |
| 39 |
next if ($key !~ /^$oids{common}->{entPhysicalClass}\.(.*)$/); |
| 40 |
push @instances, $1; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
foreach my $instance (@instances) { |
| 45 |
next if (!defined($self->{results}->{entity}->{$oids{$self->{type}}->{chasEntPhysAdminStatus} . '.' . $instance})); |
| 46 |
|
| 47 |
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{type}}, results => $self->{results}->{entity}, instance => $instance); |
| 48 |
|
| 49 |
next if ($self->check_filter(section => 'unknown', instance => $instance)); |
| 50 |
$self->{components}->{unknown}->{total}++; |
| 51 |
|
| 52 |
$self->{output}->output_add( |
| 53 |
long_msg => sprintf( |
| 54 |
"unknown '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", |
| 55 |
$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance, |
| 56 |
$result->{chasEntPhysAdminStatus}, $result->{chasEntPhysOperStatus} |
| 57 |
) |
| 58 |
); |
| 59 |
|
| 60 |
if ($result->{chasEntPhysPower} > 0) { |
| 61 |
$self->{output}->perfdata_add( |
| 62 |
nlabel => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], |
| 63 |
unit => 'W', |
| 64 |
instances => $instance, |
| 65 |
value => $result->{chasEntPhysPower}, |
| 66 |
min => 0 |
| 67 |
); |
| 68 |
} |
| 69 |
|
| 70 |
my $exit = $self->get_severity(label => 'admin', section => 'unknown.admin', value => $result->{chasEntPhysAdminStatus}); |
| 71 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 72 |
$self->{output}->output_add( |
| 73 |
severity => $exit, |
| 74 |
short_msg => sprintf( |
| 75 |
"unknown '%s/%s/%s' admin status is %s", |
| 76 |
$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance, |
| 77 |
$result->{chasEntPhysAdminStatus} |
| 78 |
) |
| 79 |
); |
| 80 |
next; |
| 81 |
} |
| 82 |
|
| 83 |
$exit = $self->get_severity(label => 'oper', section => 'unknown.oper', value => $result->{chasEntPhysOperStatus}); |
| 84 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 85 |
$self->{output}->output_add( |
| 86 |
severity => $exit, |
| 87 |
short_msg => sprintf( |
| 88 |
"unknown '%s/%s/%s' operational status is %s", |
| 89 |
$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance, |
| 90 |
$result->{chasEntPhysOperStatus} |
| 91 |
) |
| 92 |
); |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
1; |