bury all dead whitespace, better off to just do it in one command. i wonder why ss...
[torrus-plus.git] / src / lib / Torrus / DevDiscover / AscendMax.pm
blob9ed9af0139f5e5d1283dd882817eeb42862b1535
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 # Ascend (Lucent) MAX device discovery.
21 # Tested with:
23 # MAX 4000, TAOS version 7.0.26
25 # NOTE: SNMP version 1 is only supported. Because of version 1 and numerous
26 # WAN DS0 interfaces, the discovery process may take few minutes.
28 package Torrus::DevDiscover::AscendMax;
30 use strict;
31 use warnings;
33 use Torrus::Log;
35 our $VERSION = 1.0;
37 $Torrus::DevDiscover::registry{'AscendMax'} = {
38 'sequence' => 500,
39 'checkdevtype' => \&checkdevtype,
40 'discover' => \&discover,
41 'buildConfig' => \&buildConfig
45 our %oiddef =
47 # ASCEND-MIB
48 'ASCEND-MIB::max' => '1.3.6.1.4.1.529.1.2',
49 # ASCEND-ADVANCED-AGENT-MIB
50 'ASCEND-ADVANCED-AGENT-MIB::wanLineTable' =>
51 '1.3.6.1.4.1.529.4.21',
52 'ASCEND-ADVANCED-AGENT-MIB::wanLineState' =>
53 '1.3.6.1.4.1.529.4.21.1.5',
54 'ASCEND-ADVANCED-AGENT-MIB::wanLineActiveChannels' =>
55 '1.3.6.1.4.1.529.4.21.1.7',
56 'ASCEND-ADVANCED-AGENT-MIB::wanLineSwitchedChannels' =>
57 '1.3.6.1.4.1.529.4.21.1.13'
60 # Not all interfaces are normally needed to monitor.
61 # You may override the interface filtering in devdiscover-siteconfig.pl:
62 # redefine $Torrus::DevDiscover::AscendMax::interfaceFilter
63 # or define $Torrus::DevDiscover::AscendMax::interfaceFilterOverlay
65 our $interfaceFilter;
66 our $interfaceFilterOverlay;
67 my %ascMaxInterfaceFilter;
69 if( not defined( $interfaceFilter ) )
71 $interfaceFilter = \%ascMaxInterfaceFilter;
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 %ascMaxInterfaceFilter =
80 'Console' => {
81 'ifType' => 33 # rs232
83 'E1' => {
84 'ifType' => 19 # e1
86 'wan_activeN' => {
87 'ifType' => 23, # ppp
88 'ifDescr' => '^wan\d+'
90 'wan_inactiveN' => {
91 'ifType' => 1, # other
92 'ifDescr' => '^wan\d+'
94 'wanidleN' => {
95 'ifType' => 1, # other
96 'ifDescr' => '^wanidle\d+'
98 'loopbacks' => {
99 'ifType' => 24 # softwareLoopback
104 sub checkdevtype
106 my $dd = shift;
107 my $devdetails = shift;
109 if( not $dd->oidBaseMatch
110 ( 'ASCEND-MIB::max',
111 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
113 return 0;
116 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
117 ($devdetails, $interfaceFilter);
119 if( defined( $interfaceFilterOverlay ) )
121 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
122 ($devdetails, $interfaceFilterOverlay);
125 $devdetails->setCap('interfaceIndexingPersistent');
127 return 1;
131 sub discover
133 my $dd = shift;
134 my $devdetails = shift;
136 my $data = $devdetails->data();
137 my $session = $dd->session();
139 my $wanTableOid = $dd->oiddef('ASCEND-ADVANCED-AGENT-MIB::wanLineTable' );
140 my $stateOid =
141 $dd->oiddef('ASCEND-ADVANCED-AGENT-MIB::wanLineState' );
142 my $totalOid =
143 $dd->oiddef('ASCEND-ADVANCED-AGENT-MIB::wanLineSwitchedChannels' );
145 my $wanTable = $session->get_table( -baseoid => $wanTableOid );
146 if( defined( $wanTable ) )
148 $devdetails->storeSnmpVars( $wanTable );
149 $devdetails->setCap('wanLineTable');
151 $data->{'ascend_wanLines'} = {};
153 for my $ifIndex ( $devdetails->getSnmpIndices( $stateOid ) )
155 # Check if the line State is 13(active)
156 if( $devdetails->snmpVar( $stateOid . '.' . $ifIndex) == 13 )
158 my $descr = $devdetails->snmpVar($dd->oiddef('ifDescr') .
159 '.' . $ifIndex);
161 $data->{'ascend_wanLines'}{$ifIndex}{'description'} = $descr;
162 $data->{'ascend_wanLines'}{$ifIndex}{'channels'} =
163 $devdetails->snmpVar( $totalOid . '.' . $ifIndex );
168 return 1;
172 sub buildConfig
174 my $devdetails = shift;
175 my $cb = shift;
176 my $devNode = shift;
178 my $data = $devdetails->data();
180 my $callStatsNode = $cb->addSubtree( $devNode, 'Call_Statistics', undef,
181 ['AscendMax::ascend-totalcalls']);
183 for my $ifIndex ( sort {$a<=>$b} keys %{$data->{'ascend_wanLines'}} )
185 my $param = {};
186 $param->{'precedence'} = sprintf('%d', -10000 - $ifIndex);
187 $param->{'ascend-ifidx'} = $ifIndex;
189 my $nChannels = $data->{'ascend_wanLines'}{$ifIndex}{'channels'};
190 $param->{'upper-limit'} = $nChannels;
191 $param->{'graph-upper-limit'} = $nChannels;
193 my $subtreeName = $data->{'ascend_wanLines'}{$ifIndex}{'description'};
194 $subtreeName =~ s/\W/_/g;
196 $cb->addLeaf( $callStatsNode, $subtreeName, $param,
197 ['AscendMax::ascend-line-stats']);
200 return;
207 # Local Variables:
208 # mode: perl
209 # indent-tabs-mode: nil
210 # perl-indent-level: 4
211 # End: