You get a bonus - 1 coin for daily activity. Now you have 1 coin

FreeBSD - monitoring the load on several network cards at once

Practice



I found myself needing to assess the load on the gateway's network interface on a FreeBSD box. This gateway ties together a bunch of offices at once (some over fiber, some via VPN, etc.), and as a result there's a bunch of virtual interfaces (some from VPN, some VLANs).

My interest was, first and foremost, in the network card facing into the corporate network - how many megabits per second it's consuming. Besides regular, untagged traffic, a certain number of VLANs also travel over it.

Each VLAN is a separate network interface. I've already covered how to look at detailed load statistics for a single interface. However, the method linked there has one significant drawback for our situation - you can only view the load of a single network card. That is, if we have, say, network interface re0 with another 50 VLANs riding on it, we'll be able to see either only the untagged traffic, or the tagged traffic for one selected VLAN. That's fine when you need to assess the load on an individual line, especially if you need to see who's consuming and sending how much. But it's absolutely no good at all if you need to see the total load or take in all interfaces at a glance.


So, iftop won't help us here - it can only look at a single interface, and we need to see all of them at once. The following command on FreeBSD will show us what we want:

sudo systat -ifstat

It will look roughly like this (all interfaces here are shown purely as an example):
/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10
Load Average |


Interface Traffic Peak Total
tun1 in 0.017 KB/s 0.104 KB/s 3.716 MB
out 0.009 KB/s 0.044 KB/s 50.966 MB

tun0 in 0.000 KB/s 0.085 KB/s 3.162 MB
out 0.000 KB/s 0.083 KB/s 68.658 MB

vlan14 in 1.691 KB/s 2.159 KB/s 38.527 GB
out 1.379 KB/s 4.052 KB/s 3.443 GB

vlan13 in 407.594 KB/s 554.035 KB/s 256.886 GB
out 20.962 KB/s 70.913 KB/s 17.667 GB

vlan12 in 2.175 KB/s 4.602 KB/s 143.265 GB
out 40.762 KB/s 45.071 KB/s 14.220 GB

vlan11 in 0.000 KB/s 0.000 KB/s 308.193 KB
out 0.000 KB/s 0.000 KB/s 328.414 KB

vlan10 in 160.428 KB/s 405.285 KB/s 49.788 GB
out 28.437 KB/s 82.483 KB/s 14.636 GB

lo0 in 0.000 KB/s 0.000 KB/s 7.055 KB
out 0.000 KB/s 0.000 KB/s 7.055 KB

rl0 in 515.176 KB/s 1.145 MB/s 55.225 GB
out 74.875 KB/s 212.162 KB/s 14.154 GB

re0 in 2.602 MB/s 2.912 MB/s 1.332 TB
out 3.059 MB/s 4.018 MB/s 1.371 TB

It's worth noting here that we can see the load per each virtual interface separately, but the physical interfaces show it as a total.

That is, if we run (as in the example above) iftop -i re0, we'll see the load of only the untagged traffic. But if we run systat - then on the re0, rl0 lines we'll see all the traffic passing through these physical interfaces. In our case (though it's not shown here): through rl0, besides itself, tun0 and tun1 are also counted, and through re0 - all the vlanXX.


PS. By default it measures not in mega/kilobits, but in Mega/KiloBytes! This is worth keeping in mind! To change it: press ":" and type:
:scale mbit
that's for megabits. For kilobits - accordingly. If you just press Enter - it will show you which scales are available.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Computer networks"

Terms: Computer networks