![]() |
![]() |
|||||||||
|
|
|
|||||||||
|
|||||||
| Register | Blogs | Xbox Live | FAQ | Donate | Members List | Social Groups | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 |
|
Resident Nutter
Join Date: Jun 2007
Location: Yorkshire, England, UK
Posts: 3,666
Thanks: 382
Thanked 436 Times in 231 Posts
Blog Entries: 8
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
If your router is running the Tomato firmware you will probably be aware the router can log your bandwidth usage, the bandwidth log could be useful if you have a limit each month or just want to keep track of your internet usage.
In its default configuration the router will lose the logs when its powered down or re started, this guide will show you how to automatically backup the logs to a remote ftp server every 12 hours. Before you begin you will need some ftp space on a remote server, if you have some free webspace on your isp’s server this will be perfect. 1] First log on to your router then go to Administration > Scripts or http://192.168.1.1/admin-scripts.asp 2] In the shutdown box add: Code:
if [ ! -s /tmp/restore-rstats ] ; then {make sure any previous restore was successful, or we will overwrite the backup with nothing...}
/tmp/backup-rstats
fi
Code:
USER="FTP Username"
PASS="FTP Password"
PORT=21
SERVER="IP or Hostname of the FTP server"
RPATH="/rstats.tgz"
RPATH_DATE="/rstats\`date +%Y.%m.%d-%H.%M.%S\`.tgz"
LPATH="/tmp/rstats.tgz"
if [ ! -s /tmp/backup-rstats ] ; then
echo -e "#!/bin/sh\nkillall -1 rstats\nsleep 1\ntar -czf \"$LPATH\" /tmp/var/lib/misc/rstats-*\nftpput -u \"$USER\" -p \"$PASS\" -P $PORT $SERVER \"$RPATH\" \"$LPATH\"\nftpput -u \"$USER\" -p \"$PASS\" -P $PORT $SERVER \"$RPATH_DATE\" \"$LPATH\"\nrm \"$LPATH\"" > /tmp/backup-rstats
chmod 777 /tmp/backup-rstats
echo -e "#!/bin/sh\nservice rstats stop\nftpget -u \"$USER\" -p \"$PASS\" -P $PORT $SERVER \"$LPATH\" \"$RPATH\"" > /tmp/restore-rstats
echo -e "if [ \$? != 0 ] ; then\n logger RStats Restore Failed... will retry\n cru a rstats \"*/5 * * * * /tmp/restore-rstats\"\n return 1\nfi\ntar -xzf \"$LPATH\" -C /\nrm \"$LPATH\"\nservice rstats start\ncru a rstats \"1 */12 * * * /tmp/backup-rstats\"" >> /tmp/restore-rstats
echo -e "logger RStats Data Restored\nrm /tmp/restore-rstats" >> /tmp/restore-rstats
chmod 777 /tmp/restore-rstats
/tmp/restore-rstats
fi
Thats it, your good to go! You can test this works by surfing the net for a bit or downloading something, then use the shutdown button on the routers web interface. It should upload the bandwidth logs then download them again when the router re starts. (it can take a minute or two after the router loading up for the logs to appear again) I take no credit for creating the script used in this guide, I found it on a random website after spending a long while looking for a solution to backup the logs to a remote server.
__________________
![]() |
|
|
|
| Thanks from: |
|
|
|
|
|
|
|
|
#2 |
|
The Feature Man
Join Date: Aug 2008
Location: Bimble, KY
Posts: 1,526
Thanks: 130
Thanked 729 Times in 270 Posts
Blog Entries: 18
![]() ![]() ![]() ![]() ![]() ![]() ![]() Xbox Live Ranking: 11th
|
I was just working on doing this the other day. Nimrod was asking why was I even bothering and to just use some program. I couldn't find anything useful on the net. Though tonight I was searching on Google very hard for a good script and I was amazed at what site I finally was returned to...DIGIEX!!!
I'm glad you already have a guide for this.Quick qustion though, is there anyway to change it to back up sooner then every 12 hours? What if your router dies, electric dies, a tornado come through and you want that data to be preserved.I have a ftp server running on my PC at the moment InsaneNutter but do you think it would be better to back this data up to my webspace here? |
|
|
|
|
|
#3 |
|
Resident Nutter
Join Date: Jun 2007
Location: Yorkshire, England, UK
Posts: 3,666
Thanks: 382
Thanked 436 Times in 231 Posts
Blog Entries: 8
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I think it would be better to backup to a remote server such as your Digiex webspace. A dedicated server should be online 24/7, at some point your pc is not going to be on when your router wants to backup the bandwidth logs. (especially as you like installing new Windows 7 builds)
The advantage of doing the bandwidth monitoring with your router is that it will log the bandwidth used by every device on your network and not just a pc running an application to do so, this means the bandwidth used by the 360 and other games consoles will also be logged. To change when the logs are backed up I think you would find "1 */12 * * * /tmp/backup-rstats" and modify the 12 to 1 for example if you want the backup to run every hour. The script has been working perfectly for the last 1 and a half years now.
__________________
![]() |
|
|
|
|
|
#4 |
|
The Feature Man
Join Date: Aug 2008
Location: Bimble, KY
Posts: 1,526
Thanks: 130
Thanked 729 Times in 270 Posts
Blog Entries: 18
![]() ![]() ![]() ![]() ![]() ![]() ![]() Xbox Live Ranking: 11th
|
Finally got it working fully today. Of course this picture is mostly showing all your rstats since you sent me yours. Though its backing up once every hour to my user webspace here. which is behind a webpage so no one should be able to see it inless they access it via a ftp client which to my knowledge doesn't work without a user and pass.
Thanks for helping me today on MSN. I turned out leaving the shutdown code as it was and changing the wan up script a little to this. so it replaces the old file on the server instead on creating a new one each time. Code:
USER="PUT FTP USERNAME HERE"
PASS="PUT FTP PASSWORD HERE"
PORT=PUT FTP PORT HERE
SERVER="PUT FTP HOST HERE IP OR HOSTNAME"
RPATH="/Router/rstats.tgz" WHERE IT SAYS ROUTER YOU CAN CHANGE THAT TO BE ANYTHING. LETS SAY IF IT SAYS "/ROUTER/RSTATS.TGZ" THEN IT TELLS THIS SCRIPT TO MAKE THE FILE RSTATS.TGZ IN THE REMOTE PATH /ROUTER WHICH IS A FOLDER I HAVE CREATED ON MY WEBSPACE. (DELETE THIS IF YOU INTEND TO USE IT)
LPATH="/tmp/rstats.tgz"
if [ ! -s /tmp/backup-rstats ] ; then
echo -e "#!/bin/sh\nkillall -1 rstats\nsleep 1\ntar -czf \"$LPATH\" /tmp/var/lib/misc/rstats-*\nftpput -u \"$USER\" -p \"$PASS\" -P $PORT $SERVER \"$RPATH\" \"$LPATH\"\nftpput -u \"$USER\" -p \"$PASS\" -P $PORT $SERVER \"$LPATH\"\nrm \"$LPATH\"" > /tmp/backup-rstats
chmod 777 /tmp/backup-rstats
echo -e "#!/bin/sh\nservice rstats stop\nftpget -u \"$USER\" -p \"$PASS\" -P $PORT $SERVER \"$LPATH\" \"$RPATH\"" > /tmp/restore-rstats
echo -e "if [ \$? != 0 ] ; then\n logger RStats Restore Failed... will retry\n cru a rstats \"*/5 * * * * /tmp/restore-rstats\"\n return 1\nfi\ntar -xzf \"$LPATH\" -C /\nrm \"$LPATH\"\nservice rstats start\ncru a rstats \"1 */1 * * * /tmp/backup-rstats\"" >> /tmp/restore-rstats
echo -e "logger RStats Data Restored\nrm /tmp/restore-rstats" >> /tmp/restore-rstats
chmod 777 /tmp/restore-rstats
/tmp/restore-rstats
fi
|
|
|
|
|
|
#5 |
|
Resident Nutter
Join Date: Jun 2007
Location: Yorkshire, England, UK
Posts: 3,666
Thanks: 382
Thanked 436 Times in 231 Posts
Blog Entries: 8
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Glad you got it working
![]() I think the idea of having it creating a separate file is so if an upload was to fail or the file got corrupted you could just restore another backup and not lose everything. As the files are only a few kb i left it be. No idea who created the script but a big thanks to them!
__________________
![]() |
|
|
|
|
|
#6 |
|
Stayed to Post
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Hi,
I found this thread when Googling to find a way to backup my bandwidth stats on my Tomato (v1.25 running on WRT54GL v1.1). I put the appropriate scripts both in Shutdown and WAN up but when I reboot my router (even multiple times) it won't do anything. When I navigate to Daily and Weekly stats pages, I get empty tables and the Monthly page gives me a "The rstats program is not responding or is busy. Try reloading after a few seconds." error. I've made sure all the FTP info was correct and tested it with Filezilla. Also, no file gets uploaded to the ftp I would like to know if someone has a clue as to what the problem could be.Thank you very much in advance! Edit: Nevermind, I uploaded the stats file I had backed up from the router interface to the FTP and renamed it rstats.tgz and it seems to have done the trick!
|
|
|
|
|
|
|
|
![]() |
| Bookmarks |
| Tags |
| backup, firmware, ftp, logs, polarcloud, rstats, tomato |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Take Back Your Bandwidth | LiquidBlack | Networking | 14 | 29-10-09 13:17 |
| Google Moves to Increase User Privacy - IP Logs to be cut from 18 to 9 months | Nimrod | Front Page News | 0 | 10-09-08 12:04 |