Debian Codegraph @

src/hardware/server/dell/openmanage/snmp/mode/components/connector.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::dell::openmanage::snmp::mode::components::connector;
22
23 use strict;
24 use warnings;
25
26 my %map_state = (
27 0 => 'unknown',
28 1 => 'ready',
29 2 => 'failed',
30 3 => 'online',
31 4 => 'offline',
32 6 => 'degraded',
33 );
34 my %map_status = (
35 1 => 'other',
36 2 => 'unknown',
37 3 => 'ok',
38 4 => 'nonCritical',
39 5 => 'critical',
40 6 => 'nonRecoverable',
41 );
42 my %map_busType = (
43 1 => 'SCSI',
44 2 => 'IDE',
45 3 => 'Fibre Channel',
46 4 => 'SSA',
47 6 => 'USB',
48 7 => 'SATA',
49 8 => 'SAS',
50 );
51
52 # In MIB 'dcstorag.mib'
53 my $mapping = {
54 channelName => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.2' },
55 channelState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.3', map => \%map_state },
56 };
57 my $mapping2 = {
58 channelComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.8', map => \%map_status },
59 };
60 my $mapping3 = {
61 channelBusType => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.2.1.11', map => \%map_busType },
62 };
63 my $oid_channelEntry = '.1.3.6.1.4.1.674.10893.1.20.130.2.1';
64
65 sub load {
66 my ($self) = @_;
67
68 push @{$self->{request}}, { oid => $oid_channelEntry, start => $mapping->{channelName}->{oid}, end => $mapping->{channelState}->{oid} },
69 { oid => $mapping2->{channelComponentStatus}->{oid} },
70 { oid => $mapping3->{channelBusType}->{oid} } ;
71 }
72
73 sub check {
74 my ($self) = @_;
75
76 $self->{output}->output_add(long_msg => "Checking connectors (channels)");
77 $self->{components}->{connector} = {name => 'connectors', total => 0, skip => 0};
78 return if ($self->check_filter(section => 'connector'));
79
80 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping2->{channelComponentStatus}->{oid}}})) {
81 next if ($oid !~ /^$mapping2->{channelComponentStatus}->{oid}\.(.*)$/);
82 my $instance = $1;
83 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_channelEntry}, instance => $instance);
84 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{channelComponentStatus}->{oid}}, instance => $instance);
85 my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{channelBusType}->{oid}}, instance => $instance);
86 $result3->{channelBusType} = defined($result3->{channelBusType}) ? $result3->{channelBusType} : '-';
87
88 next if ($self->check_filter(section => 'connector', instance => $instance));
89
90 $self->{components}->{connector}->{total}++;
91
92 $self->{output}->output_add(long_msg => sprintf("Connector '%s' status is '%s' [instance: %s, state: %s, bus type: %s]",
93 $result->{channelName}, $result2->{channelComponentStatus}, $instance,
94 $result->{channelState}, $result3->{channelBusType}
95 ));
96 my $exit = $self->get_severity(label => 'default', section => 'connector', value => $result2->{channelComponentStatus});
97 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
98 $self->{output}->output_add(severity => $exit,
99 short_msg => sprintf("Connector '%s' status is '%s'",
100 $result->{channelName}, $result2->{channelComponentStatus}));
101 }
102 }
103 }
104
105 1;