Add Speedtest to Web GUI

I think that it would be useful to be able to run speedtest-cli from the Web GUI and was able to do this by hacking the mdstat.cgi script.

image

As you can see creating a speedtest.cgi script would be easy. I don’t know what’s involved with adding a menu entry.

If users and devs think that this is a good idea, I could write a patch to add a speedtest.cgi page with some assistance (and patience since I’m kinda new to this :slight_smile: ) on how to add the entry to the Web GUI menu system as I have no clue there.

Edit: I dug into the menu entry and it turns out I was looking in the wrong places. Actually was able to add the menu entry.

5 Likes

Ok, after all that, it just occurred to me that speedtest-cli is an addon and not installed by default on all systems. Hmmm…

Maybe something like this would be acceptable in that case? Is there a reason that speedtest-cli isn’t installed by default? License issue?

nice!

It should be acceptable… But someone would need to build it up and submit it for approval.

It wasn’t felt to be needed as a “core” package. I do not believe every one needs or uses it. So it lives as an add-on.

If there was a license issue, it would not have been added/accepted to IPFire.

3 Likes

Maybe GUI could be added directly to speedtest-cli addon?

1 Like

Hello,

@porkyle I think that would make a lot of sense. :slight_smile:

Here’s a demo package if you want to give it a try. It just adds the speedtest.cgi and the menu entry and installs speedtest-cli if it’s not there. It doesn’t include any language localizations or link to doc page which doesn’t exist anyway.

If you want to give it a try, upload the zip to your ipfire and extract it. Then go to the speedtestwebgui directory and run install.sh. The only error check that the install script does is to make sure that it’s only run once since it appends to the end of 20-status.menu and doing that multiple times would probably not be good.

speedtestwebgui.zip (2.7 KB)

This works on my system, but from a “my system is not your system” perspective, let me know if you have any issue and feedback would be appreciated.

Let me know what you think.

I think adding a menu item for speedtest that just runs the command line command and then prints the same output as would be seen on the command line doesn’t seem to add much value.

More useful would be if a WUI page was created that enabled you to run it to show the result on the screen or to allow you to select the output going to a csv or json file with a choice of how often to run it, and for how long (for ever or just for a certain number of times) would be much more useful. Name and path of file could be user selectable.

There could also be a table to provide the list of servers that speedtest would select from and the option to exclude some of the servers or to only run the test from one server.

Incidentally I would always run the command with --secure applied so that https is used and not http.

2 Likes

I don’t think speedtest-cli is any good. Whenever I’ve used it, it has been unable to get anywhere near the right line speed reading much too low on an 800/80 internet connection. If I used the Ookla app in windows straight before or afterwards, I got a good reading in Windows…

Hi all,
@stephen , i think this idea might be a nice one if there are some more historical data for speedtests, displayed may with RRD or such ? Also some more informations might be great. I think IPFire uses the sivel package → GitHub - sivel/speedtest-cli: Command line interface for testing internet bandwidth using speedtest.net where it seems that the last commit is meanwhile three years ago ? Did someone tried the speedtest-cli package from librespeed → GitHub - librespeed/speedtest-cli: Command line client for LibreSpeed ?

Best,

Erik

2 Likes

It’s probably also worth noting the outgoing connection information for those who have multiple configured, i.e. interface/connection name & IP address, especially if looking to keep historical data.
Would make it obvious if using fallback / alternate connection.

Hello All,

Thanks for the input. Lots of good ideas.

I’m thinking of this in phases.

Initially, the ability to run speedtest-cli from the Web GUI which is pretty much done with the exception of language localizations and documentation.

Then add the ability to run speedtest-cli at intervals and log that data. I’m working on a page in the Time Settings style with settings on top and “run now” on the bottom for this. The data would be the CSV or JSON produced by speedtest-cli with logrotate according to Log Settings value. It would be up to the user to decide/code how to consume the data. For the intervals, I’m limiting them to number of hours factors of 24 as in “how many times do you want to run speedtest-cli today” and plan to use fcron to drive that.

And finally add something to the Web GUI to be able to display some graphs modeled after existing graph.pl or produce some other useful output from the data that can be displayed. I haven’t spent a lot of time thinking about this.

I think that the first phase could be done with the installation of the speedtest-cli addon but I thought about it and am not comfortable with the idea or maybe the precedent of having an addon package modify the Web GUI i.e. IPFire Core. So I’m not going that route.

So that’s my plan for the time being.

Again thanks for the input and ideas. Feedback is welcome.

Regards,
Stephen

I


like the idea of a page for speed test. i added a start button and back button for the page i have.

1 Like

Hi Stephan,

i think you don´t have to worry about this since a lot of Addons do use the WUI. Spoken from the possibility how to implement software which are only sorted in the additionals or Addons and which are not part of the Core system you can use the DEPS line → git.ipfire.org Git - ipfire-2.x.git/blob - lfs/wio so software needed to get a new feature to run will be installed automatically via Pakfire. Also, the posted LFS is also an Addon (WIO), like Hostapd, Tor and what not else.

But as @nickh mentioned, did you checked the consistence of speedtest-cli ? Or @nickh what measure did you do on your line which brings speedtest-cli to your evalution “don´t think is any good” ?

Best,

Erik

I compared speedtest-cli with the Ookla speed test in Windows. The Windows version gave very similar speeds to my ISP speeds - 800/80. The Linux version was way down on download. I’ve just tried again and in Linux (Centos 7 equivalent) I am seeing 291/67. The 67 is possibly understandable. The 291 is not. This is all on a wired 1000Mb/s LAN… Ubuntu 24.04 shows 309/72.

I tested librespeed-cli, ookla’s cli speedtest, and speedtest-cli and after multiple tests on two different Ipfire systems gave pretty much the same results on 100Mbit line.

I think it is OK on slower connections. Can someone try testing on another fast link?

I was at work when I tested, from home is a different story:

[root@ipsio ~]# speedtest-cli
Retrieving speedtest.net configuration...
Testing from Provider (IP)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by - Fiber (city, state) [364.65 km]: 33.569 ms
Testing download speed................................................................................
Download: 477.38 Mbit/s
Testing upload speed......................................................................................................
Upload: 41.67 Mbit/s
[root@ipsio ~]# ./librespeed-cli
Retrieving server list from https://librespeed.org/backend-servers/servers.php
Selecting the fastest server based on ping
Selected server: , United States (Clouvider) [speedtest.clouvider.net]
Sponsored by: Clouvider @ https://www.clouvider.co.uk/
You're testing from: IP - Unknown ISP
Ping: 28.36 ms  Jitter: 2.68 ms
Download rate:  878.89 Mbps
Upload rate:    39.52 Mbps
[root@ipsio ~]# ./speedtest

   Speedtest by Ookla

      Server:  - city, state (id: x)
         ISP: 
Idle Latency:    25.18 ms   (jitter: 12.18ms, low: 20.20ms, high: 45.99ms)
    Download:   955.04 Mbps (data used: 1.1 GB)                                                   
                 34.58 ms   (jitter: 14.04ms, low: 13.39ms, high: 314.43ms)
      Upload:    40.88 Mbps (data used: 19.9 MB)                                                   
                 91.39 ms   (jitter: 20.59ms, low: 24.54ms, high: 137.00ms)
 Packet Loss:     0.0%

How does that compare to your contracted ISP speed?

speedtest-cli fails the speed test compared to what i should get, the other 2 are spot on

I think speedtest/librespeed cannot be a fully authoritative tool :wink:

edit


edit

Next tests on windows 10 computer in the green zone

obraz

Regards

here is the contents of my modified speedtest.cgi with the start button and a back button for anyone that wants it:

#!/usr/bin/perl
###############################################################################
#                                                                             #
# IPFire.org - A linux based firewall                                         #
# Copyright (C) 2011  IPFire Team  <info@ipfire.org>                          #
#                                                                             #
# This program is free software: you can redistribute it and/or modify        #
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation, either version 3 of the License, or           #
# (at your option) any later version.                                         #
#                                                                             #
# This program is distributed in the hope that it will be useful,             #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
#                                                                             #
###############################################################################

use strict;

# enable only the following on debugging purpose
#use warnings;
#use CGI::Carp 'fatalsToBrowser';

require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";

my %color = ();
my %mainsettings = ();
my %speedparams=();

$speedparams{'ACTION'} = '';

&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);

&Header::showhttpheaders();
&Header::openpage($Lang::tr{'status information'}, 1, '');
&Header::openbigbox('100%', 'left');
&Header::getcgihash(\%speedparams);

&Header::openbox('100%', 'left',"Speedtest");

print <<END 
<table width="100%">
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<tr>
	<td align="center"><input type='submit' name='ACTION' value="$Lang::tr{'start'}"></td>
</tr>
</table>
END
;
print '<br><textarea style="width:100%" rows=15 name="text" readonly="readonly">';
if ( $speedparams{'ACTION'} eq "$Lang::tr{'start'}" )
{
# Run speedtest-cli.
if ( -e "/usr/bin/speedtest-cli" ) {
	my @speedtest = `speedtest-cli -secure`;
	print "@speedtest";
}
else {
	my @speedtest = "Error:  The speedtest-cli addon is not installed.  Use pakfire to install the speedtest-cli addon before running speedtest.";
	print "@speedtest";
}
}
print '</textarea>';


print"<table width='100%'><tr><td align='center'><a href='/cgi-bin/speedtest.cgi'><img src='/images/back.png' alt='$Lang::tr{'back'}' title='$Lang::tr{'back'}' /></a></td></tr></table>";
&Header::closebox();

&Header::closebigbox();
&Header::closepage();
4 Likes