Bandwidth Monitoring

Andrey Simonenko simon at comsys.ntu-kpi.kiev.ua
Wed Jul 16 04:59:50 PDT 2003


On Tue, 15 Jul 2003 13:32:26 +0000 (UTC) in lucky.freebsd.questions, David Loszewski wrote:

> Say I have a 20GB Data Transfer limit per month, is there a way to
> monitor how much of that limit I've used up? MRTG doesn't seem to do the
> job.
> 

sysutils/ipa from the Ports Collection can do it.

I even can try to write ipa.conf (but didn't test it),
let 100, 200, 300 be IP Firewall rules which counts ingoing
traffic from ISP:

rule isp-ingoing {
    ipfw = 100 200 300
    info = Ingoing traffic from ISP
    maxchunk = 1G
# This allows to monitor traffic before limit 20G.
#    limit 10G {
#        byte_limit = 10G
#	zero_time = +M
#	reach {
#	    exec = /bin/echo "10G reached" | /usr/bin/mail admin
#	}
#	expire {
#	    expire_time = 0s
#	}
#    }
#
# This is 20G/month limit.
    limit 20G {
        byte_limit = 20G
	zero_time = +M
	reach {
	    exec = /sbin/ipfw add 10 deny all from me to my-isp
	    exec = /bin/echo "20G reached" | /usr/bin/mail admin
	}
	expire {
	    expire_time = +M
	    exec = /sbin/ipfw del 10
	    exec = /bin/echo "20G reached limit expired" | /usr/bin/mail admin
	}
	startup {
	    if_limit_is_reached {
	        exec = /sbin/ipfw add 10 deny all from me to my-isp
	    }
	}
    }
}

I didn't test this config and it can contain errors!

More information in IPA manual pages (also available on
http://ipa-system.sourceforge.net/).


More information about the freebsd-questions mailing list