Debian Codegraph @

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