Merge remote-tracking branch 'upstream/master'
[torrus-plus.git] / src / lib / Torrus / DevDiscover / Xylan.pm
blob454ab7fb58e480d1695ed2adf9f903d6958e92f7
1 # Copyright (C) 2002 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id$
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # Xylan (Alcatel) switch discovery.
22 # Tested with:
24 # Xylan OmniSwitch 9x
25 # Xylan OmniStack 5024
26 # Switch software: X/OS 4.3.3
28 # Virtual ports are not processed yet
31 package Torrus::DevDiscover::Xylan;
33 use strict;
34 use warnings;
36 use Torrus::Log;
38 our $VERSION = 1.0;
40 $Torrus::DevDiscover::registry{'Xylan'} = {
41 'sequence' => 500,
42 'checkdevtype' => \&checkdevtype,
43 'discover' => \&discover,
44 'buildConfig' => \&buildConfig
48 our %oiddef =
50 # XYLAN-BASE-MIB
51 'xylanSwitchDevice' => '1.3.6.1.4.1.800.3.1.1',
52 # PORT-MIB::phyPortTable
53 'xylanPhyPortTable' => '1.3.6.1.4.1.800.2.3.3.1',
54 # PORT-MIB::phyPortDescription
55 'xylanPhyPortDescription' => '1.3.6.1.4.1.800.2.3.3.1.1.4',
56 # PORT-MIB::phyPortToInterface
57 'xylanPhyPortToInterface' => '1.3.6.1.4.1.800.2.3.3.1.1.19'
60 # Not all interfaces are normally needed to monitor.
61 # You may override the interface filtering in devdiscover-siteconfig.pl:
62 # redefine $Torrus::DevDiscover::Xylan::interfaceFilter
63 # or define $Torrus::DevDiscover::Xylan::interfaceFilterOverlay
65 our $interfaceFilter;
66 our $interfaceFilterOverlay;
67 my %xylInterfaceFilter;
69 if( not defined( $interfaceFilter ) )
71 $interfaceFilter = \%xylInterfaceFilter;
75 # Key is some unique symbolic name, does not mean anything
76 # ifType is the number to match the interface type
77 # ifDescr is the regexp to match the interface description
78 %xylInterfaceFilter =
80 'vnN' => {
81 'ifType' => 53 # propVirtual
83 'loN' => {
84 'ifType' => 24 # softwareLoopback
88 sub checkdevtype
90 my $dd = shift;
91 my $devdetails = shift;
93 if( not $dd->oidBaseMatch
94 ( 'xylanSwitchDevice',
95 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
97 return 0;
100 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
101 ($devdetails, $interfaceFilter);
103 if( defined( $interfaceFilterOverlay ) )
105 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
106 ($devdetails, $interfaceFilterOverlay);
109 $devdetails->setCap('interfaceIndexingPersistent');
111 return 1;
115 sub discover
117 my $dd = shift;
118 my $devdetails = shift;
120 my $data = $devdetails->data();
121 my $session = $dd->session();
123 $data->{'nameref'}{'ifNick'} = 'xylanInterfaceNick';
124 $data->{'nameref'}{'ifSubtreeName'} = 'xylanInterfaceNick';
125 $data->{'nameref'}{'ifComment'} = 'xylanInterfaceComment';
126 $data->{'nameref'}{'ifReferenceName'} = 'xylanInterfaceHumanName';
128 my $phyPortTable =
129 $session->get_table( -baseoid => $dd->oiddef('xylanPhyPortTable') );
131 if( not defined $phyPortTable )
133 Error('Error retrieving PORT-MIB::phyPortTable from Xylan device');
134 return 0;
137 $devdetails->storeSnmpVars( $phyPortTable );
139 for my $slotDotPort
140 ( $devdetails->
141 getSnmpIndices( $dd->oiddef('xylanPhyPortDescription') ) )
143 my ( $slot, $port ) = split( '\.', $slotDotPort );
145 my $ifIndex =
146 $devdetails->snmpVar($dd->oiddef('xylanPhyPortToInterface') .
147 '.' . $slotDotPort);
148 my $interface = $data->{'interfaces'}{$ifIndex};
150 if( defined $interface )
152 $interface->{'xylanInterfaceNick'} =
153 sprintf( '%d_%d', $slot, $port );
155 $interface->{'xylanInterfaceHumanName'} =
156 sprintf( '%d/%d', $slot, $port );
158 $interface->{'xylanInterfaceComment'} =
159 $devdetails->snmpVar($dd->oiddef('xylanPhyPortDescription') .
160 '.' . $slotDotPort);
164 # verify if all interfaces are processed
166 for my $ifIndex ( keys %{$data->{'interfaces'}} )
168 my $interface = $data->{'interfaces'}{$ifIndex};
170 if( not defined( $interface->{'xylanInterfaceNick'} ) )
172 Warn('Interface ' . $ifIndex . ' is not in phyPortTable');
174 my $nick = sprintf( 'PORT%d', $ifIndex );
175 $interface->{'xylanInterfaceNick'} = $nick;
176 $interface->{'xylanInterfaceHumanName'} = $nick;
178 $interface->{'xylanInterfaceComment'} = $interface->{'ifDescr'};
182 return 1;
186 sub buildConfig
188 my $devdetails = shift;
189 my $cb = shift;
190 my $devNode = shift;
191 return;
198 # Local Variables:
199 # mode: perl
200 # indent-tabs-mode: nil
201 # perl-indent-level: 4
202 # End: