Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to average upload and download speed using dstat -n.

How can I add all the received and sent datas that appear after dstat -n, so that I can add them and find average upload and download speed over some period of time?

share|improve this question
up vote 1 down vote accepted

You could pass the arguments for delay (number of seconds) and counter (number of times) to run, and capture the output in a txt or csv file.

Check the dstat manual (see arguments section):

dstat -n 5 10 >> /tmp/dstat_speed.txt 

The above runs 10 times for every 5 seconds.

share|improve this answer
I know that.Give me the way to add them,not print to a file. – Optimus Prime Jan 25 '13 at 17:01
Okay found it,adding columns in a file,using this method – Optimus Prime Jan 25 '13 at 17:33
I will accept your answer now. – Optimus Prime Jan 25 '13 at 17:37
excellent. thank you. – Ram G Jan 25 '13 at 18:13

Here is how to do it. Let's say we need to average it for "2 min(120 sec)". First write it to a file named stat.txt.Refresh every second fro 120 times.

       dstat -n 1 120 >> stat.txt

Add the columns of stat.txt

       awk -F" " '{t1=t1+$1;t2=t2+$2}END{t1=t1/120;t2=t2/120;print t1"\t"t2}' stat.txt

Remove stat.txt

       rm stat.txt

We can make a script too from these commands.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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