and_woox Posted January 8, 2008 Report 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 Quote Link to comment Share on other sites More sharing options...
paul Posted January 8, 2008 Report 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"; } Quote Link to comment Share on other sites More sharing options...
and_woox Posted January 10, 2008 Author Report Share Posted January 10, 2008 Thanks for the reply. Could you walk me over your script? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.