Bandwidth in real time

The same way, as command
Code:
top
shows live cpu usage, I would like same type of command, that shows live bandwith usage
 
Beastie said:
This one's my favorite, but I usually add a number at the end (% systat -ifstat x) to get updates every x seconds.
I do this too. And almost always x=1.
 
Does anyone know of a way to get the current up/down rate for an interface without the curses interface? I would like the current rates reported once, so I can grab these values in a script.
 
Does anyone know of a way to get the current up/down rate for an interface without the curses interface? I would like the current rates reported once, so I can grab these values in a script.
Sorry If I bump, but I need too something that I can grab in a script, any advice?
 
And If I want to visualize download or upload only?
For just the download rate, you can use ifstat -i wlan0 -b 1 1 | awk 'NR%3==0 {print $1}'. For upload only, replace $1 with $2. Replace wlan0 with your interface.

EDIT: So the above works in that it extracts what you want from the ifstat output, but what ifstat reports does not seem very accurate, at least with a count of 1. Maybe it takes a few updates before it reports something accurate?
 
For just the download rate, you can use ifstat -i wlan0 -b 1 1 | awk 'NR%3==0 {print $1}'. For upload only, replace $1 with $2. Replace wlan0 with your interface.

EDIT: So the above works in that it extracts what you want from the ifstat output, but what ifstat reports does not seem very accurate, at least with a count of 1. Maybe it takes a few updates before it reports something accurate?

Oh really thanks!
What about if I want to visualize the value in KiloBytes or maybe MegaBytes?

EDIT
Looks like the value it shows with your command are not the download/upload speed. I state that I've changed wlan0 with mine (re0).
 
According to ifstat(1), the rates are reported in kbytes/sec by default and with the -b flag, kbits/sec. If you wanted MB/s, you could use something like ifstat -i wlan0 1 1 | awk 'NR%3==0 {print $1/1024}', but a quick test shows inaccurate rates. You might play around with a larger count. Maybe something like this untested command: ifstat -i wlan0 1 3 | awk 'NR%5==0 {print $1}'.
 
According to ifstat(1), the rates are reported in kbytes/sec by default and with the -b flag, kbits/sec. If you wanted MB/s, you could use something like ifstat -i wlan0 1 1 | awk 'NR%3==0 {print $1/1024}', but a quick test shows inaccurate rates. You might play around with a larger count. Maybe something like this untested command: ifstat -i wlan0 1 3 | awk 'NR%5==0 {print $1}'.

Thanks a lot, I've tried to put your commands inside my bar bash script but with ifstat it takes seconds before it shows all values. Is it possible to show all the other values without waiting for "download" and "upload"? Here my script:

Bash:
#!/bin/bash

while true; do
»···date="$(date "+%a %d-%m-%Y %H:%M:::%Z")"
»···volume="$(mixer | grep 'pcm' | awk '{print $7}')"
»···cputemp="$(sysctl -a | grep 'dev.cpu.5.temperature' | awk '{print $2}')"
»···memusage="$(freecolor -m -o | grep 'Mem' | awk '{print $4}')"
»···memtotal="$(freecolor -m -o | grep 'Mem' | awk '{print $2}')"
»···ipaddress="$(ifconfig re0 | grep 'inet' | awk '{print $2}')"
»···download="$(ifstat -i re0 1 3 | awk 'NR%5==0 {print $1}')"
»···upload="$(ifstat -i re0 1 3 | awk 'NR%5==0 {print $2}')"

»···xsetroot -name " ${download}KB/s ${upload}KB/s ${memusage}MB/${memtotal}MB ${cputemp} $ipaddress $volume $date "
»···sleep 1
done
 
Back
Top