views:

4117

answers:

8

Tools such as MRTG provide network throughput / bandwidth graphs for the current network utilisation on specific interfaces, such as eth0. How can I return that information at the command line on Linux/UNIX?

Preferably this would be without installing anything other than what is available on the system as standard.

+2  A: 

I like iptraf but you probably have to install it and it seems to not being maintained actively anymore.

Johannes Weiß
+1  A: 

You can parse the output of ifconfig

Mehrdad Afshari
+4  A: 

You could parse /proc/net/dev.

codelogic
/proc does not exist on every UNIX.
Mehrdad Afshari
True, just assumed due to the Linux tag, that OP was only interested in Linux.
codelogic
+3  A: 
ephemient
+2  A: 

"iftop does for network usage what top(1) does for CPU usage" -- http://www.ex-parrot.com/~pdw/iftop/

I don't know how "standard" iftop is, but I was able to install it with "yum install iftop" on Fedora.

Philip Durbin
A: 

I find dstat to be quite good. Has to be installed though. Gives you way more information than you need. Netstat will give you packet rates but not bandwith also. netstat -s

+2  A: 

Besides iftop and iptraf, also check: bwm-ng cbm

miguel
A: 

Got sar? Likely yes if youre using RHEL/CentOS.

No need for priv, dorky binaries, hacky scripts, libpcap, etc. Win.

$ sar -n DEV 1 3
Linux 2.6.18-194.el5 (localhost.localdomain)    10/27/2010

02:40:56 PM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s
02:40:57 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02:40:57 PM      eth0  10700.00   1705.05 15860765.66 124250.51      0.00      0.00      0.00
02:40:57 PM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

02:40:57 PM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s
02:40:58 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02:40:58 PM      eth0   8051.00   1438.00 11849206.00 105356.00      0.00      0.00      0.00
02:40:58 PM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

02:40:58 PM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s
02:40:59 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02:40:59 PM      eth0   6093.00   1135.00 8970988.00  82942.00      0.00      0.00      0.00
02:40:59 PM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth0   8273.24   1425.08 12214833.44 104115.72      0.00      0.00      0.00
Average:         eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00
filler