Debian Codegraph @

src/network/evertz/FC7800/snmp/mode/hardware.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 network::evertz::FC7800::snmp::mode::hardware;
22
23 use base qw(centreon::plugins::templates::hardware);
24
25 sub set_system {
26 my ($self, %options) = @_;
27
28 $self->{cb_hook2} = 'snmp_execute';
29
30 $self->{thresholds} = {
31 psu => [
32 ['false', 'CRITICAL'],
33 ['true', 'OK'],
34 ['notAvailable', 'UNKNOWN'],
35 ],
36 frameline => [
37 ['false', 'OK'],
38 ['true', 'CRITICAL'],
39 ['notAvailable', 'UNKNOWN'],
40 ],
41 };
42
43 $self->{components_path} = 'network::evertz::FC7800::snmp::mode::components';
44 $self->{components_module} = ['frameline', 'psu'];
45 }
46
47 sub new {
48 my ($class, %options) = @_;
49 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, no_load_components => 1);
50 bless $self, $class;
51
52 $options{options}->add_options(arguments => {});
53
54 return $self;
55 }
56
57 sub snmp_execute {
58 my ($self, %options) = @_;
59
60 $self->{snmp} = $options{snmp};
61 $self->{results} = $self->{snmp}->get_leef(oids => $self->{request});
62 }
63
64 1;
65
66 =head1 MODE
67
68 Check hardware.
69
70 =over 8
71
72 =item B<--component>
73
74 Which component to check (default: '.*').
75 Can be: 'psu', 'frameline'.
76
77 =item B<--filter>
78
79 Exclude some parts (comma separated list)
80 You can also exclude items from specific instances: --filter=psu,1
81
82 =item B<--no-component>
83
84 Define the expected status if no components are found (default: critical).
85
86
87 =item B<--threshold-overload>
88
89 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
90 Example: --threshold-overload='psu,OK,notAvailable'
91
92 =back
93
94 =cut
95
96 package network::evertz::FC7800::snmp::mode::components::psu;
97
98 use strict;
99 use warnings;
100
101 my %map_psu_status = (1 => 'false', 2 => 'true', 3 => 'notAvailable');
102
103 my $mapping_psu = {
104 powerSupply1Status => { oid => '.1.3.6.1.4.1.6827.10.232.4.3', map => \%map_psu_status },
105 powerSupply2Status => { oid => '.1.3.6.1.4.1.6827.10.232.4.4', map => \%map_psu_status },
106 };
107
108 sub load {
109 my ($self) = @_;
110
111 push @{$self->{request}}, $mapping_psu->{powerSupply1Status}->{oid} . '.0', $mapping_psu->{powerSupply2Status}->{oid} . '.0';
112 }
113
114 sub check_psu {
115 my ($self, %options) = @_;
116
117 return if (!defined($options{status}));
118 return if ($self->check_filter(section => 'psu', instance => $options{instance}));
119
120 $self->{components}->{psu}->{total}++;
121 $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]",
122 $options{instance}, $options{status}, $options{instance}));
123 my $exit = $self->get_severity(section => 'psu', value => $options{status});
124 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
125 $self->{output}->output_add(severity => $exit,
126 short_msg => sprintf("Power supply '%s' status is '%s'", $options{instance}, $options{status}));
127 }
128 }
129
130 sub check {
131 my ($self) = @_;
132
133 $self->{output}->output_add(long_msg => "Checking poer supplies");
134 $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
135 return if ($self->check_filter(section => 'psu'));
136
137 my $result = $self->{snmp}->map_instance(mapping => $mapping_psu, results => $self->{results}, instance => '0');
138
139 check_psu($self, status => $result->{powerSupply1Status}, instance => 1);
140 check_psu($self, status => $result->{powerSupply2Status}, instance => 2);
141 }
142
143 1;
144
145 package network::evertz::FC7800::snmp::mode::components::frameline;
146
147 use strict;
148 use warnings;
149
150 my %map_frameline_status = (1 => 'false', 2 => 'true', 3 => 'notAvailable');
151
152 my $mapping_frameline = {
153 frameStatusLine => { oid => '.1.3.6.1.4.1.6827.10.232.4.2', map => \%map_frameline_status },
154 };
155
156 sub load {
157 my ($self) = @_;
158
159 push @{$self->{request}}, $mapping_frameline->{frameStatusLine}->{oid} . '.0';
160 }
161
162 sub check {
163 my ($self) = @_;
164
165 $self->{output}->output_add(long_msg => "Checking frame line");
166 $self->{components}->{frameline} = {name => 'frameline', total => 0, skip => 0};
167 return if ($self->check_filter(section => 'frameline'));
168
169 my $result = $self->{snmp}->map_instance(mapping => $mapping_frameline, results => $self->{results}, instance => '0');
170
171 return if (!defined($result->{frameStatusLine}));
172 $self->{components}->{frameline}->{total}++;
173 $self->{output}->output_add(long_msg => sprintf("frame line status is '%s' [instance = %s]",
174 $result->{frameStatusLine}, '0'));
175 my $exit = $self->get_severity(section => 'frameline', value => $result->{frameStatusLine});
176 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
177 $self->{output}->output_add(severity => $exit,
178 short_msg => sprintf("Frame line status is '%s'", $result->{frameStatusLine}));
179 }
180 }
181
182 1;