[Nottingham] Bandwidth Accounting

Roger Light roger at atchoo.org
Mon Apr 16 15:07:54 BST 2007


On 16/04/07, Penfold <penfoldq at penfoldq.co.uk> wrote:

> Does anyone have any ideas how I could implement my own bandwidth
> accounting, hopefully to locate the ports and traffic types that are
> eating my incoming bandwidth?

I keep track of bandwidth on a particular port using iptables and a
cron job that looks like:

STAMP=$(date +%s)
GGZIN=$(/sbin/iptables -L ggz-in -v -x | grep ACCEPT | awk '{print $1,$2}')
GGZOUT=$(/sbin/iptables -L ggz-out -v -x | grep ACCEPT | awk '{print $1,$2}')
/sbin/iptables -Z ggz-in
/sbin/iptables -Z ggz-out

echo "${STAMP} ${GGZIN}" >> /var/log/ggzd/ggzin.log
echo "${STAMP} ${GGZOUT}" >> /var/log/ggzd/ggzout.log

So read the chain counters and then zero them. ggz-in and ggz-out are
chains that have all the traffic in/out of the port sent to them and
all they do is accept.

Cheers,

Roger



More information about the Nottingham mailing list