You can get network bandwidth and number of packets using the following dstat
command:
dstat -n --net-packets -f 10
Or, if you want to control certain interfaces, you can do:
dstat -n --net-packets -N eth0,wlan0 10
If you prefer the more usual output bits per second
:
dstat -n --net-packets -N eth0,wlan0 --bits 10
This will give you 10 second averages. If you prefer to write this for post-processing, you can export it to a CSV file using:
dstat -n --net-packets -N eth0,wlan0 --bits 10
Dstat comes with many plugins for comparing these metrics with other metrics on your system and gives you the option to add your own (python) plugins if you need to customize data or control something specific for your environment.
source share