Debian Codegraph @

src/hardware/pdu/gude/epc/snmp/mode/resources.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::pdu::gude::epc::snmp::mode::resources;
22
23 use strict;
24 use warnings;
25 use Exporter;
26
27 our @ISA = qw(Exporter);
28 our @EXPORT_OK = qw(find_gude_version);
29
30 my $regexp_gude_branch = {
31 '1104' => '.1.3.6.1.4.1.28507.68',
32 '1105' => '.1.3.6.1.4.1.28507.69',
33 '1202' => '.1.3.6.1.4.1.28507.43',
34 '8021' => '.1.3.6.1.4.1.28507.77',
35 '8025' => '.1.3.6.1.4.1.28507.79',
36 '8031' => '.1.3.6.1.4.1.28507.81',
37 '8035' => '.1.3.6.1.4.1.28507.83',
38 '8041' => '.1.3.6.1.4.1.28507.85',
39 '8045' => '.1.3.6.1.4.1.28507.87',
40 '8101' => '.1.3.6.1.4.1.28507.89',
41 '8221' => '.1.3.6.1.4.1.28507.56',
42 '8226' => '.1.3.6.1.4.1.28507.58',
43 '8316' => '.1.3.6.1.4.1.28507.64'
44 };
45
46 sub find_gude_branch {
47 my ($self, %options) = @_;
48
49 my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0';
50 my $snmp_result = $options{snmp}->get_leef(
51 oids => [ $oid_sysDescr ],
52 nothing_quit => 1
53 );
54 my $branch;
55 foreach my $re (keys %$regexp_gude_branch) {
56 if ($snmp_result->{$oid_sysDescr} =~ /$re/) {
57 $branch = $regexp_gude_branch->{$re};
58 last;
59 }
60 }
61 if (!defined($branch)) {
62 $self->{output}->add_option_msg(short_msg => 'unsupported device: ' . $snmp_result->{$oid_sysDescr});
63 $self->{output}->option_exit();
64 }
65
66 return $branch;
67 }
68
69 1;
70
71 __END__