import torrus 1.0.9
[freeside.git] / torrus / perllib / Torrus / DevDiscover / Alteon.pm
1 #
2 #  Discovery module for Alteon devices
3 #
4 #  Copyright (C) 2007 Jon Nistor
5 #
6 #  This program is free software; you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation; either version 2 of the License, or
9 #  (at your option) any later version.
10 #
11 #  This program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
20 # $Id: Alteon.pm,v 1.1 2010-12-27 00:03:55 ivan Exp $
21 # Jon Nistor <nistor at snickers dot org>
22 #
23
24
25 package Torrus::DevDiscover::Alteon;
26
27 use strict;
28 use Torrus::Log;
29
30
31 $Torrus::DevDiscover::registry{'Alteon'} = {
32     'sequence'     => 500,
33     'checkdevtype' => \&checkdevtype,
34     'discover'     => \&discover,
35     'buildConfig'  => \&buildConfig
36     };
37
38 # pmodule-dependend OIDs are presented for module #1 only.
39 # currently devices with more than one module do not exist
40
41 our %oiddef =
42     (
43      # ALTEON-PRIVATE-MIBS
44      'alteonOID'                 => '1.3.6.1.4.1.1872.1',
45      'hwPartNumber'              => '1.3.6.1.4.1.1872.2.1.1.1.0',
46      'hwRevision'                => '1.3.6.1.4.1.1872.2.1.1.2.0',
47      'agSoftwareVersion'         => '1.3.6.1.4.1.1872.2.1.2.1.7.0',
48      'agEnabledSwFeatures'       => '1.3.6.1.4.1.1872.2.1.2.1.25.0',
49      'slbCurCfgRealServerName'   => '1.3.6.1.4.1.1872.2.1.5.2.1.12',
50      'slbNewCfgRealServerName'   => '1.3.6.1.4.1.1872.2.1.5.3.1.13',
51      'slbCurCfgGroupName'        => '1.3.6.1.4.1.1872.2.1.5.10.1.7',
52      'slbNewCfgGroupName'        => '1.3.6.1.4.1.1872.2.1.5.11.1.10',
53      'slbStatPortMaintPortIndex' => '1.3.6.1.4.1.1872.2.1.8.2.1.1.1',
54      'slbStatVServerIndex'       => '1.3.6.1.4.1.1872.2.1.8.2.7.1.3',
55      );
56
57 sub checkdevtype
58 {
59     my $dd = shift;
60     my $devdetails = shift;
61
62     if( not $dd->oidBaseMatch
63         ( 'alteonOID',
64           $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
65     {
66         return 0;
67     }
68     
69     $devdetails->setCap('interfaceIndexingPersistent');
70
71     return 1;
72 }
73
74 sub discover
75 {
76     my $dd = shift;
77     my $devdetails = shift;
78
79     my $session = $dd->session();
80     my $data = $devdetails->data();
81
82     # Get the system info and display it in the comment
83     my $alteonInfo = $dd->retrieveSnmpOIDs
84         ( 'hwPartNumber', 'hwRevision', 'agSoftwareVersion',
85           'agEnabledSwFeatures', 'sysDescr' );
86
87     $data->{'param'}{'comment'} =
88         $alteonInfo->{'sysDescr'} . ", Hw Serial#: " .
89         $alteonInfo->{'hwPartNumber'} . ", Hw Revision: " .
90         $alteonInfo->{'hwRevision'} .  ", " .
91         $alteonInfo->{'agEnabledSwFeatures'} . ", Version: " .
92         $alteonInfo->{'agSoftwareVersion'};
93
94     # PROG: Discover slbStatVServerIndex (Virtual Server index)
95     my $virtTable = $session->get_table ( -baseoid =>
96                                           $dd->oiddef('slbStatVServerIndex') );
97     $devdetails->storeSnmpVars( $virtTable ); 
98     foreach my $virtIndex
99         ( $devdetails->getSnmpIndices( $dd->oiddef('slbStatVServerIndex') ) )
100     {
101         Debug("Alteon::vserver  Found index $virtIndex");
102         $data->{'VSERVER'}{$virtIndex} = 1;
103     }
104
105     # PROG: SLB Port Maintenance Statistics Table
106     my $maintTable =
107         $session->get_table ( -baseoid =>
108                               $dd->oiddef('slbStatPortMaintPortIndex') );
109     $devdetails->storeSnmpVars( $maintTable );
110     
111     foreach my $mIndex
112         ( $devdetails->getSnmpIndices
113           ( $dd->oiddef('slbStatPortMaintPortIndex') ) )
114     {
115         Debug("Alteon::maintTable  Index: $mIndex");
116         $data->{'MAINT'}{$mIndex} = 1;
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     $cb->addTemplateApplication($devNode, 'Alteon::alteon-cpu');
131     $cb->addTemplateApplication($devNode, 'Alteon::alteon-mem');
132     $cb->addTemplateApplication($devNode, 'Alteon::alteon-packets');
133     $cb->addTemplateApplication($devNode, 'Alteon::alteon-sensor');
134
135     # PROG: Virtual Server information
136     my $virtNode =
137         $cb->addSubtree( $devNode, 'VirtualServer_Stats',
138                          { 'comment' => 'Stats per Virtual Server' },
139                          [ 'Alteon::alteon-vserver-subtree'] );
140
141     foreach my $virtIndex ( sort {$a <=> $b } keys %{$data->{'VSERVER'}} )
142     {
143         $cb->addSubtree( $virtNode, 'VirtualHost_' . $virtIndex,
144                          { 'alteon-vserver-index' => $virtIndex },
145                          [ 'Alteon::alteon-vserver'] ); 
146     } 
147
148     # PROG: SLB Port Maintenance Statistics Table
149     my $maintNode =
150         $cb->addSubtree( $devNode, 'Port_Maintenance_Stats',
151                          { 'comment' => 'SLB port maintenance statistics' },
152                          [ 'Alteon::alteon-maint-subtree'] );
153     
154     foreach my $mIndex ( sort {$a <=> $b } keys %{$data->{'MAINT'}} )
155     {
156         $cb->addSubtree( $maintNode, 'Port_' . $mIndex,
157                          { 'alteon-maint-index' => $mIndex },
158                          [ 'Alteon::alteon-maint'] ); 
159     }
160
161 }
162
163 1;
164
165 # Local Variables:
166 # mode: perl
167 # indent-tabs-mode: nil
168 # perl-indent-level: 4
169 # End: