Debian Codegraph @

src/network/alcatel/omniswitch/snmp/mode/components/other.pm

raw
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::other;
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 other");
33 $self->{components}->{other} = {name => 'others', total => 0, skip => 0};
34 return if ($self->check_filter(section => 'other'));
35
36 my @instances = ();
37 foreach my $key (keys %{$self->{results}->{$oids{common}->{entPhysicalClass}}}) {
38 if ($self->{results}->{$oids{common}->{entPhysicalClass}}->{$key} == 1) {
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 => 'other', instance => $instance));
50 $self->{components}->{other}->{total}++;
51
52 $self->{output}->output_add(
53 long_msg => sprintf(
54 "other '%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 => 'hardware.other.power.watt',
63 unit => 'W',
64 instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance],
65 value => $result->{chasEntPhysPower},
66 min => 0
67 );
68 }
69
70 my $exit = $self->get_severity(label => 'admin', section => 'other.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 "other '%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 => 'other.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 "other '%s/%s/%s' operational status is %s",
89 $result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance,
90 $result->{chasEntPhysOperStatus}
91 )
92 );
93 }
94 }
95 }
96
97 1;