1 # Copyright (C) 2004 Marc Haber
2 # Copyright (C) 2005 Stanislav Sinyagin
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # Marc Haber <mh+torrus-devel@zugschlus.de>
20 # Redesigned by Stanislav Sinyagin
22 # Allied Telesyn 18-Slot Media Converter Chassis
24 package Torrus
::DevDiscover
::AlliedTelesyn_PBC18
;
34 $Torrus::DevDiscover
::registry
{'AlliedTelesyn_PBC18'} = {
36 'checkdevtype' => \
&checkdevtype
,
37 'discover' => \
&discover
,
38 'buildConfig' => \
&buildConfig
44 'ATMCCommon-MIB::mediaconverter' => '1.3.6.1.4.1.207.1.12',
45 'ATMCCommon-MIB::mcModuleName' => '1.3.6.1.4.1.207.8.41.1.1.1.1.1.2',
46 'ATMCCommon-MIB::mcModuleType' => '1.3.6.1.4.1.207.8.41.1.1.1.1.1.3',
47 'ATMCCommon-MIB::mcModuleState' => '1.3.6.1.4.1.207.8.41.1.1.1.1.1.4',
48 'ATMCCommon-MIB::mcModuleAportLinkState' =>
49 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.10',
50 'ATMCCommon-MIB::mcModuleBportLinkState' =>
51 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.11',
52 'ATMCCommon-MIB::mcModuleCportLinkState' =>
53 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.12',
54 'ATMCCommon-MIB::mcModuleDportLinkState' =>
55 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.13',
60 our %knownModuleTypes =
62 8 => 'AT-PB103/1 (1x100Base-TX, 1x100Base-FX Single-Mode Fibre SC, 15km)',
69 my $devdetails = shift;
71 if( not $dd->oidBaseMatch
72 ( 'ATMCCommon-MIB::mediaconverter',
73 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
85 my $devdetails = shift;
87 my $data = $devdetails->data();
88 my $session = $dd->session();
92 my $base = $dd->oiddef('ATMCCommon-MIB::mcModuleType');
94 my $table = $session->get_table( -baseoid
=> $base );
95 if( not defined( $table ) )
100 $devdetails->storeSnmpVars( $table );
102 for my $INDEX ( $devdetails->getSnmpIndices($base) )
104 my $moduleType = $devdetails->snmpVar( $base . '.' . $INDEX );
105 if( $moduleType == 0 )
110 $data->{'PBC18'}{$INDEX} = {};
111 if( defined( $knownModuleTypes{$moduleType} ) )
113 $data->{'PBC18'}{$INDEX}{'moduleDesc'} =
114 $knownModuleTypes{$moduleType};
118 Warn
('Unknown PBC18 module type: ' . $moduleType);
122 for my $INDEX ( keys %{$data->{'PBC18'}} )
125 for my $oidname ( 'ATMCCommon-MIB::mcModuleName',
126 'ATMCCommon-MIB::mcModuleState',
127 'ATMCCommon-MIB::mcModuleAportLinkState',
128 'ATMCCommon-MIB::mcModuleBportLinkState',
129 'ATMCCommon-MIB::mcModuleCportLinkState',
130 'ATMCCommon-MIB::mcModuleDportLinkState' )
132 push( @
{$oids}, $dd->oiddef( $oidname ) . '.' . $INDEX );
135 my $result = $session->get_request( -varbindlist
=> $oids );
136 if( $session->error_status() == 0 and defined( $result ) )
138 $devdetails->storeSnmpVars( $result );
142 Error
('Error retrieving PBC18 module information');
147 for my $INDEX ( keys %{$data->{'PBC18'}} )
149 if( $devdetails->snmpVar
150 ( $dd->oiddef('ATMCCommon-MIB::mcModuleState') .'.'.$INDEX )
153 delete $data->{'PBC18'}{$INDEX};
157 my $name = $devdetails->snmpVar
158 ( $dd->oiddef('ATMCCommon-MIB::mcModuleName') .'.'.$INDEX );
160 if( defined($name) and $name ne '' )
162 $data->{'PBC18'}{$INDEX}{'moduleName'} = $name;
165 for my $portName ('A', 'B', 'C', 'D')
167 my $oid = $dd->oiddef
168 ('ATMCCommon-MIB::mcModule'.$portName.'portLinkState').
171 my $portState = $devdetails->snmpVar ( $oid );
172 if( $portState == 1 or $portState == 2 )
174 $data->{'PBC18'}{$INDEX}{'portAvailable'}{$portName} = $oid;
183 our %portLineColors =
194 my $devdetails = shift;
198 my $data = $devdetails->data();
201 'data-file' => '%system-id%_pbc18_%pbc-module-index%.rrd',
202 'collector-scale' => '-1,*,2,+',
203 'graph-lower-limit' => 0,
204 'graph-upper-limit' => 1,
206 'rrd-create-dstype' => 'GAUGE',
208 'RRA:MAX:0:1:4032 RRA:MAX:0.17:6:2016 RRA:MAX:0.042:288:732',
210 'has-overview-shortcuts' => 'yes',
211 'overview-shortcuts' => 'links',
212 'overview-subleave-name-links' => 'AllPorts',
213 'overview-shortcut-text-links' => 'All modules',
214 'overview-shortcut-title-links' => 'All converter modules',
215 'overview-page-title-links' => 'All converter modules',
218 $cb->addParams( $devNode, $param );
220 for my $INDEX ( sort {$a<=>$b} keys %{$data->{'PBC18'}} )
222 my $modParam = { 'pbc-module-index' => $INDEX };
224 if( defined( $data->{'PBC18'}{$INDEX}{'moduleDesc'} ) )
226 $modParam->{'legend'} =
227 'Module type: ' . $data->{'PBC18'}{$INDEX}{'moduleDesc'};
230 if( defined( $data->{'PBC18'}{$INDEX}{'moduleName'} ) )
232 $modParam->{'comment'} =
233 $data->{'PBC18'}{$INDEX}{'moduleName'};
237 $cb->addSubtree( $devNode, 'Module_' . $INDEX, $modParam );
240 'ds-type' => 'rrd-multigraph',
242 'graph-lower-limit' => '0',
243 'precedence' => '1000',
244 'comment' => 'Ports status',
245 'vertical-label' => 'Status',
250 ( sort keys %{$data->{'PBC18'}{$INDEX}{'portAvailable'}} )
254 $mgParam->{'ds-names'} .= ',';
257 my $dsname = 'port' . $portName;
258 $mgParam->{'ds-names'} .= $dsname;
260 $mgParam->{'graph-legend-' . $dsname} = 'Port ' . $portName;
261 $mgParam->{'line-style-' . $dsname} = 'LINE2';
262 $mgParam->{'line-color-' . $dsname} = $portLineColors{$portName};
263 $mgParam->{'line-order-' . $dsname} = $n;
264 $mgParam->{'ds-expr-' . $dsname} = '{Port_' . $portName . '}';
267 'rrd-ds' => 'Port' . $portName,
269 $data->{'PBC18'}{$INDEX}{'portAvailable'}{$portName},
272 $cb->addLeaf( $modNode, 'Port_' . $portName, $portParam );
276 $cb->addLeaf( $modNode, 'AllPorts', $mgParam );
288 # indent-tabs-mode: nil
289 # perl-indent-level: 4