Debian Codegraph @

src/hardware/server/cisco/ucs/snmp/mode/components/iocard.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 hardware::server::cisco::ucs::snmp::mode::components::iocard;
22
23 use strict;
24 use warnings;
25 use hardware::server::cisco::ucs::snmp::mode::components::resources qw(%mapping_presence %mapping_operability);
26
27 # In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB'
28 my $mapping1 = {
29 cucsEquipmentIOCardPresence => { oid => '.1.3.6.1.4.1.9.9.719.1.15.30.1.31', map => \%mapping_presence },
30 };
31 my $mapping2 = {
32 cucsEquipmentIOCardOperState => { oid => '.1.3.6.1.4.1.9.9.719.1.15.30.1.25', map => \%mapping_operability },
33 };
34 my $oid_cucsEquipmentIOCardDn = '.1.3.6.1.4.1.9.9.719.1.15.30.1.2';
35
36 sub load {
37 my ($self) = @_;
38
39 push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentIOCardPresence}->{oid} },
40 { oid => $mapping2->{cucsEquipmentIOCardOperState}->{oid} }, { oid => $oid_cucsEquipmentIOCardDn };
41 }
42
43 sub check {
44 my ($self) = @_;
45
46 # In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB'
47 $self->{output}->output_add(long_msg => "Checking io cards");
48 $self->{components}->{iocard} = {name => 'io cards', total => 0, skip => 0};
49 return if ($self->check_filter(section => 'iocard'));
50
51 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentIOCardDn}})) {
52 $oid =~ /\.(\d+)$/;
53 my $instance = $1;
54 my $iocard_dn = $self->{results}->{$oid_cucsEquipmentIOCardDn}->{$oid};
55 my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsEquipmentIOCardPresence}->{oid}}, instance => $instance);
56 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentIOCardOperState}->{oid}}, instance => $instance);
57
58 next if ($self->absent_problem(section => 'iocard', instance => $iocard_dn));
59 next if ($self->check_filter(section => 'iocard', instance => $iocard_dn));
60
61 $self->{output}->output_add(
62 long_msg => sprintf(
63 "IO cards '%s' state is '%s' [presence: %s].",
64 $iocard_dn, $result2->{cucsEquipmentIOCardOperState},
65 $result->{cucsEquipmentIOCardPresence}
66 )
67 );
68
69 my $exit = $self->get_severity(section => 'iocard.presence', label => 'default.presence', value => $result->{cucsEquipmentIOCardPresence});
70 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
71 $self->{output}->output_add(
72 severity => $exit,
73 short_msg => sprintf(
74 "IO cards '%s' presence is: '%s'",
75 $iocard_dn, $result->{cucsEquipmentIOCardPresence}
76 )
77 );
78 next;
79 }
80
81 $self->{components}->{iocard}->{total}++;
82
83 $exit = $self->get_severity(section => 'iocard.operability', label => 'default.operability', value => $result2->{cucsEquipmentIOCardOperState});
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 "IO cards '%s' state is '%s'.",
89 $iocard_dn, $result2->{cucsEquipmentIOCardOperState}
90 )
91 );
92 }
93 }
94 }
95
96 1;