What's new

[script] Current Download/Upload WAN speed

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

berez

Occasional Visitor
Hi,

is there possible to get information about current Download/Upload WAN speed? I would use bash script.
 
This speed value, or other similar current speed value...
 

Attachments

  • speed.JPG
    speed.JPG
    32 KB · Views: 338
is there possible to get information about current Download/Upload WAN speed? I would use bash script.

For download speed testing
Code:
curl  http://proof.ovh.net/files/100Mb.dat -w "%{time_connect},%{time_total},%{speed_download},%{http_code},%{size_download},%{url_effective}\n" -o /dev/null
and while the above is useful when run interactively, you can suppress the progress indicator to have only the '.csv' result line returned for piping/parsing out to a file for later analysis using scripting:
Code:
curl  -s http://proof.ovh.net/files/100Mb.dat -w "%{time_connect},%{time_total},%{speed_download},%{http_code},%{size_download},%{url_effective}\n" -o /dev/null
If you choose an appropriate Upload test site then the same technique can be used for Upload speed testing
 
I want get current speed-stats. No possible speed. Example: if my PC #1 downoads current 1mbps and second PC is downloading now 2mbps then value have to shows 3mbps as current download speed from WAN.
 
Speed is a function of time. So you have to decide what time period you are measuring, 1 millisecond, 1 second, 10 seconds, etc.

This command will give you the total number of bytes downloaded and uploaded at that point in time. If you wait for your desired sampling period (say 1 second) and issue the command again you can subtract one from the other giving you the rate.

Code:
ifconfig $(nvram get wan0_ifname) | grep "RX bytes" | awk -F[:\(] '{print $2 $4}'
 
Thanks - great solution.

What is the best way to "transfer" these values to another debian-based device (rapsberry pi)?

I see two solutions
1. Install mosquito service on the router, and then "publish" (by mosquitto_pub command) values to rapsberry pi.

or

2. Create script on rapsberry pi, script will do:
- logon to router by ssh
- execute @ColinTaylor command


maybe any other ideas?
 
Probably easier to use SNMP if you need this data on another device. Note that the RX+TX number on WAN interface (br0) would wrap after 4GB because Broadcom/Asus is funny that way.
 
I'd never heard of mosquito so can't comment on that.

I do something similar with QoS bandwidth data. I have a script that runs continuously on the router. Every 2 seconds it collects the data and appends it to a file together with a timestamp. Then I have another process that periodically runs on a Centos server that logs into the router with FTP and transfers the file. The file is fed into an RRD database and displayed as a graph on a web page.

EDIT: @kfp suggestion is probably a better solution, although it's not appropriate in my specific situation :(.

Whatever solution you choose should ultimately by driven by the data; frequency, format, accuracy, resilience, etc.
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top