default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / torrus / perllib / Torrus / DevDiscover / CiscoIOS_Docsis.pm
1 #  Copyright (C) 2002  Stanislav Sinyagin
2 #
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.
7 #
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.
12 #
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.
16
17 # $Id: CiscoIOS_Docsis.pm,v 1.1 2010-12-27 00:03:46 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
19
20 # DOCSIS interface, Cisco specific
21
22 package Torrus::DevDiscover::CiscoIOS_Docsis;
23
24 use strict;
25 use Torrus::Log;
26
27 # Sequence number is 600 - we depend on RFC2670_DOCS_IF and CiscoIOS
28
29 $Torrus::DevDiscover::registry{'CiscoIOS_Docsis'} = {
30     'sequence'     => 600,
31     'checkdevtype' => \&checkdevtype,
32     'discover'     => \&discover,
33     'buildConfig'  => \&buildConfig
34     };
35
36 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
37     'DocsisMacModemsMonitor'} = 'CiscoIOS_Docsis';
38
39 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
40     'DocsisUpUtilMonitor'} = 'CiscoIOS_Docsis';
41 $Torrus::DevDiscover::RFC2863_IF_MIB::knownSelectorActions{
42     'DocsisUpSlotsMonitor'} = 'CiscoIOS_Docsis';
43
44
45 our %oiddef =
46     (
47      # CISCO-DOCS-EXT-MIB:cdxIfUpstreamChannelExtTable
48      'cdxIfUpChannelMaxUGSLastFiveMins' => '1.3.6.1.4.1.9.9.116.1.4.1.1.14'
49      );
50
51
52 sub checkdevtype
53 {
54     my $dd = shift;
55     my $devdetails = shift;
56
57     if( $devdetails->isDevType('CiscoIOS') and
58         $devdetails->isDevType('RFC2670_DOCS_IF') )
59     {
60         return 1;
61     }
62
63     return 0;
64 }
65
66
67 sub discover
68 {
69     my $dd = shift;
70     my $devdetails = shift;
71
72     my $data = $devdetails->data();
73     
74     if( $dd->checkSnmpTable( 'cdxIfUpChannelMaxUGSLastFiveMins' ) )
75     {
76         $devdetails->setCap('cdxIfUpChannelMaxUGSLastFiveMins');
77     }
78
79     push( @{$data->{'docsConfig'}{'docsCableMaclayer'}{'templates'}},
80           'CiscoIOS_Docsis::cisco-docsis-mac-subtree' );
81
82     foreach my $ifIndex ( @{$data->{'docsCableMaclayer'}} )
83     {
84         my $interface = $data->{'interfaces'}{$ifIndex};
85
86         push( @{$interface->{'docsTemplates'}},
87               'CiscoIOS_Docsis::cisco-docsis-mac-util' );
88     }
89
90     foreach my $ifIndex ( @{$data->{'docsCableUpstream'}} )
91     {
92         my $interface = $data->{'interfaces'}{$ifIndex};
93
94         push( @{$interface->{'docsTemplates'}},
95               'CiscoIOS_Docsis::cisco-docsis-upstream-util' );
96     }
97     
98     return 1;
99 }
100
101
102 sub buildConfig
103 {
104     my $devdetails = shift;
105     my $cb = shift;
106     my $devNode = shift;
107
108     my $data = $devdetails->data();
109
110     if( $devdetails->hasCap('cdxIfUpChannelMaxUGSLastFiveMins') )
111     {
112         $cb->setVar( $devNode, 'CiscoIOS_Docsis::ugs-supported', 'true' );
113     }
114
115     if( scalar( @{$data->{'docsCableMaclayer'}} ) > 0 )
116     {
117         # Build All_Modems summary graph
118         my $param = {
119             'ds-type'              => 'rrd-multigraph',
120             'ds-names'             => 'total,active,registered',
121             'graph-lower-limit'    => '0',
122             'precedence'           => '1000',
123             'comment'              =>
124                 'Registered, Active and Total modems on CMTS',
125                 
126                 'vertical-label'       => 'Modems',
127                 
128                 'graph-legend-total'   => 'Total',
129                 'line-style-total'     => '##totalresource',
130                 'line-color-total'     => '##totalresource',
131                 'line-order-total'     => '1',
132                 
133                 'graph-legend-active'  => 'Active',
134                 'line-style-active'    => '##resourcepartusage',
135                 'line-color-active'    => '##resourcepartusage',
136                 'line-order-active'    => '2',
137                 
138                 'graph-legend-registered'  => 'Registered',
139                 'line-style-registered'    => '##resourceusage',
140                 'line-color-registered'    => '##resourceusage',
141                 'line-order-registered'    => '3',
142                 'descriptive-nickname'     => '%system-id%: All modems'
143             };
144         
145         my $first = 1;
146         foreach my $ifIndex ( @{$data->{'docsCableMaclayer'}} )
147         {
148             my $interface = $data->{'interfaces'}{$ifIndex};
149             
150             my $intf = $interface->{$data->{'nameref'}{'ifSubtreeName'}};
151             
152             if( $first )
153             {
154                 $param->{'ds-expr-total'} =
155                     '{' . $intf . '/Modems_Total}';
156                 $param->{'ds-expr-active'} =
157                     '{' . $intf . '/Modems_Active}';
158                 $param->{'ds-expr-registered'} =
159                     '{' . $intf . '/Modems_Registered}';
160                 $first = 0;
161             }
162             else
163             {
164                 $param->{'ds-expr-total'} .=
165                     ',{' . $intf . '/Modems_Total},+';
166                 $param->{'ds-expr-active'} .=
167                     ',{' . $intf . '/Modems_Active},+';
168                 $param->{'ds-expr-registered'} .=
169                     ',{' . $intf . '/Modems_Registered},+';
170             }
171         }
172
173         my $macNode =
174             $cb->getChildSubtree( $devNode,
175                                   $data->{'docsConfig'}{
176                                       'docsCableMaclayer'}{
177                                           'subtreeName'} );
178         if( defined( $macNode ) )
179         {
180             $cb->addLeaf( $macNode, 'All_Modems', $param, [] );
181         }
182         else
183         {
184             Error('Could not find the MAC layer subtree');
185             exit 1;
186         }
187         
188         # Apply selector actions
189         foreach my $ifIndex ( @{$data->{'docsCableMaclayer'}} )
190         {
191             my $interface = $data->{'interfaces'}{$ifIndex};
192             
193             my $intf = $interface->{$data->{'nameref'}{'ifSubtreeName'}};
194             
195             my $monitor =
196                 $interface->{'selectorActions'}{'DocsisMacModemsMonitor'};
197             if( defined( $monitor ) )
198             {
199                 my $intfNode = $cb->getChildSubtree( $macNode, $intf );
200                 $cb->addLeaf( $intfNode, 'Modems_Registered',
201                               {'monitor' => $monitor } );
202             }
203         }
204     }
205
206     if( scalar( @{$data->{'docsCableUpstream'}} ) > 0 )
207     {
208         my $upstrNode =
209             $cb->getChildSubtree( $devNode,
210                                   $data->{'docsConfig'}{'docsCableUpstream'}{
211                                       'subtreeName'} );
212         
213         foreach my $ifIndex ( @{$data->{'docsCableUpstream'}} )
214         {
215             my $interface = $data->{'interfaces'}{$ifIndex};
216             
217             my $intf = $interface->{$data->{'nameref'}{'ifSubtreeName'}};
218             
219             my $monitor =
220                 $interface->{'selectorActions'}{'DocsisUpUtilMonitor'};
221             if( defined( $monitor ) )
222             {
223                 my $intfNode = $cb->getChildSubtree( $upstrNode, $intf );
224                 $cb->addLeaf( $intfNode, 'Util',
225                               {'monitor' => $monitor } );
226             }
227
228             $monitor =
229                 $interface->{'selectorActions'}{'DocsisUpSlotsMonitor'};
230             if( defined( $monitor ) )
231             {
232                 my $intfNode = $cb->getChildSubtree( $upstrNode, $intf );
233                 $cb->addLeaf( $intfNode, 'ContSlots',
234                               {'monitor' => $monitor } );
235             }
236         }
237
238         # Override the overview shortcus defined in rfc2670.docsis-if.xml
239         
240         my $shortcuts = 'snr,fec,freq,modems,util';
241         if( $devdetails->hasCap('cdxIfUpChannelMaxUGSLastFiveMins') )
242         {
243             $shortcuts .= ',ugs';
244         }
245         
246         my $param = {        
247             'overview-shortcuts' =>
248                 $shortcuts,
249                 
250                 'overview-subleave-name-modems' => 'Modems',
251                 'overview-direct-link-modems' => 'yes',
252                 'overview-direct-link-view-modems' => 'expanded-dir-html',
253                 'overview-shortcut-text-modems' => 'All modems',
254                 'overview-shortcut-title-modems'=>
255                 'Show modem quantities in one page',
256                 'overview-page-title-modems' => 'Modem quantities',
257                 
258                 'overview-subleave-name-util' => 'Util_Summary',
259                 'overview-direct-link-util' => 'yes',
260                 'overview-direct-link-view-util' => 'expanded-dir-html',
261                 'overview-shortcut-text-util' => 'All utilization',
262                 'overview-shortcut-title-util' => 'All upstream utilization',
263                 'overview-page-title-util' => 'Upstream utilization',
264                 
265                 'overview-subleave-name-ugs' => 'Active_UGS',
266                 'overview-direct-link-ugs' => 'yes',
267                 'overview-direct-link-view-ugs' => 'expanded-dir-html',
268                 'overview-shortcut-text-ugs' => 'All UGS',
269                 'overview-shortcut-title-ugs' => 'Show all UGS in one page',
270                 'overview-page-title-ugs' => 'UGS Statistics'
271             };
272
273         $cb->addParams( $upstrNode, $param );
274     }
275 }
276
277
278 1;
279
280
281 # Local Variables:
282 # mode: perl
283 # indent-tabs-mode: nil
284 # perl-indent-level: 4
285 # End: