Over a million developers have joined DZone.

Bandwidth Usage By MAC Address For Linksys WRT54G Router Running DDWrt;

·
// Chuck the following in the extra crontab.
// The first line re-downloads the code if necessary (router restarted)
// The second line clears the usage database on the 15th of the month (that's when our billing cycle starts. Adjust accordingly) - and uploads a record of the usage for the billing cycle.
// The last four lines backup & restore (if necessary) the usage & address-mapping files to an FTP server. Will need to replace with actual account details. 
// Our ISP doesn't distinguish between peak/off peak. 


* * * * * root [ ! -f /tmp/wrtbwmon ] && wget http://wrtbwmon.googlecode.com/files/wrtbwmon -O /tmp/wrtbwmon && chmod +x /tmp/wrtbwmon
59 23 14 * * root [ -f /tmp/usage.db ] && rm /tmp/usage.db && touch /tmp/usage.db && FILENAME="usage-`date -I`.htm" && cd /www/user && ftpput -u username -p password ftp.vosi.biz $FILENAME usage.htm
* * * * * root /tmp/wrtbwmon setup br0
* * * * * root /tmp/wrtbwmon update /tmp/usage.db peak
43 */2 * * * root [ -f /tmp/nic_users.txt ] && cat /tmp/nic_users.txt > /tmp/nic_users_tmp; cat /tmp/dnsmasq.leases | awk '{print toupper($2) "," , $4, "(" $3 ")" }' >> /tmp/nic_users_tmp
44 */2 * * * root cat /tmp/nic_users_tmp | sort | uniq -w17 > /tmp/nic_users.txt && rm /tmp/nic_users_tmp
*/2 * * * * root /tmp/wrtbwmon publish /tmp/usage.db /tmp/www/usage.htm /tmp/nic_users.txt
15 * * * * root cd /tmp && ftpput -u username -p password ftp.vosi.biz usage.db usage.db
15 * * * * root cd /tmp && ftpput -u username -p password ftp.vosi.biz nic_users.txt nic_users.txt
* * * * * root [ ! -f /tmp/usage.db ] && wget ftp://username:password@ftp.vosi.biz/usage.db -O /tmp/usage.db
* * * * * root [ ! -f /tmp/nic_users.txt ] && wget ftp://username:password@ftp.vosi.biz/nic_users.txt -O /tmp/nic_users.txt
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}