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 # $Id: Apple_AE.pm,v 1.1 2010-12-27 00:03:55 ivan Exp $
19 # Jon Nistor <nistor at snickers.org>
21 # Apple Airport Extreme Discovery Module
23 # NOTE: Options for this module:
24 # Apple_AE::disable-clients
26 package Torrus::DevDiscover::Apple_AE;
32 $Torrus::DevDiscover::registry{'Apple_AE'} = {
34 'checkdevtype' => \&checkdevtype,
35 'discover' => \&discover,
36 'buildConfig' => \&buildConfig
42 # Apple Airport Extreme
43 'airportObject' => '1.3.6.1.4.1.63.501',
44 'baseStation3' => '1.3.6.1.4.1.63.501.3',
47 'sysConfName' => '1.3.6.1.4.1.63.501.3.1.1.0',
48 'sysConfContact' => '1.3.6.1.4.1.63.501.3.1.2.0',
49 'sysConfLocation' => '1.3.6.1.4.1.63.501.3.1.3.0',
50 'sysConfFirmwareVersion' => '1.3.6.1.4.1.63.501.3.1.5.0',
52 'wirelessNumber' => '1.3.6.1.4.1.63.501.3.2.1.0',
53 'wirelessPhysAddress' => '1.3.6.1.4.1.63.501.3.2.2.1.1'
60 my $devdetails = shift;
62 # PROG: Standard sysObject does not work on Airport devices
63 # So we will match on the specific OID
64 if( not $dd->checkSnmpOID('sysConfName') )
69 $devdetails->setCap('interfaceIndexingPersistent');
78 my $devdetails = shift;
80 my $session = $dd->session();
81 my $data = $devdetails->data();
83 # NOTE: Comments and Serial number of device
85 $dd->retrieveSnmpOIDs( 'sysConfName', 'sysConfLocation',
86 'sysConfFirmwareVersion' );
88 if( defined( $chassisInfo ) )
90 if( not $chassisInfo->{'sysConfLocation'} )
92 $chassisInfo->{'sysConfLocation'} = "unknown";
95 $data->{'param'}{'comment'} = "Apple Airport Extreme, " .
96 "Fw#: " . $chassisInfo->{'sysConfFirmwareVersion'} . ", " .
97 $chassisInfo->{'sysConfName'} . " located at " .
98 $chassisInfo->{'sysConfLocation'};
100 $data->{'param'}{'comment'} = "Apple Airport Extreme";
104 # PROG: Find wireless clients
105 if( $devdetails->param('Apple_AE::disable-clients') ne 'yes' )
107 my $numWireless = $dd->retrieveSnmpOIDs('wirelessNumber');
110 $session->get_table( -baseoid =>
111 $dd->oiddef('wirelessPhysAddress') );
112 $devdetails->storeSnmpVars( $tableClients );
114 if( $tableClients && ($numWireless->{'wirelessNumber'} > 0) )
116 # PROG: setCap that we actually have clients ...
117 $devdetails->setCap('AE_clients');
119 foreach my $wClient ( $devdetails->getSnmpIndices
120 ($dd->oiddef('wirelessPhysAddress')) )
122 my $wMAC = $devdetails->snmpVar(
123 $dd->oiddef('wirelessPhysAddress') . "." . $wClient);
126 $data->{'Apple_AE'}{'wClients'}{$wClient} = undef;
127 $data->{'Apple_AE'}{'wClients'}{$wClient}{'wMAC'} = $wMAC;
129 Debug("Apple_AE:: Client $wMAC / $wClient");
140 my $devdetails = shift;
143 my $data = $devdetails->data();
146 # Wireless Client information
147 if( $devdetails->hasCap('AE_clients') )
150 $cb->addSubtree( $devNode, 'Wireless_Clients', undef,
151 [ 'Apple_AE::ae-wireless-clients-subtree'] );
153 foreach my $wClient ( keys %{$data->{'Apple_AE'}{'wClients'}} )
155 my $airport = $data->{'Apple_AE'}{'wClients'}{$wClient};
156 my $wMAC = $airport->{'wMAC'};
161 $cb->addSubtree( $nodeTop, $wMACfix,
162 { 'wireless-mac' => $wMAC,
163 'wireless-macFix' => $wMACfix,
164 'wireless-macOid' => $wClient },
165 [ 'Apple_AE::ae-wireless-clients-leaf' ] );
169 # PROG: Adding global statistics
170 $cb->addTemplateApplication( $devNode, 'Apple_AE::ae-global-stats');
178 # indent-tabs-mode: nil
179 # perl-indent-level: 4