[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Controlling IP traffic (e.g. per month)



Hi

On Mon, Oct 28, 2002 at 10:32:30AM +0100, Dieter Heiliger wrote:
> Now I want to get more control over the traffic that was already used 
> since the beginning of each month. My ideal configuration would be to 
> get an email when e.g. 80% of the traffic included in the monthly fee 
> got used already. When a new month begins the counter has to be set to 
> zero again.
> 
> Is there an easy way to implement this?
Yeah. A simple shell script with the ability to detect 32bit counter
overflows should be enough.
ipchains and iptables (so, no matter whether you use 2.2 or 2.4 kernel)
have an own counter for each firewall rule. This counter can be abused(?)
for accounting.
ipchains -A INPUT -j RETURN for example will add such a counter in
/proc/net/ipfw_names iirc (only doing accounting with 2.4 at the moment).
So you can read the bytes of that file or even grep if you want. iptables
communication is somewhat more complicated, as you need to use sockets.

Anyway, the point is, a shell script with such a simple logic detection
should be pretty easy and fast to built, and adding an if clause with your
maximum traffic wouldn't be that hard either :)..

Of course, you can also wind that up and use a mysql database if you
want.. or you're bored ;)


MfG/Regards, Alexander

-- 
Alexander Reelsen   http://tretmine.org
ref@tretmine.org    GnuPG: pub 1024D/F0D7313C  sub 2048g/6AA2EDDB
                    7D44 F4E3 1993 FDDF 552E  7C88 EE9C CBD1 F0D7 313C



Reply to: