Per-IP Bandwidth Monitoring

Mark Johnston markj at freebsd.org
Sun Jun 9 05:09:24 UTC 2013


On Sat, Jun 08, 2013 at 10:32:11PM -0400, Kenta Suzumoto wrote:
> Hello. I'm running a FreeBSD machine with 5 IP addresses, each of them attached to a specific jail. I'm wondering if there is an easy way to monitor the bandwidth usage of each of them individually. Upon googling, I ran into a lot of suggestions like bandwidthd. I gave it a try and it seemed very broken and basically didn't work at all. I'm basically looking for a "vnstat that works per IP instead of per interface" kind of thing. jnettop wasn't what I was looking for. It doesn't have to make pretty graphs(but that's nice too), just human-readable text is fine. Anyone have a recommendation?

I'm not clear on what exactly you're after, but it seems like you should
be able to get the info you need using the DTrace ip provider. This
provider isn't available in FreeBSD yet, but a patch for it is at [1].
To use it, you'll need to recompile the kernel with my changes and then
install the ip.d file from the patch to /usr/lib/dtrace.

Once that's done, you can try the example script at [2] on your jail
host. It just tracks the number of sent and received bytes per local IP
address, and prints the totals every second. That's just an example
presentation though - the point is that collecting this kind of info is
pretty trivial with DTrace. The downside is that such scripts may hurt
your throughput since they cause the kernel to execute some extra code
for every packet sent and received through the IP stack. The actual
performance hit will depend on the script.

-Mark

[1] http://people.freebsd.org/~markj/patches/providers/ip-provider.diff

[2] http://people.freebsd.org/~markj/monitor.d


More information about the freebsd-net mailing list