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: RFC2670_DOCS_IF.pm,v 1.1 2010-12-27 00:03:55 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # DOCSIS interface statistics
22 package Torrus::DevDiscover::RFC2670_DOCS_IF;
28 $Torrus::DevDiscover::registry{'RFC2670_DOCS_IF'} = {
30 'checkdevtype' => \&checkdevtype,
31 'discover' => \&discover,
32 'buildConfig' => \&buildConfig
36 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
37 'DocsisUpSNRMonitor'} = 'RFC2670_DOCS_IF';
38 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
39 'DocsisUpSNRTokenset'} = 'RFC2670_DOCS_IF';
41 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
42 'DocsisUpFECCorMonitor'} = 'RFC2670_DOCS_IF';
43 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
44 'DocsisUpFECUncorMonitor'} = 'RFC2670_DOCS_IF';
46 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
47 'DocsisDownUtilMonitor'} = 'RFC2670_DOCS_IF';
53 'docsIfDownstreamChannelTable' => '1.3.6.1.2.1.10.127.1.1.1',
54 'docsIfCmtsDownChannelCounterTable' => '1.3.6.1.2.1.10.127.1.3.10',
55 'docsIfSigQSignalNoise' => '1.3.6.1.2.1.10.127.1.1.4.1.5',
63 my $devdetails = shift;
65 my $session = $dd->session();
66 my $data = $devdetails->data();
68 if( $dd->checkSnmpTable( 'docsIfDownstreamChannelTable' ) )
80 my $devdetails = shift;
82 my $data = $devdetails->data();
83 my $session = $dd->session();
85 if( $dd->checkSnmpTable( 'docsIfCmtsDownChannelCounterTable' ) )
87 $devdetails->setCap('docsDownstreamUtil');
91 $session->get_table( -baseoid =>
92 $dd->oiddef('docsIfSigQSignalNoise') );
93 if( defined( $snrTable ) )
95 $devdetails->storeSnmpVars( $snrTable );
98 $data->{'docsCableMaclayer'} = [];
99 $data->{'docsCableDownstream'} = [];
100 $data->{'docsCableUpstream'} = [];
102 foreach my $ifIndex ( sort {$a<=>$b} keys %{$data->{'interfaces'}} )
104 my $interface = $data->{'interfaces'}{$ifIndex};
105 my $ifType = $interface->{'ifType'};
107 $interface->{'docsTemplates'} = [];
108 $interface->{'docsParams'} = {};
110 if( $devdetails->hasCap('interfaceIndexingPersistent') )
112 $interface->{'docsParams'}{'interface-index'} = $ifIndex;
117 push( @{$data->{'docsCableMaclayer'}}, $ifIndex );
119 elsif( $ifType == 128 )
121 push( @{$data->{'docsCableDownstream'}}, $ifIndex );
122 if( $devdetails->hasCap('docsDownstreamUtil') )
124 push( @{$interface->{'docsTemplates'}},
125 'RFC2670_DOCS_IF::docsis-downstream-util' );
128 elsif( $ifType == 129 or $ifType == 205 )
130 if( $devdetails->hasOID( $dd->oiddef('docsIfSigQSignalNoise') .
133 push( @{$data->{'docsCableUpstream'}}, $ifIndex );
134 push( @{$interface->{'docsTemplates'}},
135 'RFC2670_DOCS_IF::docsis-upstream-stats' );
141 if( $devdetails->param('RFC2670_DOCS_IF::upstreams-only') eq 'yes' )
143 $data->{'docsCableMaclayer'} = [];
144 $data->{'docsCableDownstream'} = [];
147 $data->{'docsConfig'} = {
148 'docsCableMaclayer' => {
149 'subtreeName' => 'Docsis_MAC_Layer',
150 'nodeidCategory' => 'docsmac',
153 'node-display-name' => 'DOCSIS MAC Layer',
156 'docsCableDownstream' => {
157 'subtreeName' => 'Docsis_Downstream',
158 'nodeidCategory' => 'docsds',
161 'node-display-name' => 'DOCSIS Downstream',
164 'docsCableUpstream' => {
165 'subtreeName' => 'Docsis_Upstream',
166 'nodeidCategory' => 'docsus',
167 'templates' => ['RFC2670_DOCS_IF::docsis-upstream-subtree'],
169 'node-display-name' => 'DOCSIS Upstream',
174 if( $devdetails->hasCap('docsDownstreamUtil') )
176 push( @{$data->{'docsConfig'}{'docsCableDownstream'}{'templates'}},
177 'RFC2670_DOCS_IF::docsis-downstream-subtree' );
186 my $devdetails = shift;
190 my $data = $devdetails->data();
192 foreach my $category ( sort keys %{$data->{'docsConfig'}} )
194 if( scalar( @{$data->{$category}} ) > 0 and
195 scalar( @{$data->{'docsConfig'}{$category}{'templates'}} ) > 0 )
197 # Count non-excluded interfaces
198 my $updatedInterfaceList = [];
199 foreach my $ifIndex ( @{$data->{$category}} )
201 my $interface = $data->{'interfaces'}{$ifIndex};
202 next if $interface->{'excluded'};
203 push( @{$updatedInterfaceList}, $ifIndex );
205 $data->{$category} = $updatedInterfaceList;
207 next if scalar( @{$data->{$category}} ) == 0;
210 $cb->addSubtree( $devNode,
211 $data->{'docsConfig'}{$category}{
213 $data->{'docsConfig'}{$category}{
215 $data->{'docsConfig'}{$category}{
218 foreach my $ifIndex ( @{$data->{$category}} )
220 my $interface = $data->{'interfaces'}{$ifIndex};
222 my $param = $interface->{'docsParams'};
224 $param->{'searchable'} = 'yes';
226 # Copy some parameters from IF-MIB discovery results
228 foreach my $p ('interface-name', 'interface-nick',
229 'node-display-name', 'comment')
231 $param->{$p} = $interface->{'param'}{$p};
234 $param->{'nodeid-docsif'} =
235 $data->{'docsConfig'}{$category}{'nodeidCategory'} .
236 '//%nodeid-device%//' .
237 $interface->{$data->{'nameref'}{'ifNodeid'}};
239 $param->{'nodeid'} = '%nodeid-docsif%';
241 my $intfNode = $cb->addSubtree
243 $interface->{$data->{'nameref'}{'ifSubtreeName'}},
245 $interface->{'docsTemplates'} );
247 # Apply selector actions
248 if( $category eq 'docsCableUpstream' )
251 $interface->{'selectorActions'}{'DocsisUpSNRMonitor'};
253 $interface->{'selectorActions'}{'DocsisUpSNRTokenset'};
254 if( defined( $monitor ) or defined( $tset ) )
257 if( defined( $monitor ) )
259 $param->{'monitor'} = $monitor;
261 if( defined( $tset ) )
263 $param->{'tokenset-member'} = $tset;
265 $cb->addLeaf( $intfNode, 'SNR', $param );
268 $monitor = $interface->{'selectorActions'}{
269 'DocsisUpFECCorMonitor'};
270 if( defined( $monitor ) )
272 $cb->addLeaf( $intfNode, 'Correctable',
273 {'monitor' => $monitor } );
276 $monitor = $interface->{'selectorActions'}{
277 'DocsisUpFECUncorMonitor'};
278 if( defined( $monitor ) )
280 $cb->addLeaf( $intfNode, 'Uncorrectable',
281 {'monitor' => $monitor } );
284 elsif( $category eq 'docsCableDownstream')
286 my $monitor = $interface->{'selectorActions'}{
287 'DocsisDownUtilMonitor'};
288 if( defined( $monitor ) )
290 $cb->addLeaf( $intfNode, 'UsedBytes',
291 {'monitor' => $monitor } );
305 # indent-tabs-mode: nil
306 # perl-indent-level: 4