updates
[torrus-plus.git] / src / lib / Torrus / DevDiscover / Xylan.pm
bloba35fd1f0684b23eba37d9fe7385d58e0bd6eedbb
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 # Stanislav Sinyagin <ssinyagin@yahoo.com>
19 # Xylan (Alcatel) switch discovery.
21 # Tested with:
23 # Xylan OmniSwitch 9x
24 # Xylan OmniStack 5024
25 # Switch software: X/OS 4.3.3
27 # Virtual ports are not processed yet
30 package Torrus::DevDiscover::Xylan;
32 use strict;
33 use warnings;
35 use Torrus::Log;
37 our $VERSION = 1.0;
39 $Torrus::DevDiscover::registry{'Xylan'} = {
40 'sequence' => 500,
41 'checkdevtype' => \&checkdevtype,
42 'discover' => \&discover,
43 'buildConfig' => \&buildConfig
47 our %oiddef =
49 # XYLAN-BASE-MIB
50 'xylanSwitchDevice' => '1.3.6.1.4.1.800.3.1.1',
51 # PORT-MIB::phyPortTable
52 'xylanPhyPortTable' => '1.3.6.1.4.1.800.2.3.3.1',
53 # PORT-MIB::phyPortDescription
54 'xylanPhyPortDescription' => '1.3.6.1.4.1.800.2.3.3.1.1.4',
55 # PORT-MIB::phyPortToInterface
56 'xylanPhyPortToInterface' => '1.3.6.1.4.1.800.2.3.3.1.1.19'
59 # Not all interfaces are normally needed to monitor.
60 # You may override the interface filtering in devdiscover-siteconfig.pl:
61 # redefine $Torrus::DevDiscover::Xylan::interfaceFilter
62 # or define $Torrus::DevDiscover::Xylan::interfaceFilterOverlay
64 our $interfaceFilter;
65 our $interfaceFilterOverlay;
66 my %xylInterfaceFilter;
68 if( not defined( $interfaceFilter ) )
70 $interfaceFilter = \%xylInterfaceFilter;
74 # Key is some unique symbolic name, does not mean anything
75 # ifType is the number to match the interface type
76 # ifDescr is the regexp to match the interface description
77 %xylInterfaceFilter =
79 'vnN' => {
80 'ifType' => 53 # propVirtual
82 'loN' => {
83 'ifType' => 24 # softwareLoopback
87 sub checkdevtype
89 my $dd = shift;
90 my $devdetails = shift;
92 if( not $dd->oidBaseMatch
93 ( 'xylanSwitchDevice',
94 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
96 return 0;
99 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
100 ($devdetails, $interfaceFilter);
102 if( defined( $interfaceFilterOverlay ) )
104 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
105 ($devdetails, $interfaceFilterOverlay);
108 $devdetails->setCap('interfaceIndexingPersistent');
110 return 1;
114 sub discover
116 my $dd = shift;
117 my $devdetails = shift;
119 my $data = $devdetails->data();
120 my $session = $dd->session();
122 $data->{'nameref'}{'ifNick'} = 'xylanInterfaceNick';
123 $data->{'nameref'}{'ifSubtreeName'} = 'xylanInterfaceNick';
124 $data->{'nameref'}{'ifComment'} = 'xylanInterfaceComment';
125 $data->{'nameref'}{'ifReferenceName'} = 'xylanInterfaceHumanName';
127 my $phyPortTable =
128 $session->get_table( -baseoid => $dd->oiddef('xylanPhyPortTable') );
130 if( not defined $phyPortTable )
132 Error('Error retrieving PORT-MIB::phyPortTable from Xylan device');
133 return 0;
136 $devdetails->storeSnmpVars( $phyPortTable );
138 for my $slotDotPort
139 ( $devdetails->
140 getSnmpIndices( $dd->oiddef('xylanPhyPortDescription') ) )
142 my ( $slot, $port ) = split( '\.', $slotDotPort );
144 my $ifIndex =
145 $devdetails->snmpVar($dd->oiddef('xylanPhyPortToInterface') .
146 '.' . $slotDotPort);
147 my $interface = $data->{'interfaces'}{$ifIndex};
149 if( defined $interface )
151 $interface->{'xylanInterfaceNick'} =
152 sprintf( '%d_%d', $slot, $port );
154 $interface->{'xylanInterfaceHumanName'} =
155 sprintf( '%d/%d', $slot, $port );
157 $interface->{'xylanInterfaceComment'} =
158 $devdetails->snmpVar($dd->oiddef('xylanPhyPortDescription') .
159 '.' . $slotDotPort);
163 # verify if all interfaces are processed
165 for my $ifIndex ( keys %{$data->{'interfaces'}} )
167 my $interface = $data->{'interfaces'}{$ifIndex};
169 if( not defined( $interface->{'xylanInterfaceNick'} ) )
171 Warn('Interface ' . $ifIndex . ' is not in phyPortTable');
173 my $nick = sprintf( 'PORT%d', $ifIndex );
174 $interface->{'xylanInterfaceNick'} = $nick;
175 $interface->{'xylanInterfaceHumanName'} = $nick;
177 $interface->{'xylanInterfaceComment'} = $interface->{'ifDescr'};
181 return 1;
185 sub buildConfig
187 my $devdetails = shift;
188 my $cb = shift;
189 my $devNode = shift;
190 return;
197 # Local Variables:
198 # mode: perl
199 # indent-tabs-mode: nil
200 # perl-indent-level: 4
201 # End: