Below is a trivial MRTG external module for watching the Linksys WET-11 with firmware 1.4.3. It can watch wireless and Ethernet in and out, transmit rate or link quality. If you make any improvements, please send me a copy.
- John #!/usr/bin/perl # Linksys WET-11 MRTG external data generator # Requires 1.4.3 firmware # John Foust [EMAIL PROTECTED] # v1.0 2/26/03 # Derived from www.acelere.net/notes code, modeled after ap-mrtg # Requires 'curl'/'wget' and 'perl' # Invoked as 'wet11.pl admin:admin 192.168.2.73 e #print scalar(@ARGV); #print @ARGV[0]; # Someday figure out why http://www.perlmonks.org/index.pl?node_id=21074 # doesn't work for this... sub charToSixBits { return index(".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_", $_[0]); } # Confirm number of arguments # hostname or IP of target WET-11 # admin:admin style user/password # e Ethernet, w wireless, t transmit, q link quality # Passed on command line $addr = $ARGV[0]; $userpass = $ARGV[1]; $what = $ARGV[2]; # Ask the WET-11 for its encoded info block # Could use 'curl -s -u admin:admin http://${F}/info_data.js' # or a Perl module... # $X = qx(wget -q -O - http://admin:[EMAIL PROTECTED]/info_data.js); $X = qx(wget -q -O - http://[EMAIL PROTECTED]/info_data.js); # Error check returned string if (length($X) ne 175) { printf("-\n-\n-\n-\n"); exit; } # Remove the info=" prefix $X = substr $X,6,-1; # Convert string $X (base64) to $S (binary) $S = ""; while ($X) { $cc = (charToSixBits(substr($X,0,1)) << 18) + (charToSixBits(substr($X,1,1)) << 12) + (charToSixBits(substr($X,2,1)) << 6) + (charToSixBits(substr($X,3,1))); $S = $S . chr(($cc >> 16) & 255) . chr(($cc >> 8) & 255) . chr($cc & 255); $X = substr($X,4); } # Fields are: # 2 junk # 32 device name # 6 MAC # 4 IP # 4 Subnet # 4 Gateway # 2 LanTX packet count # 2 LanRX packet count # 2 WLanTX packet count # 2 WLanRX packet count # 32 SSID # 1 ntype (adhoc, infr) # 1 channel # 1 WEP # 6 Client MAC # 1 TX rate # 1 Quality # 6 BSSID ($devname, $firmware, $MAC, $IP, $Subnet, $Gateway, $LANTx, $LANRx, $WLANTx, $WLANRx, $SSID, $ntype, $channel, $WEP, $firstClient, $txrate, $quality, $BSSID) = unpack("x2 A32 a3 H12 N N N n n n n A32 c1 c1 c1 H12 c1 c1 H12", $S); # Confirm firmware version? # Emit LAN or wireless values if ($what eq "e") { printf("%d\n%d\n", $LANTx, $LANRx ); } elsif ($what eq "w") { printf("%d\n%d\n", $WLANTx, $WLANRx ); } # Or transmit rate: and a zero for Out rate elsif ($what eq "t") { printf("%s\n0\n", ($txrate <= 1) ? "1" : ($txrate <= 3) ? "2" : ($txrate <= 7) ? "5.5" : "11"); } # Or link quality: and a zero for Out rate elsif ($what eq "q") { printf("%d\n0\n", int(0.5 + ((100 * $quality) / 92)) ); } else { printf("0\n0\n"); } # Always emit uptime and device name printf("\-\n%s\n", $devname ); -- general wireless list, a bawug thing <http://www.bawug.org/> [un]subscribe: http://lists.bawug.org/mailman/listinfo/wireless
