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.
18 # $Id: AlliedTelesyn_PBC18.pm,v 1.1 2010-12-27 00:03:49 ivan Exp $
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;
30 $Torrus::DevDiscover::registry{'AlliedTelesyn_PBC18'} = {
32 'checkdevtype' => \&checkdevtype,
33 'discover' => \&discover,
34 'buildConfig' => \&buildConfig
40 'ATMCCommon-MIB::mediaconverter' => '1.3.6.1.4.1.207.1.12',
41 'ATMCCommon-MIB::mcModuleName' => '1.3.6.1.4.1.207.8.41.1.1.1.1.1.2',
42 'ATMCCommon-MIB::mcModuleType' => '1.3.6.1.4.1.207.8.41.1.1.1.1.1.3',
43 'ATMCCommon-MIB::mcModuleState' => '1.3.6.1.4.1.207.8.41.1.1.1.1.1.4',
44 'ATMCCommon-MIB::mcModuleAportLinkState' =>
45 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.10',
46 'ATMCCommon-MIB::mcModuleBportLinkState' =>
47 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.11',
48 'ATMCCommon-MIB::mcModuleCportLinkState' =>
49 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.12',
50 'ATMCCommon-MIB::mcModuleDportLinkState' =>
51 '1.3.6.1.4.1.207.8.41.1.1.1.1.1.13',
56 our %knownModuleTypes =
58 8 => 'AT-PB103/1 (1x100Base-TX, 1x100Base-FX Single-Mode Fibre SC, 15km)',
65 my $devdetails = shift;
67 if( not $dd->oidBaseMatch
68 ( 'ATMCCommon-MIB::mediaconverter',
69 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
81 my $devdetails = shift;
83 my $data = $devdetails->data();
84 my $session = $dd->session();
88 my $oid = $dd->oiddef('ATMCCommon-MIB::mcModuleType');
90 my $table = $session->get_table( -baseoid => $oid );
91 if( not defined( $table ) )
96 $devdetails->storeSnmpVars( $table );
98 foreach my $INDEX ( $devdetails->getSnmpIndices($oid) )
100 my $moduleType = $devdetails->snmpVar( $oid . '.' . $INDEX );
101 if( $moduleType == 0 )
106 $data->{'PBC18'}{$INDEX} = {};
107 if( defined( $knownModuleTypes{$moduleType} ) )
109 $data->{'PBC18'}{$INDEX}{'moduleDesc'} =
110 $knownModuleTypes{$moduleType};
114 Warn('Unknown PBC18 module type: ' . $moduleType);
118 foreach my $INDEX ( keys %{$data->{'PBC18'}} )
121 foreach my $oidname ( 'ATMCCommon-MIB::mcModuleName',
122 'ATMCCommon-MIB::mcModuleState',
123 'ATMCCommon-MIB::mcModuleAportLinkState',
124 'ATMCCommon-MIB::mcModuleBportLinkState',
125 'ATMCCommon-MIB::mcModuleCportLinkState',
126 'ATMCCommon-MIB::mcModuleDportLinkState' )
128 push( @{$oids}, $dd->oiddef( $oidname ) . '.' . $INDEX );
131 my $result = $session->get_request( -varbindlist => $oids );
132 if( $session->error_status() == 0 and defined( $result ) )
134 $devdetails->storeSnmpVars( $result );
138 Error('Error retrieving PBC18 module information');
143 foreach my $INDEX ( keys %{$data->{'PBC18'}} )
145 if( $devdetails->snmpVar
146 ( $dd->oiddef('ATMCCommon-MIB::mcModuleState') .'.'.$INDEX )
149 delete $data->{'PBC18'}{$INDEX};
153 my $name = $devdetails->snmpVar
154 ( $dd->oiddef('ATMCCommon-MIB::mcModuleName') .'.'.$INDEX );
156 if( length( $name ) > 0 )
158 $data->{'PBC18'}{$INDEX}{'moduleName'} = $name;
161 foreach my $portName ('A', 'B', 'C', 'D')
163 my $oid = $dd->oiddef
164 ('ATMCCommon-MIB::mcModule'.$portName.'portLinkState').
167 my $portState = $devdetails->snmpVar ( $oid );
168 if( $portState == 1 or $portState == 2 )
170 $data->{'PBC18'}{$INDEX}{'portAvailable'}{$portName} = $oid;
179 our %portLineColors =
190 my $devdetails = shift;
194 my $data = $devdetails->data();
197 'data-file' => '%system-id%_pbc18_%pbc-module-index%.rrd',
198 'collector-scale' => '-1,*,2,+',
199 'graph-lower-limit' => 0,
200 'graph-upper-limit' => 1,
202 'rrd-create-dstype' => 'GAUGE',
204 'RRA:MAX:0:1:4032 RRA:MAX:0.17:6:2016 RRA:MAX:0.042:288:732',
206 'has-overview-shortcuts' => 'yes',
207 'overview-shortcuts' => 'links',
208 'overview-subleave-name-links' => 'AllPorts',
209 'overview-shortcut-text-links' => 'All modules',
210 'overview-shortcut-title-links' => 'All converter modules',
211 'overview-page-title-links' => 'All converter modules',
214 $cb->addParams( $devNode, $param );
216 foreach my $INDEX ( sort {$a<=>$b} keys %{$data->{'PBC18'}} )
218 my $param = { 'pbc-module-index' => $INDEX };
220 if( defined( $data->{'PBC18'}{$INDEX}{'moduleDesc'} ) )
223 'Module type: ' . $data->{'PBC18'}{$INDEX}{'moduleDesc'};
226 if( defined( $data->{'PBC18'}{$INDEX}{'moduleName'} ) )
228 $param->{'comment'} =
229 $data->{'PBC18'}{$INDEX}{'moduleName'};
232 my $modNode = $cb->addSubtree( $devNode, 'Module_' . $INDEX, $param );
235 'ds-type' => 'rrd-multigraph',
237 'graph-lower-limit' => '0',
238 'precedence' => '1000',
239 'comment' => 'Ports status',
240 'vertical-label' => 'Status',
245 ( sort keys %{$data->{'PBC18'}{$INDEX}{'portAvailable'}} )
249 $mgParam->{'ds-names'} .= ',';
252 my $dsname = 'port' . $portName;
253 $mgParam->{'ds-names'} .= $dsname;
255 $mgParam->{'graph-legend-' . $dsname} = 'Port ' . $portName;
256 $mgParam->{'line-style-' . $dsname} = 'LINE2';
257 $mgParam->{'line-color-' . $dsname} = $portLineColors{$portName};
258 $mgParam->{'line-order-' . $dsname} = $n;
259 $mgParam->{'ds-expr-' . $dsname} = '{Port_' . $portName . '}';
262 'rrd-ds' => 'Port' . $portName,
264 $data->{'PBC18'}{$INDEX}{'portAvailable'}{$portName},
267 $cb->addLeaf( $modNode, 'Port_' . $portName, $param );
271 $cb->addLeaf( $modNode, 'AllPorts', $mgParam );
282 # indent-tabs-mode: nil
283 # perl-indent-level: 4