bandwidth monitoring

Support section for FREESCO v0.3.x

bandwidth monitoring

Postby syscon456 » Sat Jun 18, 2011 2:01 am

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.

#syscon
User avatar
syscon456
Junior Member
 
Posts: 45
Joined: Sat Feb 12, 2005 9:35 pm

Re: bandwidth monitoring

Postby dingetje » Sat Jun 18, 2011 4:20 am

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.

http://robert.cheramy.net/ipfm/ in combination with http://scripfm.sourceforge.net/ 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.

HTH
GreetZ
http://dingetje.homeip.net

"Software is like sex: it's better when it's free." - LINUS TORVALDS
User avatar
dingetje
FREESCO GURU !!
 
Posts: 1004
Joined: Wed Nov 14, 2001 12:13 pm
Location: The Netherlands

Re: bandwidth monitoring

Postby Lightning » Sat Jun 18, 2011 10:31 am

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 0.0.0.0 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.
If you are afraid that you might make a mistake. The chances are high that you will never learn anything.
User avatar
Lightning
FREESCO GOD !!
 
Posts: 3052
Joined: Wed Nov 14, 2001 6:50 am
Location: Oregon, USA

Re: bandwidth monitoring

Postby syscon456 » Sat Jun 18, 2011 4:11 pm

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" :-)
User avatar
syscon456
Junior Member
 
Posts: 45
Joined: Sat Feb 12, 2005 9:35 pm

Re: bandwidth monitoring

Postby Lightning » Sat Jun 18, 2011 7:11 pm

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
#!/bin/sh

NAME=`basename $0`

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

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"
                fi
                sleep 7200
        fi
done

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
$star)
    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
If you are afraid that you might make a mistake. The chances are high that you will never learn anything.
User avatar
Lightning
FREESCO GOD !!
 
Posts: 3052
Joined: Wed Nov 14, 2001 6:50 am
Location: Oregon, USA


Return to FREESCO Support for v0.3.x

Who is online

Users browsing this forum: No registered users and 1 guest

cron