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.
You can parse the output of
ifconfig
I couldn't get the parse ifconfig script to work for me on an AMI so got this to work measuring received traffic averaged over 10 seconds
Sorry, it's ever so cheap and nasty but it worked!
I wrote this dumb script a long time ago, it depends on nothing but Perl and Linux≥2.6:
It just reads from
/sys/class/net/$dev/statistics
every second, and prints out the current numbers and the average rate of change:You could parse /proc/net/dev.
I got another quick'n'dirty bash script for that:
It's considering that
sleep 1
will actually last exactly one second, which is not true, but good enough for a rough bandwidth assessment.Thanks to @ephemient for the
/sys/class/net/<interface>
! :)I like
iptraf
but you probably have to install it and it seems to not being maintained actively anymore.