*/ ?>

Traffic Logging with WRTbwlog

Filed Under Gadgets & Hardware, Hacks and Mods on 2006-10-07, 01:32

I’m a stats junkie, I’ll be the first to admit it. Ever since the first few days at college on a T1 line I’ve wanted to keep an eye on how much bandwidth I could burn through. With a few additions to DD-WRT on the Linksys WRT54G router you can see where all your bandwidth is going. The WRTbwlog page has some great info on setting things up, but we ran into a few snags so we thought it was worth a post. Here’s how to test it out to see how you like it:

First, we’ll assume you’ve already purchased a Linksys WRT54G router and flashed the firmware to install DD-WRT. We’re working with DD-WRT v23 SP1 Final (05/16/06) std.

Next you’ll need to go and get a copy of WRTbwlog. As of writing this the version of WRTbwlog that’s actually available on their site does not work with the latest releases of DD-WRT. But never fear, krikkit over on the DD-WRT forums fixed it. You can read all about it in this thread. So we’ll use this copy of his fixed version. But wait, let’s save us some trouble and just download it straight to the router.

Go ahead and ssh into the DD-WRT router. (how to enable ssh) Copy and paste the following commands:

cd /tmp
wget http://www.geeked.info/wp-content/files/wrtbwlog_cust_exp.tgz
tar -xzf wrtbwlog_cust_exp.tgz
rm wrtbwlog_cust_exp.tgz
cd bwlog
./start.sh

This should startup WRTbwlog. If you grabbed krikkit’s version, you’ll probably see a message that says:
ftpget: Unable to connect to remote host (192.168.1.100): No route to host
You can either ignore it or you can download our fixed copy.

Now, from a desktop load up a web browser, hit a few of your favorite websites to generate some traffic, and then go to http://192.168.1.1:8000/traffic.cgi and marvel at the stats. (If your router isn’t 192.168.1.1, replace it with the appropriate IP address obviously). Go surf some sites, download some things, and then go back and refresh the traffic page. Pretty slick, eh?

Only one problem at this point, you’d have to execute the commands above every single time you rebooted your router. If you’re like me, that’s once every few weeks, but it would still be a pain. So let’s get bwlog installed permanently on the router. It’s painless, I promise.

Log into the web interface for DD-WRT and go to the Administration tab->Diagnostics Tab. Most of you can probably just click here.
We’re going to add something so that WRTbwlog is automatically installed and started, but first a comment. If you can, please download the .tgz file and host it on your own server. It’ll be faster for you (and cheaper for me in bandwidth costs). And then replace the obvious text below

In the Commands box paste the following:

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20;
do
sleep 5
cd /tmp
/usr/bin/wget http://www.YOURWEBSERVER.com/PATH/TO/wrtbwlog_cust_exp.tgz
/bin/tar -xzf wrtbwlog_cust_exp.tgz
rm wrtbwlog_cust_exp.tgz
cd bwlog
( ./start.sh & ) &
done

(source)

Click “Save Startup”
Reboot your router, and check http://192.168.1.1:8000/traffic.cgi and hopefully smile. You’re all set!

If you want to take the extra steps to save your traffic logs across reboots you’ll need to look into setting up an FTP backup. Unfortunately with the latest versions of DD-WRT necessary components (ftpput) are missing and this isn’t possible yet. But when it’s fixed, you can check WRTbwlog’s page for more info on this and the rest of WRTbwlog’s features and settings.

Forum discussions: 1 2

Tagged: , ,


Comments