DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

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

02.01.2011
| 4173 views |
  • submit to reddit
        // 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