0

Is there a command line program for Linux that will tell me how much is currently being uploaded and downloaded (ie the network "speed").

I want a program that runs, tells me the traffic, then stops. All I've been able to find are live updating applications. (I want to be able to use it similarly to, for example, free, and not, for example, top)

4 Answers 4

1

iptable rules can be used to count the packets coming in and going out. I have used this capability to troubleshoot network/firewall issue and not for the bandwidth monitoring.

However, iptables does provide options to

create new custom chains
create IP based rules
view counters
reset counters

So using iptable options, a script can do the job for you. An example is given on linux.com on how to use these iptable options.

1

You're looking for netstat. A few common switches I use:

  • -n , which tells it not to resolve names and protocols.
  • -a , which tells it to also report ports that are listening.
  • -t , which tells it to just report TCP ports; there's a lot of other stuff reported by netstat
4
  • If I run netstat -t, would the download speed be the sum of the Recv-Q column, and the upload speed be the sum of the Send-Q column? Oct 25, 2009 at 17:48
  • @Jeffrey Aylesworth: i think netstat falls more under the 'top' category than the 'free' category. Oct 25, 2009 at 18:14
  • @quack: not at all. Are you confusing it with nettop maybe?
    – innaM
    Oct 25, 2009 at 18:26
  • The Recv-Q column is the amount of data that the host has received, but hasn't been processed by the program yet. The Send-Q column shows how much data the program has asked the system to send, but hasn't been sent yet(usually due to bandwidth limitations, but sometimes due to having the command sent at exactly the right time).
    – Kevin M
    Oct 26, 2009 at 15:58
1

Give it a try with "vnstat". get it from sourceforge or freshmeat.Wonderful commandline utility to solve your owes.

0

Maybe a bit too much like top, but nload does a decent job.

1
  • That looks good, but it needs to run, tell me the traffic, then exits. I need to be able to read it from a script. Oct 25, 2009 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .