Debian Codegraph @

src/network/lenovo/rackswitch/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 network::lenovo::rackswitch::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_rackswitch_branch);
29
30 my $branches = {
31 'g8124' => '.1.3.6.1.4.1.26543.2.7.4',
32 'g7028' => '.1.3.6.1.4.1.20301.2.7.17',
33 'g7052' => '.1.3.6.1.4.1.20301.2.7.18',
34 'g8052' => '.1.3.6.1.4.1.26543.2.7.7',
35 'g8264cs' => '.1.3.6.1.4.1.20301.2.7.15',
36 # g8264cs_sif not same oids
37 'g8254' => '.1.3.6.1.4.1.26543.2.7.6', # there is some extra stack OIDs
38 'g8272' => '.1.3.6.1.4.1.19046.2.7.24',
39 'g8296' => '.1.3.6.1.4.1.19046.2.7.22',
40 'g8332' => '.1.3.6.1.4.1.20301.2.7.16'
41
42 };
43
44 sub find_rackswitch_branch {
45 my (%options) = @_;
46
47 my $oid_software = '1.1.1.10.0';
48 my $snmp_result = $options{snmp}->get_leef(
49 oids => [ map($_ . '.' . $oid_software, values(%$branches)) ]
50 );
51 foreach (keys %$snmp_result) {
52 return $1 if (defined($snmp_result->{$_}) && /^(.*)\.$oid_software/);
53 }
54
55 $options{output}->add_option_msg(short_msg => 'unsupported device');
56 $options{output}->option_exit();
57 }
58
59 1;
60
61 __END__