1 # Copyright (C) 2010 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: CasaCMTS.pm,v 1.1 2010-12-27 00:03:47 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # DOCSIS interface, CASA specific
22 package Torrus::DevDiscover::CasaCMTS;
28 $Torrus::DevDiscover::registry{'CasaCMTS'} = {
30 'checkdevtype' => \&checkdevtype,
31 'discover' => \&discover,
32 'buildConfig' => \&buildConfig
36 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
37 'DocsisMacModemsMonitor'} = 'CasaCMTS';
42 'casaProducts' => '1.3.6.1.4.1.20858.2',
49 my $devdetails = shift;
51 if( not $dd->oidBaseMatch
53 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) or
54 not $devdetails->isDevType('RFC2670_DOCS_IF') )
66 my $devdetails = shift;
68 my $data = $devdetails->data();
70 push( @{$data->{'docsConfig'}{'docsCableMaclayer'}{'templates'}},
71 'CasaCMTS::casa-docsis-mac-subtree' );
73 foreach my $ifIndex ( @{$data->{'docsCableMaclayer'}} )
75 my $interface = $data->{'interfaces'}{$ifIndex};
77 push( @{$interface->{'docsTemplates'}},
78 'CasaCMTS::casa-docsis-mac-util' );
81 foreach my $ifIndex ( @{$data->{'docsCableUpstream'}} )
83 my $interface = $data->{'interfaces'}{$ifIndex};
85 push( @{$interface->{'docsTemplates'}},
86 'CasaCMTS::casa-docsis-upstream-util' );
89 foreach my $ifIndex ( @{$data->{'docsCableDownstream'}} )
91 my $interface = $data->{'interfaces'}{$ifIndex};
93 push( @{$interface->{'docsTemplates'}},
94 'CasaCMTS::casa-docsis-downstream-util' );
104 my $devdetails = shift;
108 my $data = $devdetails->data();
111 if( scalar( @{$data->{'docsCableMaclayer'}} ) > 0 )
113 # Build All_Modems summary graph
115 'ds-type' => 'rrd-multigraph',
116 'ds-names' => 'total,active,registered',
117 'graph-lower-limit' => '0',
118 'precedence' => '1000',
119 'vertical-label' => 'Modems',
121 'graph-legend-total' => 'Total',
122 'line-style-total' => '##totalresource',
123 'line-color-total' => '##totalresource',
124 'line-order-total' => '1',
126 'graph-legend-active' => 'Active',
127 'line-style-active' => '##resourcepartusage',
128 'line-color-active' => '##resourcepartusage',
129 'line-order-active' => '2',
131 'graph-legend-registered' => 'Registered',
132 'line-style-registered' => '##resourceusage',
133 'line-color-registered' => '##resourceusage',
134 'line-order-registered' => '3',
135 'descriptive-nickname' => '%system-id%: All modems'
138 # for the sake of better Emacs formatting
139 $param->{'comment'} =
140 'Registered, Active and Total modems on CMTS';
143 $data->{'docsConfig'}{'docsCableMaclayer'}{'nodeidCategory'} .
144 '//%nodeid-device%//modems';
147 foreach my $ifIndex ( @{$data->{'docsCableMaclayer'}} )
149 my $interface = $data->{'interfaces'}{$ifIndex};
151 my $intf = $interface->{$data->{'nameref'}{'ifSubtreeName'}};
155 $param->{'ds-expr-total'} =
156 '{' . $intf . '/Modems_Total}';
157 $param->{'ds-expr-active'} =
158 '{' . $intf . '/Modems_Active}';
159 $param->{'ds-expr-registered'} =
160 '{' . $intf . '/Modems_Registered}';
165 $param->{'ds-expr-total'} .=
166 ',{' . $intf . '/Modems_Total},+';
167 $param->{'ds-expr-active'} .=
168 ',{' . $intf . '/Modems_Active},+';
169 $param->{'ds-expr-registered'} .=
170 ',{' . $intf . '/Modems_Registered},+';
175 $cb->getChildSubtree( $devNode,
176 $data->{'docsConfig'}{
177 'docsCableMaclayer'}{
179 if( defined( $macNode ) )
181 $cb->addLeaf( $macNode, 'All_Modems', $param, [] );
185 Error('Could not find the MAC layer subtree');
189 # Apply selector actions
190 foreach my $ifIndex ( @{$data->{'docsCableMaclayer'}} )
192 my $interface = $data->{'interfaces'}{$ifIndex};
194 my $intf = $interface->{$data->{'nameref'}{'ifSubtreeName'}};
197 $interface->{'selectorActions'}{'DocsisMacModemsMonitor'};
198 if( defined( $monitor ) )
200 my $intfNode = $cb->getChildSubtree( $macNode, $intf );
201 $cb->addLeaf( $intfNode, 'Modems_Registered',
202 {'monitor' => $monitor } );
207 if( scalar( @{$data->{'docsCableUpstream'}} ) > 0 )
210 $cb->getChildSubtree( $devNode,
211 $data->{'docsConfig'}{'docsCableUpstream'}{
214 # Override the overview shortcus defined in rfc2670.docsis-if.xml
216 my $shortcuts = 'snr,fec,freq,modems';
219 'overview-shortcuts' =>
222 'overview-subleave-name-modems' => 'Modems',
223 'overview-direct-link-modems' => 'yes',
224 'overview-direct-link-view-modems' => 'expanded-dir-html',
225 'overview-shortcut-text-modems' => 'All modems',
226 'overview-shortcut-title-modems'=>
227 'Show modem quantities in one page',
228 'overview-page-title-modems' => 'Modem quantities',
231 $cb->addParams( $upstrNode, $param );
234 if( scalar( @{$data->{'docsCableDownstream'}} ) > 0 )
237 $cb->getChildSubtree( $devNode,
238 $data->{'docsConfig'}{'docsCableDownstream'}{
241 # Override the overview shortcus defined in rfc2670.docsis-if.xml
243 my $shortcuts = 'util,modems';
246 'overview-shortcuts' => $shortcuts,
247 'overview-subleave-name-modems' => 'Modems',
248 'overview-direct-link-modems' => 'yes',
249 'overview-direct-link-view-modems' => 'expanded-dir-html',
250 'overview-shortcut-text-modems' => 'All modems',
251 'overview-shortcut-title-modems' =>
252 'Show modem quantities in one page',
253 'overview-page-title-modems' => 'Modem quantities',
256 $cb->addParams( $downstrNode, $param );
266 # indent-tabs-mode: nil
267 # perl-indent-level: 4