arevindh / pihole-speedtest

Pihole Speedtest Mod
https://arevindh.github.io/pihole-speedtest/
MIT License
218 stars 22 forks source link

Speedtest manual server entry and times of speedtests are incorrect #163

Closed ChrisWNY closed 4 months ago

ChrisWNY commented 4 months ago

Some funkiness going on within the Pi-hole speedtest Settings area:

In Pi-Hole Settings > Speedtest, setting a manual server ID does nothing. The speedtest reverts to a pre-determined server, "PhoenixNAP Global IT Services" no matter which speedtest server ID is configured. The ID gets saved in the UI properly, but it tests against PhoenixNAP Global IT Services anyway.

Times on the bar graph show up as GMT - timezone_Offset. For example, in my case I have speedtests run every 12 hours, at 12pm EST and 12AM EST. The times show up as 7AM and 19:00 on the bar graph. In other words, times on the bar graph are GMT only and cannot be changed or adjusted to display the time in the local timezone being used. The OS timezone in Ubuntu is set to US EST.

Checking "run test now" then hitting the "CONFIRM" button on the lower-right has no effect and does not kick off speed tests.

Pi-hole OS and hardware info: Ubuntu 6.5.0-17-generic #17-Ubuntu SMP PREEMPT_DYNAMIC Thu Jan 11 14:01:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux N5105 x86 CPU 16GB RAM 512GB NVMe

ipitio commented 4 months ago

Oh man I thought I got everything working. Can you confirm all that doesn't work on another browser, or if you clear site data on the browser you're using?

We use MomentJS to convert the UTC dates stored in the database to your browser's timezone; is your browser on the same timezone as your OS? Firefox, for example, sets its timezone to UTC if you enable fingerprinting resistance. What timezone offset is in the speedtest log?

Do you see any errors or warnings in the console when trying to run a test now? Does the "show status" show anything different after you try running a test now? I actually forgot to test testing with a custom server so I'll take a look at that tonight.

ChrisWNY commented 4 months ago

It's the same issue across different browsers...confirmed via Chrome, Firefox, and MS Edge. Checking off "manual speed test" in Settings and clicking "confirm" results in a correct status message, but the actual speedtest itself doesn't kick off. Changing the Speedtest server in any browser results in the ID being saved properly within the UI, but the Speedtest process itself still defaults to "PhoenixNAP Global IT Services."

Times are all shown in UTC regardless of browser...seems that timezone settings are being ignored, defaulting to UTC on the bar graph...within the Speedest log it shows "UTC-5:00" for time, so it knows I'm in EST but doesn't show the actual EST hour/minute. The browser on my client PC is in the same timezone (Eastern US Time) as the OS hosting Pi-hole.

I'm not seeing any errors or warnings within the console...the scheduled 12-hour speedtests run fine as expected.

image image

town3r commented 4 months ago

Do you run into the same issue if you perform a clean install of the mod from @ipitio repo?

curl -sSLN https://github.com/ipitio/pihole-speedtest/raw/ipitio/mod.sh | sudo bash

I don't think I'm running into the same issues w/ the build from their repo atm.

image

ChrisWNY commented 4 months ago

I'll try a clean install to find out if that makes a difference and will report back.

Edit: I'm getting the following when running the script:

`The repository is setup! You can now install packages.

Fri Feb 23 09:33:11 AM EST 2024 `

Not sure where it's looking for speedtest...it's clearly installed on my Ubuntu host: ~$ speedtest --version Speedtest by Ookla 1.2.0.84 (ea6b6773cf) Linux/x86_64-linux-musl 6.5.0-17-generic x86_64

ChrisWNY commented 4 months ago

And nevermind about the automatic/scheduled speedtests running, they haven't run since 2/19, which was when I pulled the latest repo down. I know it boils down to a script or module not recognizing where my speedtest install resides. Just don't have the spare time right now to troubleshoot it any further.

EDIT: Running "curl -sSLN https://github.com/ipitio/pihole-speedtest/raw/ipitio/mod.sh | sudo bash" messes things up in /etc/apt/sources.list.d - a source list for speedtest ends up being added to that directory as a result of running that script, and until I remove that file, sudo apt update won't work because of an error related to speedtest not having a release file. Clearly there are some kinks to be worked out in that install script - it may work on Raspberry Pi OS systems, but certainly has not worked from my experience on my Ubuntu host.

ChrisWNY commented 4 months ago

Any suggestions on temporary workarounds? The scripts seem to have issues with speedtest package locations...I don't use the speedtest CLI, only the official Ookla speedtest app. Tests haven't worked since I pulled the newest repo down. I'm also not seeing a way to roll back to a previous, working repo.

ipitio commented 4 months ago

Sorry, I haven't been home the past few days so haven't had a chance to take a look. I don't have an idea yet as to why you're experiencing those issues since the script and mod work on my raspi os and linux mint machines, and in docker.

What's the location of your speedtest binary?

And yeah there isn't functionality (yet) in the script to roll back to a previous release unfortunately.

ChrisWNY commented 4 months ago

The speedtest binary is in /usr/bin/speedtest.

image

ipitio commented 4 months ago

Well that's where it's supposed to be... I shall investigate.

In the meantime you can use git checkout in /var/www/html/admin and /opt/mod_pihole to go back to their respective previous tags. Then copy webpage.sh and speedtestmod/ from mod_pihole to pihole (unless you need to go back to when speedtest.sh was in admin, then copy speedtest.sh to where it was there).

ChrisWNY commented 4 months ago

Here's /opt/pihole image

speedtest.sh used to be in var/www/html/admin/scripts/pi-hole

I had a script that I used to use for updating my pi-hole repo. It worked great until you guys moved some things around.

!/bin/sh

manually update pi-hole speedtest

cd /opt/pihole/ rm webpage.sh wget https://github.com/pi-hole/pi-hole/raw/master/advanced/Scripts/webpage.sh chmod +x webpage.sh

cd /var/www/html/ rm -rf org_admin mv admin org_admin # remove old org_admin folder if exists git clone https://github.com/arevindh/AdminLTE admin

cd /opt/pihole/ rm -f webpage.sh.org mv webpage.sh webpage.sh.org # remove old webpage.sh.org file if exists wget https://github.com/arevindh/pi-hole/raw/master/advanced/Scripts/webpage.sh chmod +x webpage.sh

pihole updatechecker local

So, I would run 2 scripts...one would REMOVE /var/www/htm/admin/ and replace it with the unmodified admin repo - https://github.com/pi-hole/AdminLTE

Then I'd remove /opt/pihole/webpage.sh and manually replace it with the original.

After Pi-hole was updated, I'd go ahead and run the script above that would pull down Sid's repo.

Is there a way I can update manually using the command line in the meantime? I can't for the life of me find speedtest.sh any more.

ipitio commented 4 months ago

I moved speedtest.sh from admin to /opt/pihole/speedtestmod (which the script copies from the /opt/mod_pihole/advanced/Scripts that it clones) since its function is more in line with the other scripts in that repo, rather than the web interface.

We do have to update the manual instructions since they've been outdated since v2.

ChrisWNY commented 4 months ago

Problem is I don't have /opt/pihole/speedtestmod on my host - it never got to the point of grabbing it since the script bails before that happens. Is there a direct link I could use to pull down the new files?

ipitio commented 4 months ago

Yeah you can just download/clone and copy the files from https://github.com/arevindh/pi-hole. You just need to copy webpage.sh and speedtestmod/

Also how did you have the speedtest binary installed initially without its repo?

ChrisWNY commented 4 months ago

I installed the Ookla speedtest binary by downloading the binary (.tgz file) and copying it manually to /usr/bin/speedtest

Here's the direct link for the binary - https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz

Just to double check, I'll need an entire directory named "speedtestmod" within /opt/pihole - webpage.sh I'm assuming just goes into the /var/www/html/admin

Making sure I put the files in the correct places. Thanks.

ipitio commented 4 months ago

That's correct, for the current version of the mod, except that webpage.sh also goes in /opt/pihole

ChrisWNY commented 4 months ago

Even with those scripts in their correct locations:

/opt/pihole/speedtestmod Contains mod.sh and speedtest.sh

/opt/pihole contains modified webpage.sh

When I attempt to kick off a speedtest from the Speedtest Settings within the web UI, nothing.

Also, the problem with the "official" speedtest package is that it doesn't exist, at least not on Ubuntu. If you follow these instructions (for Ubuntu/Debian) on a stock, untouched Ubuntu host, you'll find the following instructions take you nowhere:

https://www.speedtest.net/apps/cli

~$ sudo apt-get install speedtest Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package speedtest

When you run "sudo apt-get install speedtest" after going through the previous commands, the package isn't found. That's why I had to download the binary and manually copy it to /usr/bin/speedtest

This same command runs without error on Raspberry Pi OS. No idea why it works there but not Ubuntu.

Ideally your scripts should be package/OS-agnostic. If the binaries are in the right place, good to go. Pi-hole is supported on Ubuntu and a large number of users run it there.

ipitio commented 4 months ago

Ideally your scripts should be package/OS-agnostic. If the binaries are in the right place, good to go. Pi-hole is supported on Ubuntu and a large number of users run it there.

You don't say :)

ipitio commented 4 months ago

@ChrisWNY If the following works for you, I'll merge the PR.

curl -sSLN https://github.com/ipitio/pihole-speedtest/raw/ipitio/mod.sh | sudo bash -s up
ChrisWNY commented 4 months ago

I'm seeing syntax errors when running that one...

"Thanks for using Speedtest Mod! Script by @ipitio

Tue Feb 27 08:07:47 PM EST 2024

Restoring Pi-hole... /opt/pihole/webpage.sh: line 1: syntax error near unexpected token `('"

Lots of text beyond that (too much to paste here), but it errors out and aborts.

ipitio commented 4 months ago

Oops wrong branch, try: (note no -s up)

curl -sSLN https://github.com/ipitio/pihole-speedtest/raw/ipitio/mod.sh | sudo bash
ChrisWNY commented 4 months ago

That one did the job! Times look correct on the graph as well. Was able to kick off the speedtest from Settings > Speedtest within the UI. Looks good.

ipitio commented 4 months ago

Finally! Glad it's working for you.

ChrisWNY commented 4 months ago

Thanks for sorting this one out!

One quick question - is there still some sort of limiter capping CPU usage when the speedtests kick off? I have symmetrical 1Gb fiber, always notice the upload tests seem to peak at 750Mbps from the repo. When I run the same test (against the same server) from a laptop on my LAN, I get 950Mbps up/down. That's why I thought there may something capping CPU within the configs somewhere.

ipitio commented 4 months ago

There briefly used to be a cpu cap in /etc/systemd/system/pihole-speedtest.service when we first created it, but quickly got rid of it. The speedtest CLI is run directly so the only limiting factor should be the hardware.

Try running speedtest directly in your Ubuntu machine's terminal—the speed should be the same as when the mod runs it.