Page 1 of 1

bandwidth monitoring

PostPosted: Sat Jun 18, 2011 2:01 am
by syscon456
Is there an application / setting to configure bandwidth monitoring in freesco?
I would allow user to watch various movies over the Internet but my bandwidth is limited to 100Gb/month as once I read 80Gb I would like to cut off or limit this service.


Re: bandwidth monitoring

PostPosted: Sat Jun 18, 2011 4:20 am
by dingetje
There are several bandwidth monitoring packages available, but none to automatically cut off or limit bandwidth to certain users after a certain amount has been reached. in combination with is a nice tool to monitor bandwidth usage and create daily, monthly, yearly and global usage reports. Due to NAT it's not possible to see the uploads per user (these are all combined in one number on the outside IP address of your FREESCO) but you can see the downloads per IP address.

For ipfm an add-on package is available on FREESCOSoft. For scr_ipfm you'll need a PHP enabled web server like my Apache add-on package.


Re: bandwidth monitoring

PostPosted: Sat Jun 18, 2011 10:31 am
by Lightning
It should be possible to do what you are asking in the 04x series using the /var/netmon.log file and the hosts package along with some scripting.

The netmon log shows the total input and output of all interfaces. You then could parse that file and check the usage. Once the usage reaches your control bandwidth you could then have your scripting block those URL's using a DNS entry of and prevent users from accessing any specific site.

The complication would be to reboot your machine at midnight on the first day of each month to make the netmon.log reset to zero and to keep the log numbers if the system is rebooted any time during the month. However those issues can be worked around with scripting to prevent anything special from happening. The one thing that would be absolutely critical is that your router be on a UPS and never shut down improperly.

Another possible way to do this is if your ISP is monitoring your bandwidth. Create a script that checks there web page and parses the bandwidth usage from it and then block the URL's accordingly.

Re: bandwidth monitoring

PostPosted: Sat Jun 18, 2011 4:11 pm
by syscon456
Thanks folks, I'll look into "ipfm", though ifconfig will give me the same information, I think.

All I need is what was received total on eth0 RX (interface that is connected to ISP),
Though, it would be nice if I could get an email if certain limit was reached on RX.
I could advise users to stop watching the "movies" :-)

Re: bandwidth monitoring

PostPosted: Sat Jun 18, 2011 7:11 pm
by Lightning
Here is a script that will do what you are asking in the 04x series. All that is required is to leave the netmon logger running and configure the built in email client to send emails to you.
Code: Select all

NAME=`basename $0`

for i in `pidof $NAME`
do      [ $i = $$ ] && continue

while :
do      set -- `cat /var/netmon.log | sed -n '/eth0/P'`
        if [ "`echo "$2" | sed -n '/G/P'`" ]
        then    BANDWIDTH=`echo "$2" | sed 's/G//;s/\..*//'`
                if [ $BANDWIDTH -ge 1 ]
                then    email -other "${BANDWIDTH}G" "cat /var/netmon.log"
                sleep 7200

Just put this script in the /boot/bin directory and name it anything you want. Then put a line in the rc_user $star) section that forks it into the background and the script will email you every two hours with an update to your bandwidth usage.

edit /rc/rc_user
Code: Select all
    fork script-name

Reboot your router with a crond job at midnight on the first day of the month

crontab -e
Code: Select all
0 0 1 * * reboot