2 # Copyright (C) 2009 Jon Nistor
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 # $Id: FTOS.pm,v 1.1 2010-12-27 00:03:54 ivan Exp $
19 # Jon Nistor <nistor at snickers.org>
21 # Force10 Networks Real Time Operating System Software
23 # NOTE: FTOS::disable-cpu
25 # FTOS::disable-temperature
26 # FTOS::use-fahrenheit
27 # FTOS::file-per-sensor (affects both power and temperature)
29 package Torrus::DevDiscover::FTOS;
34 $Torrus::DevDiscover::registry{'FTOS'} = {
36 'checkdevtype' => \&checkdevtype,
37 'discover' => \&discover,
38 'buildConfig' => \&buildConfig
45 'f10Products' => '1.3.6.1.4.1.6027.1',
48 'chType' => '1.3.6.1.4.1.6027.3.1.1.1.1.0',
49 'chSerialNumber' => '1.3.6.1.4.1.6027.3.1.1.1.2.0',
50 'chSysPowerSupplyIndex' => '1.3.6.1.4.1.6027.3.1.1.2.1.1.1',
51 'chSysCardSlotIndex' => '1.3.6.1.4.1.6027.3.1.1.2.3.1.1',
52 'chSysCardNumber' => '1.3.6.1.4.1.6027.3.1.1.2.3.1.3',
53 'chRpmCpuIndex' => '1.3.6.1.4.1.6027.3.1.1.3.7.1.1',
55 # FORCE10-SYSTEM-COMPONENT-MIB
56 'camUsagePartDesc' => '1.3.6.1.4.1.6027.3.7.1.1.1.1.4'
62 '1' => 'Force10 E1200 16-slot switch/router',
63 '2' => 'Force10 E600 9-slot switch/router',
64 '3' => 'Force10 E300 8-slot switch/router',
65 '4' => 'Force10 E150 8-slot switch/router',
66 '5' => 'Force10 E610 9-slot switch/router',
67 '6' => 'Force10 C150 6-slot switch/router',
68 '7' => 'Force10 C300 10-slot switch/router',
69 '8' => 'Force10 E1200i 16-slot switch/router',
70 '9' => 'Force10 S2410 10GbE switch',
71 '10' => 'Force10 S2410 10GbE switch',
72 '11' => 'Force10 S50 access switch',
73 '12' => 'Force10 S50e access switch',
74 '13' => 'Force10 S50v access switch',
75 '14' => 'Force10 S50nac access switch',
76 '15' => 'Force10 S50ndc access switch',
77 '16' => 'Force10 S25pdc access switch',
78 '17' => 'Force10 S25pac access switch',
79 '18' => 'Force10 S25v access switch',
80 '19' => 'Force10 S25n access switch'
85 '1' => 'Control Processor',
86 '2' => 'Routing Processor #1',
87 '3' => 'Routing Processor #2'
91 # Not all interfaces are normally needed to monitor.
92 # You may override the interface filtering in devdiscover-siteconfig.pl:
93 # redefine $Torrus::DevDiscover::FTOS::interfaceFilter
94 # or define $Torrus::DevDiscover::FTOS::interfaceFilterOverlay
97 our $interfaceFilterOverlay;
98 my %ftosInterfaceFilter;
100 if( not defined( $interfaceFilter ) )
102 $interfaceFilter = \%ftosInterfaceFilter;
106 # Key is some unique symbolic name, does not mean anything
107 # ifType is the number to match the interface type
108 # ifDescr is the regexp to match the interface description
109 %ftosInterfaceFilter =
112 'ifType' => 1, # other
115 'ifType' => 24, # softwareLoopback
124 my $devdetails = shift;
126 if( not $dd->oidBaseMatch
128 $devdetails->snmpVar( $dd->oiddef('sysObjectID') ) ) )
133 # Systems running FTOS will have chassisType, SFTOS will not.
134 if( not $dd->checkSnmpOID('chType') )
139 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
140 ($devdetails, $interfaceFilter);
142 if( defined( $interfaceFilterOverlay ) )
144 &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
145 ($devdetails, $interfaceFilterOverlay);
148 $devdetails->setCap('interfaceIndexingPersistent');
157 my $devdetails = shift;
159 my $session = $dd->session();
160 my $data = $devdetails->data();
162 # NOTE: Comments and Serial number of device
163 my $chassisSerial = $dd->retrieveSnmpOIDs( 'chType', 'chSerialNumber' );
165 if( defined( $chassisSerial ) )
167 $data->{'param'}{'comment'} =
168 %f10ChassisType->{$chassisSerial->{'chType'}} .
169 ', Hw Serial#: ' . $chassisSerial->{'chSerialNumber'};
173 $data->{'param'}{'comment'} = "Force10 Networks switch/router";
176 # PROG: CPU statistics
177 if( $devdetails->param('FTOS::disable-cpu') ne 'yes' )
179 # Poll table to translate the CPU Index to a Name
181 $session->get_table( -baseoid => $dd->oiddef('chRpmCpuIndex') );
183 $devdetails->storeSnmpVars( $ftosCpuTable );
185 if( defined( $ftosCpuTable ) )
187 $devdetails->setCap('ftosCPU');
189 # Find the index of the CPU
190 foreach my $ftosCPUidx ( $devdetails->getSnmpIndices
191 ( $dd->oiddef('chRpmCpuIndex') ) )
193 my $cpuType = $dd->oiddef('chRpmCpuIndex') . "." . $ftosCPUidx;
194 my $cpuName = %f10CPU->{$ftosCpuTable->{$cpuType}};
196 Debug("FTOS::CPU index $ftosCPUidx, $cpuName");
198 # Construct the data ...
199 $data->{'ftosCPU'}{$ftosCPUidx} = $cpuName;
204 Debug("FTOS::CPU No CPU information found, old sw?");
209 # PROG: Power Supplies
210 if( $devdetails->param('FTOS::disable-power') ne 'yes' )
212 # Poll table of power supplies
214 $session->get_table( -baseoid =>
215 $dd->oiddef('chSysPowerSupplyIndex') );
217 $devdetails->storeSnmpVars( $ftosPSUTable );
219 if( defined( $ftosPSUTable ) )
221 $devdetails->setCap('ftosPSU');
223 # Find the Index of the Power Supplies
224 foreach my $ftosPSUidx ( $devdetails->getSnmpIndices
225 ($dd->oiddef('chSysPowerSupplyIndex')) )
227 Debug("FTOS::PSU index $ftosPSUidx");
229 push( @{$data->{'ftosPSU'}}, $ftosPSUidx );
236 if( $devdetails->param('FTOS::disable-sensors') ne 'yes' )
238 # Check if temperature sensors are supported
240 $session->get_table( -baseoid =>
241 $dd->oiddef('chSysCardSlotIndex') );
242 $devdetails->storeSnmpVars( $sensorTable );
245 $session->get_table( -baseoid => $dd->oiddef('chSysCardNumber') );
246 $devdetails->storeSnmpVars( $sensorCard );
249 if( defined( $sensorTable ) )
251 $devdetails->setCap('ftosSensor');
253 foreach my $sensorIdx ( $devdetails->getSnmpIndices
254 ( $dd->oiddef('chSysCardSlotIndex') ) )
257 $devdetails->snmpVar( $dd->oiddef('chSysCardNumber') .
260 $data->{'ftosSensor'}{$sensorIdx} = $sensorCard;
262 Debug("FTOS::Sensor index $sensorIdx, card $sensorCard");
264 } # END if: $sensorTable
265 } # END: disable-sensors
274 my $devdetails = shift;
277 my $data = $devdetails->data();
280 # PROG: CPU processing
281 if( $devdetails->hasCap('ftosCPU') )
283 my $nodeTop = $cb->addSubtree( $devNode, 'CPU_Usage', undef,
284 [ 'FTOS::ftos-cpu-subtree'] );
286 foreach my $CPUidx ( sort {$a <=> $b} keys %{$data->{'ftosCPU'}} )
288 my $CPUName = $data->{'ftosCPU'}{$CPUidx};
289 my $subName = sprintf( 'CPU_%.2d', $CPUidx );
291 my $nodeCPU = $cb->addSubtree( $nodeTop, $subName,
292 { 'comment' => $CPUName,
293 'cpu-index' => $CPUidx,
294 'cpu-name' => $CPUName },
295 [ 'FTOS::ftos-cpu' ] );
300 # PROG: Power supplies
301 if( $devdetails->hasCap('ftosPSU') )
303 my $subtreeName = "Power_Supplies";
304 my $param = { 'comment' => 'Power supplies status',
305 'precedence' => -600 };
307 = $devdetails->param('FTOS::file-per-sensor') eq 'yes';
310 $param->{'data-file'} = '%snmp-host%_power' .
311 ($filePerSensor ? '_%power-index%':'') .
314 my $nodeTop = $cb->addSubtree( $devNode, $subtreeName,
315 $param, $templates );
318 foreach my $PSUidx ( sort {$a <=> $b} @{$data->{'ftosPSU'}} )
320 my $leafName = sprintf( 'power_%.2d', $PSUidx );
322 my $nodePSU = $cb->addLeaf( $nodeTop, $leafName,
323 { 'power-index' => $PSUidx },
324 [ 'FTOS::ftos-power-supply-leaf' ]);
329 # PROG: Temperature sensors
330 if( $devdetails->hasCap('ftosSensor') )
332 my $subtreeName = "Temperature_Sensors";
334 my $fahrenheit = $devdetails->param('FTOS::use-fahrenheit') eq 'yes';
336 = $devdetails->param('FTOS::file-per-sensor') eq 'yes';
337 my $templates = [ 'FTOS::ftos-temperature-subtree' ];
339 $param->{'data-file'} = '%snmp-host%_sensors' .
340 ($filePerSensor ? '_%sensor-index%':'') .
341 ($fahrenheit ? '_fahrenheit':'') . '.rrd';
343 my $subtreeNode = $cb->addSubtree( $devNode, $subtreeName,
344 $param, $templates );
346 foreach my $sIndex ( sort {$a<=>$b} keys %{$data->{'ftosSensor'}} )
348 my $leafName = sprintf( 'sensor_%.2d', $sIndex );
349 my $threshold = 60; # Forced value for the time being, 60 degC
350 my $sensorCard = $data->{'ftosSensor'}{$sIndex};
354 $threshold = $threshold * 1.8 + 32;
358 'sensor-index' => $sIndex,
359 'sensor-description' => 'Module ' . $sensorCard,
360 'upper-limit' => $threshold
363 my $templates = ['FTOS::ftos-temperature-sensor' .
364 ($fahrenheit ? '-fahrenheit':'')];
366 $cb->addLeaf( $subtreeNode, $leafName, $param, $templates );
376 # indent-tabs-mode: nil
377 # perl-indent-level: 4