rt311.pl - readme
Written by Spencer Thomas
Contact me at evoluder@bellsouth.net or http://partypics.kicks-ass.net for questions/comments/contributions.

I was fairly disappointed that my Netgear RT311 router (if you can call it that) didn't support SNMP. I really 
wanted to monitor my home network traffic with MRTG. Well, I knew that you could get the "SNMP like" data from 
the stat page on the web interface so I wrote this script to get the data with Lynx and parse it out. I tested 
this script under Redhat 7.2, Lynx 2.8rel1, and the 3.25 RT311 ROM with little/no problems. I imagine with a 
little work you could even get it to run under Windows or anything else that can talk PERL. It seems to work 
fine so long as you don't try to log into the web interface while this is in the cron as the router will "lock 
out" attempts to log into the router from different machines (IPs?). So basically if you want to get into the 
router you will probably have to keep this from running while you do it. I would imagine this script could 
probably be adapted to other routers (devices?) that have web interfaces, so I am open to suggestions. Feel 
free to modify this script so long as you give me credit and contribute to the MRTG project. Some example 
configs and the usage are listed below. A more efficient version of this script would get all of the data (and 
store it in a file?) at once and then have MRTG get each piece so you didn't have to hit the web interface 4 
times for all of the data. If there is any interest in this script (email me!) I will do it. The router also 
has a few other little bits of information that might be useful and could be included in future versions as 
well. Of course, none of this would even be necessary if Neatgear would release a ROM for the RT311 that 
included SNMP!

Before you do anything, make sure you examine the top part of the script and change the variables to match your 
system, the script WILL NOT WORK unless you do this!

Usage: rt311.pl [interface] [output]

The interface is either "wan" or "lan" and the output is "bytes" or "packets"

So, in order to get the RX/TX bytes from the LAN interface you would use :

rt311.pl lan bytes

and you should get something like this :

1234
5678
01:01:01
100M/Full

Here are my configs for all four sets of data you can get from this script. I am no MRTG/RT311 expert, so please 
let me know if any are in error.

For "wan packets" or "lan packets" :

#---------wanpk--------------------------------
Target[wanpk]: `/usr/local/mrtg-2/bin/rt311.pl wan packets`
Options[wanpk]: nopercent,growright
MaxBytes[wanpk]:1250000
YLegend[wanpk]: packets
ShortLegend[wanpk]: packets
Legend1[wanpk]: TX Packets
Legend2[wanpk]: RX Packets
LegendI[wanpk]: TX Packets:
LegendO[wanpk]: RX Packets:
Title[wanpk]: Packets RX/TX on RT311 WAN
PageTop[wanpk]: Packets RX/TX on RT311 WAN
WithPeak[wanpk]:wmy
Legend3[wanpk]: Packets TX max
Legend4[wanpk]: Packets RX max
#--------end wanpk-----------------------------

(I know that "MaxBytes" could probably be a lot lower, but this seems to be ok)

For "wan bytes" or "lan bytes" :

#---------wanbytes-----------------------
Target[wanbytes]: `/usr/local/mrtg-2/bin/rt311.pl wan bytes`
Options[wanbytes]: nopercent, growright,gauge
MaxBytes[wanbytes]:1250000
YLegend[wanbytes]: bytes/s
ShortLegend[wanbytes]: b/s
Legend1[wanbytes]: TX bytes/s
Legend2[wanbytes]: RX bytes/s
LegendI[wanbytes]: TX bytes/s:
LegendO[wanbytes]: RX bytes/s:
Title[wanbytes]: Bytes/s RX/TX on RT311 WAN
PageTop[wanbytes]: Bytes/s RX/TX on RT311 WAN
WithPeak[wanbytes]:wmy
Legend3[wanbytes]: bytes/s TX max
Legend4[wanbytes]: bytes/s RX max
#---------end wanbytes-------------------



