Debian Codegraph @

src/hardware/server/hp/bladechassis/snmp/mode/components/fuse.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::hp::bladechassis::snmp::mode::components::fuse;
22
23 use strict;
24 use warnings;
25
26 my %map_conditions = (
27 1 => 'other',
28 2 => 'ok',
29 3 => 'degraded',
30 4 => 'failed',
31 );
32
33 my %present_map = (
34 1 => 'other',
35 2 => 'absent',
36 3 => 'present',
37 4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
38 );
39
40 my $mapping = {
41 fuse_name => { oid => '.1.3.6.1.4.1.232.22.2.3.1.4.1.4' }, # cpqRackCommonEnclosureFuseEnclosureName
42 fuse_location => { oid => '.1.3.6.1.4.1.232.22.2.3.1.4.1.5' }, # cpqRackCommonEnclosureFuseLocation
43 fuse_condition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.4.1.7', map => \%map_conditions }, # cpqRackCommonEnclosureFuseCondition
44 };
45
46 sub check {
47 my ($self) = @_;
48
49 $self->{components}->{fuse} = {name => 'fuses', total => 0, skip => 0};
50 $self->{output}->output_add(long_msg => "checking fuse");
51 return if ($self->check_filter(section => 'fuse'));
52
53 my $oid_cpqRackCommonEnclosureFusePresent = '.1.3.6.1.4.1.232.22.2.3.1.4.1.6';
54
55 my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureFusePresent);
56 return if (scalar(keys %$snmp_result) <= 0);
57
58 my @get_oids = ();
59 my @oids_end = ();
60 foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
61 $key =~ /^$oid_cpqRackCommonEnclosureFusePresent\.(.*)$/;
62 my $oid_end = $1;
63
64 next if ($present_map{$snmp_result->{$key}} ne 'present' &&
65 $self->absent_problem(section => 'fuse', instance => $oid_end));
66
67 push @oids_end, $oid_end;
68 push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
69 }
70
71 $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
72 foreach (@oids_end) {
73 my $fuse_index = $_;
74
75 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $fuse_index);
76 next if ($self->check_filter(section => 'fuse', instance => $fuse_index));
77
78 $self->{components}->{fuse}->{total}++;
79 $self->{output}->output_add(long_msg => sprintf("fuse '%s' status is %s [name: %s, location: %s].",
80 $fuse_index, $result->{fuse_condition},
81 $result->{fuse_name}, $result->{fuse_location}));
82 my $exit = $self->get_severity(label => 'default', section => 'fuse', instance => $fuse_index, value => $result->{fuse_condition});
83 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
84 $self->{output}->output_add(severity => $exit,
85 short_msg => sprintf("Fuse '%s' status is %s",
86 $fuse_index, $result->{fuse_condition}));
87 }
88 }
89 }
90
91 1;