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

What to use to view (monitor) the load on a network card (interface) in Linux or FreeBSD

Practice



For instant monitoring of network load, a utility called "iftop" is well suited. It can show a per-interface graph for the last 3 seconds in real time (i.e. every 3 seconds) - who is connecting where and how much they are loading the network channel.


Installation

FreeBSD:

Install from ports.

$ cd /usr/ports/net-mgmt/iftop
$ sudo make install clean


Linux Debian/Ubuntu:

$ sudo aptitude install iftop


Linux CentOS/Redhat:

$ sudo yum install iftop


Usage

The iftop utility displays the current network load right in the console, without using a web interface or X-Windows. What's very useful is that you can see right now, right here, what the network load is and who is generating it.

When launching it, I highly recommend specifying the interface to collect information from using the -i flag, otherwise the utility will attach itself to the first interface it finds and you may get data that is not at all what you expect. Of course, if there's only one network interface in the system, there's no need to bother.

Also, if you don't want the utility to resolve the DNS name and service name for each IP address and port, respectively - specify the -n flag.

$ sudo iftop -i eth0 -n

And here's roughly what the output will look like:

Listening on eth0 5Kb 25.0Kb 37.5Kb 50.0Kb 62.5Kb
└───────────────┴───────────────┴───────────────┴───────────────┴───────────────
80.78.116.141 => 188.226.25.103 2.72Kb 2.72Kb 2.72Kb
<= 320b 320b 320b
















────────────────────────────────────────────────────────────────────────────────
TX: cumm: 696B peak: 2.72Kb rates: 2.72Kb 2.72Kb 2.72Kb
RX: 80B 320b 320b 320b 320b
TOTAL: 776B 3.03Kb 3.03Kb 3.03Kb 3.03Kb

Help can be obtained by pressing the "H" key inside the program itself.

At the bottom we see summary information:
  • TX - the amount of information transmitted through the interface
  • RX - the amount of information received
  • TOTAL - the sum of TX and RX

and columns:
  • cumm - cumulative information - how many bytes have passed during the time the utility has been running (i.e. since you launched it) (counter in bytes/kilobytes, etc.)
  • peak - the peak recorded load over the last few minutes (in bits/kilobits, etc.)
  • rates - three values of the current load, in bits/kilobits, etc. Why 3 values? Because the screen updates once every 3 seconds, while the utility takes a measurement every second - so it shows all 3 measurements every 3 seconds.

Well, that's about it. The utility is useful precisely as a means of showing "here and now", in text form (i.e. without any hassle), information about the network usage of the interface.

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