Debian Codegraph @

src/hardware/server/cisco/ucs/snmp/mode/components/localdisk.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::localdisk;
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-STORAGE-MIB'
28 my $mapping1 = {
29 cucsStorageLocalDiskPresence => { oid => '.1.3.6.1.4.1.9.9.719.1.45.4.1.10', map => \%mapping_presence }
30 };
31 my $mapping2 = {
32 cucsStorageLocalDiskOperability => { oid => '.1.3.6.1.4.1.9.9.719.1.45.4.1.9', map => \%mapping_operability }
33 };
34 my $oid_cucsStorageLocalDiskDn = '.1.3.6.1.4.1.9.9.719.1.45.4.1.2';
35
36 sub load {
37 my ($self) = @_;
38
39 push @{$self->{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} },
40 { oid => $mapping2->{cucsStorageLocalDiskOperability}->{oid} }, { oid => $oid_cucsStorageLocalDiskDn };
41 }
42
43 sub check {
44 my ($self) = @_;
45
46 $self->{output}->output_add(long_msg => "Checking local disks");
47 $self->{components}->{localdisk} = {name => 'local disks', total => 0, skip => 0};
48 return if ($self->check_filter(section => 'localdisk'));
49
50 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsStorageLocalDiskDn}})) {
51 $oid =~ /\.(\d+)$/;
52 my $instance = $1;
53 my $localdisk_dn = $self->{results}->{$oid_cucsStorageLocalDiskDn}->{$oid};
54 my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsStorageLocalDiskPresence}->{oid}}, instance => $instance);
55 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsStorageLocalDiskOperability}->{oid}}, instance => $instance);
56
57 next if ($self->absent_problem(section => 'localdisk', instance => $localdisk_dn));
58 next if ($self->check_filter(section => 'localdisk', instance => $localdisk_dn));
59
60 $self->{output}->output_add(
61 long_msg => sprintf(
62 "local disk '%s' state is '%s' [presence: %s].",
63 $localdisk_dn, $result2->{cucsStorageLocalDiskOperability},
64 $result->{cucsStorageLocalDiskPresence}
65 )
66 );
67
68 my $exit = $self->get_severity(section => 'localdisk.presence', label => 'default.presence', value => $result->{cucsStorageLocalDiskPresence});
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 "local disk '%s' presence is: '%s'",
74 $localdisk_dn, $result->{cucsStorageLocalDiskPresence})
75 );
76 next;
77 }
78
79 $self->{components}->{localdisk}->{total}++;
80
81 $exit = $self->get_severity(section => 'localdisk.operability', label => 'default.operability', value => $result2->{cucsStorageLocalDiskOperability});
82 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
83 $self->{output}->output_add(
84 severity => $exit,
85 short_msg => sprintf(
86 "local disk '%s' state is '%s'",
87 $localdisk_dn, $result2->{cucsStorageLocalDiskOperability}
88 )
89 );
90 }
91 }
92 }
93
94 1;