11

I'm looking for a good way to get the current total bandwidth usage on a linux machine. I’ve tried iftop, nethogs, but they don’t show real bandwidth usage compared to system monitor; they don’t suit the needs of my project. I want a command which I execute and it returns the current usage for upload and download and nothing else.

I would like also to do it with native Linux tools without installing anything. In fact I’m making a monitoring application, and I want it to be able to monitor computers without the need to install something in each computer the user wants to monitor, that would be great!

4

Use iptraf - http://www.linuxcommand.org/man_pages/iptraf8.html

It's an ncurses based commandline utility which is able to give you statistics on all interfaces on the machine - including bandwidth usage.

1

There's a lot of tools you can use: nload, bmon, iftop, vnstat, ifstat... and if you want to just get a specific part of their output (for example, upload and download), I'm pretty sure that you can grep/cut/awk the output to make it work for you.

18 commands to monitor network bandwidth on Linux server

  • bmon worked for me in Ubuntu, giving me the present TX and RX of every interface, and a simple graph of the last 60 seconds. – Leopoldo Sanczyk Oct 3 '17 at 4:06
  • not built-in tool – Nicolas Thery Apr 18 at 9:45
1

sysstat collects network stast as well. If you do a "man sar" you will see all the resources you can keep historical data for.

Set it up by putting in cron the command "/usr/lib/sa/sa1" (or /usr/lib64/sa/sa1) and have it run each time you want a data point (e.g. every 5 minutes)

Then you can use "sar" to view your data. Default is today. You can also view historical data for up to 30 days. You can also archive your data off so you can keep it forever (each day's data is about 8mb).

For networking, you would use "sar -n"

Wonderful tool :)

An example:

 testlinux:~ # sar -n DEV | head -10
 Linux 2.6.16.60-0.21-default (pCITFileSvr01)    11/07/10

 00:00:01        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
 00:05:01           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 00:05:01         eth0      9.95      0.12      1.42      0.02      0.00      0.00      0.00
 00:10:01           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 00:10:01         eth0     10.20      0.04      1.44      0.00      0.00      0.00      0.00
 00:15:01           lo      0.00      0.00      0.00      0.00      0.00       0.00      0.00
 00:15:01         eth0     10.32      0.12      1.50      0.02      0.00      0.00      0.00
 00:20:01           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 testlinux:~ #

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.