Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Apr 2004 16:36:25 -0400
From:      Chuck Swiger <cswiger@mac.com>
To:        Dragoncrest <dragoncrest@voyager.net>
Cc:        questions@freebsd.org
Subject:   Re: Bandwidth tracking/monitoring on Freebsd
Message-ID:  <40785AC9.5050305@mac.com>
In-Reply-To: <200404102020.i3AKKLfb007744@mail5.mx.voyager.net>
References:  <200404102020.i3AKKLfb007744@mail5.mx.voyager.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Dragoncrest wrote:
> Hi all.  Got a question.  I got a box on my network that I'd like to be
> able to track bandwidth usage on.  Just to see how much traffic is
> passing through it in a one month period and daily over a 24 hour
> period.  Is there some kind of application I can use to log total bytes
> sent and total bytes recieved?  I don't need to know specifically WHAT
> was sent, but rather HOW MUCH of it was sent.  [ ... ]

Try something like the following IPFW rules, replacing IIF with the name of 
the network interface you want to pay attention to:

add pipe 11 tcp from any to any in via IIF
add pipe 11 udp from any to any in via IIF
add pipe 11 ip from any to any in via IIF
pipe 11 config queue 60
add pipe 12 tcp from any to any out via IIF
add pipe 12 udp from any to any out via IIF
add pipe 12 ip from any to any out via IIF
pipe 12 config queue 60

The normal periodic processing ought to cause these stats to be reset daily. 
This really is the easiest way of accomplishing what you've asked for, but:

> What is the easiest way to do this short of setting up IPFW and doing a
> kernel compile and all that nasty stuff.  Any suggestions will be welcome.

...another approach would be to run 'netstat -s' on a daily basis, parse the 
output, and subtract values to obtain daily deltas.  You'd have to write 10-20 
lines of shell code using grep and awk, or use Python or Perl to do the task.

-- 
-Chuck



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40785AC9.5050305>