how to see each connection use of bandwidth?
There are many tools available, although you will have to install a network monitoring system to get per-process bandwidth information.
In order of setup ease:
A simple package that does not require a lot of setup is iftop. This will show you bandwidth per process. This is probably what you want, if you want a simple real-time solution.
- To just get per-interface bandwidth,
bwm-ng
is a small package that shows you real-time usage per interface. netstat
will list your open connections, and should already be present on most systems- ntop is a very useful tool for system monitoring, that can also monitor per-process TCP connections, IF you install a kernel module to support network monitoring.
- Gacti, nagios, ntop and ganglia are several more heavy weight systems that can do network monitoring per host/system/service/protocol/etc depending on setup for one server to an entire enterprise network. See mediawiki server monitoring for a real-life example of
ganglia
in action.
real time usage continuous polling in 5 seconds interval using native netstat
netstat --interfaces=eth0 -c 5
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 601670041 0 0 0 290653338 0 0 0 BMRU
eth0 1500 0 601796657 0 0 0 290721761 0 0 0 BMRU
using awk you can just watch a particular field that you are interested, below example you'll just watch for 2 RX and TX columns show how many packets have been received or transmitted error-free (RX-OK/TX-OK)
netstat --interfaces=eth0 -c 5 |awk '{ print $4 "\t" $8 }'
RX-OK TX-OK
605142559 292429624
605142595 292429661
There's a simple package, called nethogs, that shows the bandwidth used by individual processes and sorts the list putting the most intensive processes on top.
# Ubuntu or Debian
$ sudo apt install nethogs
# Fedora or CentOS
$ sudo yum install nethogs -y