Bandwidth Usage Report
-
- Novice
- Posts: 15
- Joined: Wed Jul 21, 2010 1:02 pm
Bandwidth Usage Report
is it possible to have a monthly bandwidth usage report using routertech (how much GB/MB used), i tried darkstat but it does not show the total downloads/uploads
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Bandwidth Usage Report
From the web interface - IPAccount
From a telnet/ssh session - showbandwidth.sh
From a telnet/ssh session - showbandwidth.sh
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
-
- Novice
- Posts: 15
- Joined: Wed Jul 21, 2010 1:02 pm
Re: Bandwidth Usage Report
Is it possible to implement some type of quota system using IP Acount option, like disable internet when a particular amount of data has been downloaded,my modem is shared between different computers and have a 50GB monthly limit from the ISP
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Bandwidth Usage Report
Code: Select all
bandwidth.sh --help
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
-
- Novice
- Posts: 15
- Joined: Wed Jul 21, 2010 1:02 pm
Re: Bandwidth Usage Report
will it reset if the router is rebooted
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Bandwidth Usage Report
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
-
- Novice
- Posts: 15
- Joined: Wed Jul 21, 2010 1:02 pm
Re: Bandwidth Usage Report
But the problem is will it be able to remember the previous amount downloaded, like for example what if 10gb was downloaded before the router got restarted won't autoexec.sh set it again to the initial value..10gb would be forgotten
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Bandwidth Usage Report
No.keyboardcowboy wrote:But the problem is will it be able to remember the previous amount downloaded
Yep. If you want persistent data, you would have to write a script to do what you want, and you would need a writeable partition (e.g., minix or smbfs) to store the data.keyboardcowboy wrote: like for example what if 10gb was downloaded before the router got restarted won't autoexec.sh set it again to the initial value..10gb would be forgotten
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
Re: Bandwidth Usage Report
Here is my latest stab at tracking usage.
This goes into /nvram/mac_watch.sh
The tail command keeps the partition from overfilling. I actually store 5000 lines. I have a 704kB minix partition (/nvram) in my GT701.
This goes into /nvram/startup.sh
Be sure to set the script flags to executable. I used WinSCP. The script copy runs in ram (/var/tmp) so it can flush the nvram data. IP/mac and usage totals are logged once a day at 1:30am.
The netshaper command slows down an offending user to 5kB/sec. Their MAC and IP must first be allocated as a Lan Client in the web gui.
This goes into /nvram/mac_watch.sh
Code: Select all
echo `date`>>/nvram/mac_log.txt
cat /var/tmp/landhcps0.leases >> /nvram/mac_log.txt
grep -v 'bytes_src = 0' /proc/net/ipt_account/mynetwork >> /nvram/mac_log.txt
echo "">>/nvram/mac_log.txt
tail /nvram/mac_log.txt -n 500 >/nvram/mac_log_tmp.txt
cp /nvram/mac_log_tmp.txt /nvram/mac_log.txt
rm /nvram/mac_log_tmp.txt
flush
This goes into /nvram/startup.sh
Code: Select all
cp /nvram/mac_watch.sh /var/tmp/mac_watch.sh
write_crontab.sh '30' '1' '*' '*' '*' '/var/tmp/mac_watch.sh'
netshaper -d 192.168.1.201/24 5000
The netshaper command slows down an offending user to 5kB/sec. Their MAC and IP must first be allocated as a Lan Client in the web gui.
Any fool can make things complicated. It takes a genius to make things simple. - Einstein Jobs
Re: Bandwidth Usage Report
This makes the report a little easier to read. It uses showbandwidth.sh .
Code: Select all
echo `date`>>/nvram/mac_log.txt
cat /var/tmp/landhcps0.leases >> /nvram/mac_log.txt
showbandwidth.sh >> /nvram/mac_log.txt
echo "">>/nvram/mac_log.txt
tail /nvram/mac_log.txt -n 500 >/nvram/mac_log_tmp.txt
cp /nvram/mac_log_tmp.txt /nvram/mac_log.txt
rm /nvram/mac_log_tmp.txt
flush
Any fool can make things complicated. It takes a genius to make things simple. - Einstein Jobs
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Bandwidth Usage Report
This is very good
FYI - what is reported for 192.168.1.0 is the sum of the total bandwidth usage of the router's network (i.e., it is not attributable to any single client). So if you are on a metered ISP connection, that would be useful information to see whether you will get into trouble with your ISP!
Another thing - for this to work in respect of throttling the bandwidth of an errant user, that user must have a fixed IP - else he could bypass your actions by simply changing his IP address (alternatively, you might want to save the MAC address of the errant user, and so you will be able to tell if he changes his IP address).
FYI - what is reported for 192.168.1.0 is the sum of the total bandwidth usage of the router's network (i.e., it is not attributable to any single client). So if you are on a metered ISP connection, that would be useful information to see whether you will get into trouble with your ISP!
Another thing - for this to work in respect of throttling the bandwidth of an errant user, that user must have a fixed IP - else he could bypass your actions by simply changing his IP address (alternatively, you might want to save the MAC address of the errant user, and so you will be able to tell if he changes his IP address).
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
Re: Bandwidth Usage Report
Here is a re-write of my Bandwidth and Mac address logger. It is nicer to the nvram and easier on ram usage. The sleep line is needed to allow the cp to finish before the flush is forced.
The initializer still goes into /nvram/startup.sh
The end result is found in /nvram/mac_log.txt . I saw an average of about 60 bytes used per line, 2 lines per user. 100 days might use about 200 lines or 12kB of nvram per user.
Note that after loading these scripts into /nvram/mac_watch.sh you MUST issue flush /nvram or your script will get lost on reboot.
Code: Select all
echo "">/var/tmp/mac_log.txt
tail /nvram/mac_log.txt -n 600 >/var/tmp/mac_log.txt
echo `date`>>/var/tmp/mac_log.txt
cat /var/tmp/landhcps0.leases >> /var/tmp/mac_log.txt
showbandwidth.sh >> /var/tmp/mac_log.txt
echo "">>/var/tmp/mac_log.txt
cp /var/tmp/mac_log.txt /nvram/mac_log.txt
sleep 5
rm /var/tmp/mac_log.txt
flush /nvram
Code: Select all
cp /nvram/mac_watch.sh /var/tmp/mac_watch.sh
write_crontab.sh '30' '1' '*' '*' '*' '/var/tmp/mac_watch.sh'
Note that after loading these scripts into /nvram/mac_watch.sh you MUST issue flush /nvram or your script will get lost on reboot.
Any fool can make things complicated. It takes a genius to make things simple. - Einstein Jobs
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Bandwidth Usage Report
Looks good. There are two points though - first, the "sleep" line is not needed before calling "flush" - the script is executed sequentially and "cp" would have finished before the "flush" line is reached; secondly, the parameter supplied to "flush" is superfluous.
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.