Debian Codegraph @

src/centreon/common/force10/snmp/mode/components/stack.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 centreon::common::force10::snmp::mode::components::stack;
22
23 use strict;
24 use warnings;
25
26 my $map_unit_status = {
27 1 => 'ok', 2 => 'unsupported', 3 => 'codeMismatch', 4 => 'configMismatch',
28 5 => 'unitDown', 6 => 'notPresent'
29 };
30
31 my $mapping = {
32 sseries => {
33 status => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.2.1.8', map => $map_unit_status }, # chStackUnitStatus
34 temperature => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.2.1.14' } # chStackUnitTemp
35 },
36 mseries => {
37 status => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.1.1.8', map => $map_unit_status }, # chStackUnitStatus
38 temperature => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.1.1.14' } # chStackUnitTemp
39 },
40 os9 => {
41 status => { oid => '.1.3.6.1.4.1.6027.3.26.1.3.4.1.8', map => $map_unit_status }, # dellNetStackUnitStatus
42 temperature => { oid => '.1.3.6.1.4.1.6027.3.26.1.3.4.1.13' } # dellNetStackUnitTemp
43 }
44 };
45 my $stack_table = {
46 sseries => '.1.3.6.1.4.1.6027.3.10.1.2.2.1',
47 mseries => '.1.3.6.1.4.1.6027.3.19.1.2.1.1',
48 os9 => '.1.3.6.1.4.1.6027.3.26.1.3.4.1'
49 };
50
51 sub load {
52 my ($self) = @_;
53
54 push @{$self->{request}},
55 { oid => $stack_table->{sseries}, start => $mapping->{sseries}->{status}->{oid}, end => $mapping->{sseries}->{temperature}->{oid} },
56 { oid => $stack_table->{mseries}, start => $mapping->{mseries}->{status}->{oid}, end => $mapping->{mseries}->{temperature}->{oid} },
57 { oid => $stack_table->{os9}, start => $mapping->{os9}->{status}->{oid}, end => $mapping->{os9}->{temperature}->{oid} };
58 }
59
60 sub check {
61 my ($self) = @_;
62
63 $self->{output}->output_add(long_msg => 'Checking stack');
64 $self->{components}->{stack} = { name => 'stack', total => 0, skip => 0 };
65 return if ($self->check_filter(section => 'stack'));
66
67 foreach my $name (keys %$stack_table) {
68 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $stack_table->{$name} }})) {
69 next if ($oid !~ /^$mapping->{$name}->{status}->{oid}\.(.*)$/);
70 my $instance = $1;
71 my $result = $self->{snmp}->map_instance(mapping => $mapping->{$name}, results => $self->{results}->{ $stack_table->{$name} }, instance => $instance);
72
73 next if ($result->{status} =~ /absent/i &&
74 $self->absent_problem(section => 'stack', instance => $instance));
75 next if ($self->check_filter(section => 'stack', instance => $instance));
76 $self->{components}->{stack}->{total}++;
77
78 $self->{output}->output_add(
79 long_msg => sprintf(
80 "stack '%s' status is '%s' [instance: %s, temperature: %s]",
81 $instance,
82 $result->{status},
83 $instance,
84 $result->{temperature}
85 )
86 );
87 my $exit = $self->get_severity(section => 'stack', value => $result->{status});
88 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
89 $self->{output}->output_add(
90 severity => $exit,
91 short_msg => sprintf(
92 "Stack '%s' status is '%s'",
93 $instance, $result->{status}
94 )
95 );
96 }
97
98 my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperature});
99 if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
100 $self->{output}->output_add(
101 severity => $exit2,
102 short_msg => sprintf("stack '%s' temperature is %s C", $instance, $result->{temperature})
103 );
104 }
105 $self->{output}->perfdata_add(
106 nlabel => 'hardware.stack.temperature.celsius',
107 unit => 'C',
108 instances => $instance,
109 value => $result->{temperature},
110 warning => $warn,
111 critical => $crit
112 );
113 }
114 }
115 }
116
117 1;