Script to read traffic speed which is used by Ajax speedmeter

Help on building IPFire & Feature Requests
Post Reply
dnl
Posts: 313
Joined: June 28th, 2013, 11:03 am

Script to read traffic speed which is used by Ajax speedmeter

Post by dnl » May 9th, 2018, 9:55 am

Hello,

Can a script running on IPFire read the traffic speed (in and out) which is displayed in the Ajax speedmeter?

My ISP is having difficult to problems with variable bandwidth. I've been running speed tests on a schedule to collect evidence.
The problem is that the speed tests are not accurate if there is something else using a lot of bandwidth. I hope to try to come up with something which will poll the "in" and "out" speeds reported by the Ajax speedmeter while running the speed test. At the end I'd report the highest speed in and the highest speed out.


For reference, the speed tests use this script from github https://github.com/sivel/speedtest-cli and are using a speed test server which the ISP hosts.

Thank you!
Image

ummeegge
Community Developer
Community Developer
Posts: 4576
Joined: October 9th, 2010, 10:00 am

Re: Script to read traffic speed which is used by Ajax speedmeter

Post by ummeegge » May 28th, 2018, 9:09 am

Hi dnl,
we´ve used speedtest-cli also in another project --> viewtopic.php?t=18586#p106896 . In there is also a script which collects the data in that format

Code: Select all

2018-28-05:11:01:27 | Download: 47.57 Mbit/s | Upload: 7.74 Mbit/s | wilhelm.tel (Norderstedt) [17.40 km]: 10.379 ms
2018-28-05:11:02:28 | Download: 48.40 Mbit/s | Upload: 9.07 Mbit/s | wilhelm.tel (Norderstedt) [17.40 km]: 10.548 ms
2018-28-05:11:03:29 | Download: 48.34 Mbit/s | Upload: 8.93 Mbit/s | wilhelm.tel (Norderstedt) [17.40 km]: 10.475 ms
script has been placed under /etc/fcron.minutely , whereby the script executes speedtest-cli which has been renamed to pyspeed and is located under /usr/bin . A speedtest.db can be found under /tmp .
This is a testing script and i´am not sure if it matches your whishes but may as a starting point interesting...

EDIT: Fast awk for average calc

For updload average:

Code: Select all

awk '{ sum+=$8 } END { print "Upload Average = ",sum/NR" mbit/s" }' /tmp/speedtest.db
For download average:

Code: Select all

awk '{ sum+=$4 } END { print "Download Average = ",sum/NR" mbit/s" }' /tmp/speedtest.db
Greetings,

UE
Image
Image
Image

dnl
Posts: 313
Joined: June 28th, 2013, 11:03 am

Re: Script to read traffic speed which is used by Ajax speedmeter

Post by dnl » June 10th, 2018, 6:23 am

Thank you ummeegge!

I have the script working but wanted to avoid impacting all internet traffic to the network.
In the short-term I changed the speed test IP to a high priority in the QoS settings. This way the test is more accurate, even if it interrupts internet usage a little.
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests