I need to average upload and download speed using
dstat -n. How can I add all the received and sent data sizes that appear after
dstat -n, so that I can add them and find average upload and download speed over some period of time ?
You basically want
So this should do:
or for given interfaces
or for all interfaces:
But if you prefer some output you can post-process, it's probably more interesting to have it write out CSV data:
Which will write out 120sec averages out to a CSV file named
As no one answered,I have figured it out. 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.
Add the columns of stat.txt
We can make a script too from these commands.
It seems that dstat is a renamed/hacked version of the sysstat commands, and those will give you the measured traffic, not bandwidth ("speed"). To get that (and that will depend on the target system's load, the path to get there, ...), use something like curl(1), which will tell you afterwards what the average speed was. Also, most home installations are asymmetric, your upload bandwidth is a fraction of the download one.
Also consider that raw bandwith isn't enough, latency is critical for interactive applications (particularly games).
Perhaps a look at the bufferbloat phenomenon is also in order.