default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / torrus / perllib / Torrus / DevDiscover / NetScreen.pm
1 #  Copyright (C) 2003  Shawn Ferry
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: NetScreen.pm,v 1.1 2010-12-27 00:03:50 ivan Exp $
18 # Shawn Ferry <sferry at sevenspace dot com> <lalartu at obscure dot org>
19
20 # NetScreen
21
22 package Torrus::DevDiscover::NetScreen;
23
24 use strict;
25 use Torrus::Log;
26
27
28 $Torrus::DevDiscover::registry{'NetScreen'} = {
29     'sequence'     => 500,
30     'checkdevtype' => \&checkdevtype,
31     'discover'     => \&discover,
32     'buildConfig'  => \&buildConfig
33     };
34
35 our %oiddef =
36     (
37      'netscreen'         => '1.3.6.1.4.1.3224',
38      'nsResSessMaxium'   => '1.3.6.1.4.1.3224.16.3.3.0',
39      'nsIfFlowTable'     => '1.3.6.1.4.1.3224.9.3',
40
41      'nsIfMonTable'      => '1.3.6.1.4.1.3224.9.4',
42      'nsIfMonIfIdx'      => '1.3.6.1.4.1.3224.9.4.1.1',
43      );
44
45 sub checkdevtype
46 {
47     my $dd = shift;
48     my $devdetails = shift;
49
50     if( not $dd->checkSnmpTable( 'netscreen' ) )
51     {
52         return 0;
53     }
54
55     my $data = $devdetails->data();
56
57     $devdetails->setCap('interfaceIndexingManaged');
58     
59     return 1;
60 }
61
62
63 sub discover
64 {
65     my $dd = shift;
66     my $devdetails = shift;
67
68     my $session = $dd->session();
69     my $data = $devdetails->data();
70
71     $data->{'nameref'}{'ifDescr'} = '';
72     $data->{'param'}{'ifindex-map'} = '$IFIDX_MAC';
73     Torrus::DevDiscover::RFC2863_IF_MIB::retrieveMacAddresses( $dd,
74                                                                $devdetails );
75
76     # TODO: do something about these tables in buildConfig
77
78     if( $dd->checkSnmpTable( 'nsIfFlowTable' ) )
79     {
80         $devdetails->setCap('nsIfFlowTable');
81     }
82
83     if( $dd->checkSnmpTable( 'nsIfMonTable' ) )
84     {
85         $devdetails->setCap('nsIfMonTable');
86     }
87
88     if( not defined( $data->{'param'}{'snmp-oids-per-pdu'} ) )
89     {
90         my $oidsPerPDU = $devdetails->param('NetScreen::snmp-oids-per-pdu');
91         if( $oidsPerPDU == 0 )
92         {
93             $oidsPerPDU = 10;
94         }
95         Debug("Setting snmp-oids-per-pdu to $oidsPerPDU");
96         $data->{'param'}{'snmp-oids-per-pdu'} = $oidsPerPDU;
97     }
98
99     my $result = $dd->retrieveSnmpOIDs('nsResSessMaxium');
100     if( defined($result) and $result->{'nsResSessMaxium'} > 0 )
101     {
102         $devdetails->setCap('NetScreen::SessMax');
103
104         my $param = {};
105         my $max = $result->{'nsResSessMaxium'};
106
107         $param->{'hrule-value-max'} = $max;
108         $param->{'hrule-legend-max'} = 'Maximum Sessions';
109         # upper limit of graph is 5% higher than max sessions
110         $param->{'graph-upper-limit'} =
111             sprintf('%e', 
112                     ( $max * 5 / 100 ) + $max );
113         
114         $data->{'netScreenSessions'} = {
115             'param' => $param,
116         };        
117     }
118
119     return 1;
120 }
121
122
123 sub buildConfig
124 {
125     my $devdetails = shift;
126     my $cb = shift;
127     my $devNode = shift;
128     my $data = $devdetails->data();
129
130
131     { #Allocated Sessions
132
133         my $ref = $data->{'netScreenSessions'};
134
135         $cb->addSubtree( $devNode, "NetScreen_Sessions", $ref->{'param'}, 
136             [ 'NetScreen::netscreen-sessions-stats' ] );
137
138     }
139
140     $cb->addTemplateApplication($devNode, 'NetScreen::netscreen-cpu-stats');
141     $cb->addTemplateApplication($devNode, 'NetScreen::netscreen-memory-stats');
142 }
143
144
145 1;
146
147
148 # Local Variables:
149 # mode: perl
150 # indent-tabs-mode: nil
151 # perl-indent-level: 4
152 # End: