and_woox Posted January 8, 2008 Share Posted January 8, 2008 Please i'm working on an iptables script where i can grant a certain amount of monthly traffic, for example grant 8g to one client per month and if he passes that amount his connection becomes unavailable. I'm trying to find a command that serves as a network traffic counter. What should i be looking for? Thanks Link to comment Share on other sites More sharing options...
paul Posted January 8, 2008 Share Posted January 8, 2008 something like this: #!/usr/bin/perl my @eths = qw ( eth0 eth1 eth2 eth3 eth4); for my $eth(@eths) { $count = 0; my $rxbytes = 0; my $txbytes = 0; for (`/sbin/ip -s link show $eth`) { chomp; $count++; if ($count == 4) { ($rxbytes, $rest) = split; } elsif ($count == 6) { ($txbytes, $rest) = split; } } print "$eth $rxbytes $txbytes\n"; } Link to comment Share on other sites More sharing options...
and_woox Posted January 10, 2008 Author Share Posted January 10, 2008 Thanks for the reply. Could you walk me over your script? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now