2 # Copyright (C) 2007 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 # Jon Nistor <nistor at snickers.org>
20 # Apple Airport Extreme Discovery Module
22 # NOTE: Options for this module:
23 # Apple_AE::disable-clients
25 package Torrus
::DevDiscover
::Apple_AE
;
35 $Torrus::DevDiscover
::registry
{'Apple_AE'} = {
37 'checkdevtype' => \
&checkdevtype
,
38 'discover' => \
&discover
,
39 'buildConfig' => \
&buildConfig
45 # Apple Airport Extreme
46 'airportObject' => '1.3.6.1.4.1.63.501',
47 'baseStation3' => '1.3.6.1.4.1.63.501.3',
50 'sysConfName' => '1.3.6.1.4.1.63.501.3.1.1.0',
51 'sysConfContact' => '1.3.6.1.4.1.63.501.3.1.2.0',
52 'sysConfLocation' => '1.3.6.1.4.1.63.501.3.1.3.0',
53 'sysConfFirmwareVersion' => '1.3.6.1.4.1.63.501.3.1.5.0',
55 'wirelessNumber' => '1.3.6.1.4.1.63.501.3.2.1.0',
56 'wirelessPhysAddress' => '1.3.6.1.4.1.63.501.3.2.2.1.1'
63 my $devdetails = shift;
65 # PROG: Standard sysObject does not work on Airport devices
66 # So we will match on the specific OID
67 if( not $dd->checkSnmpOID('sysConfName') )
72 $devdetails->setCap('interfaceIndexingPersistent');
81 my $devdetails = shift;
83 my $session = $dd->session();
84 my $data = $devdetails->data();
86 # NOTE: Comments and Serial number of device
88 $dd->retrieveSnmpOIDs( 'sysConfName', 'sysConfLocation',
89 'sysConfFirmwareVersion' );
91 if( defined( $chassisInfo ) )
93 if( not $chassisInfo->{'sysConfLocation'} )
95 $chassisInfo->{'sysConfLocation'} = "unknown";
98 $data->{'param'}{'comment'} = "Apple Airport Extreme, " .
99 "Fw#: " . $chassisInfo->{'sysConfFirmwareVersion'} . ", " .
100 $chassisInfo->{'sysConfName'} . " located at " .
101 $chassisInfo->{'sysConfLocation'};
103 $data->{'param'}{'comment'} = "Apple Airport Extreme";
107 # PROG: Find wireless clients
108 if( $devdetails->paramDisabled('Apple_AE::disable-clients') )
110 my $numWireless = $dd->retrieveSnmpOIDs('wirelessNumber');
113 $session->get_table( -baseoid
=>
114 $dd->oiddef('wirelessPhysAddress') );
115 $devdetails->storeSnmpVars( $tableClients );
117 if( $tableClients && ($numWireless->{'wirelessNumber'} > 0) )
119 # PROG: setCap that we actually have clients ...
120 $devdetails->setCap('AE_clients');
122 for my $wClient ( $devdetails->getSnmpIndices
123 ($dd->oiddef('wirelessPhysAddress')) )
125 my $wMAC = $devdetails->snmpVar(
126 $dd->oiddef('wirelessPhysAddress') . "." . $wClient);
129 $data->{'Apple_AE'}{'wClients'}{$wClient} = undef;
130 $data->{'Apple_AE'}{'wClients'}{$wClient}{'wMAC'} = $wMAC;
132 Debug
("Apple_AE:: Client $wMAC / $wClient");
143 my $devdetails = shift;
146 my $data = $devdetails->data();
149 # Wireless Client information
150 if( $devdetails->hasCap('AE_clients') )
153 $cb->addSubtree( $devNode, 'Wireless_Clients', undef,
154 [ 'Apple_AE::ae-wireless-clients-subtree'] );
156 for my $wClient ( keys %{$data->{'Apple_AE'}{'wClients'}} )
158 my $airport = $data->{'Apple_AE'}{'wClients'}{$wClient};
159 my $wMAC = $airport->{'wMAC'};
164 $cb->addSubtree( $nodeTop, $wMACfix,
165 { 'wireless-mac' => $wMAC,
166 'wireless-macFix' => $wMACfix,
167 'wireless-macOid' => $wClient },
168 [ 'Apple_AE::ae-wireless-clients-leaf' ] );
172 # PROG: Adding global statistics
173 $cb->addTemplateApplication( $devNode, 'Apple_AE::ae-global-stats');
183 # indent-tabs-mode: nil
184 # perl-indent-level: 4