Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Speedtest CLI. Run speedtest on pfSense box

    Scheduled Pinned Locked Moved pfSense Packages
    167 Posts 52 Posters 144.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • provelsP
      provels @justheretohelp
      last edited by provels

      @justheretohelp
      Create speedtest.inc in /usr/local/www/widgets/include
      This will add the Speedtest entry to the pfSense Dashboard widget choices.

      <?php
      /* File     : /usr/local/www/widgets/include/speedtest.inc
       * Author   : Zak Ghani
       * Date     : 10-03-2019
       * 
       * This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
       * OR CONDITIONS OF ANY KIND, either express or implied.
       * 
       */
      
      $Download_title = gettext("Speedtest - Mbps");
      
      ?>
      

      Then create speedtest.widget.php in /usr/local/www/widgets/widgets

      <?php
      /* File     : /usr/local/www/widgets/widgets/speedtest.widget.php
       * Author   : Zak Ghani
       * Date     : 10-03-2019
       * 
       * This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
       * OR CONDITIONS OF ANY KIND, either express or implied.
       * 
       * URL Choices :    https://www.bing.com/widget/t/speedtest
       *                  https://www.measurementlab.net/p/ndt-ws.html
      
       */
      
      require_once("guiconfig.inc");
      
      ?> 
      
      <iframe 
          src="https://www.bing.com/widget/t/speedtest"
      width="498"
      height="500"
      frameborder="0"
      >
      </iframe>
      

      When you copy the code, be sure to get it all, the windows scrolls. You may need to mess with the pixel height/width of the object.
      Think that's it...

      Peder

      MAIN - pfSense+ 24.11-RELEASE - Adlink MXE-5401, i7, 16 GB RAM, 64 GB SSD. 500 GB HDD for SyslogNG
      BACKUP - pfSense+ 23.01-RELEASE - Hyper-V Virtual Machine, Gen 1, 2 v-CPUs, 3 GB RAM, 8GB VHDX (Dynamic)

      1 Reply Last reply Reply Quote 1
      • R
        RaidArray
        last edited by

        Sorry about the dead links. In the middle of moving websites. @provels has it spot on coding wise.
        Should be able to get the instructions back on line within the next few days.

        luckman212L 1 Reply Last reply Reply Quote 0
        • luckman212L
          luckman212 LAYER 8 @RaidArray
          last edited by

          @RaidArray Are those instructions back up online somewhere by chance?

          1 Reply Last reply Reply Quote 0
          • M
            MarcO42
            last edited by MarcO42

            Hi,
            this long discussion was nearly wat I'm locking for.
            But in the end I build it on my own...and maybe someone is interested in this. Here is what I did:
            I have mounted a USB drive (not really necessary for everybody) and build a script that can called by cron.
            This script is parsing the response from speedtest-cli on directly on the WAN interface and writes a log file. From this log file I took the last 7 lines (cron is running every day) and create a /usr/local/www/js/speettest_cli.js as data file for my chart from https://www.chartjs.org.
            And here is the result:
            0e8cb483-3fab-4221-b978-39dfeb42c13c-grafik.png

            The tooltip is a mouse over and you can also hide single elements like this:

            d18f6f55-5479-4dcb-af1e-b43731d6c5ca-grafik.png
            The fact that you see only the 03.03. and 04.03. is that I created yesterday and these are just placeholder until the new data arrived.

            Here you can finde all files.

            speedtest.zip

            Feel free to use it. Think everyone have to adapt all the paths in the \usr\local\bin\speedtest.sh
            Also in this file you have to set you place for the speedtest...like speedtest-cli --server 16688

            Cheers
            MarcO

            P 1 Reply Last reply Reply Quote 4
            • L
              lastb0isct
              last edited by

              Does anyone have the speedtest.py still? I can't seem to find it.

              provelsP 1 Reply Last reply Reply Quote 0
              • luckman212L
                luckman212 LAYER 8
                last edited by

                @lastb0isct Have you tried...

                # pkg search speedtest
                # pkg install py27-speedtest-cli
                

                if pkg gives you a Shared object "libcryptoauth.so.3" not found, required by "pkg" error, try

                # pkg-static install py27-speedtest-cli
                
                1 Reply Last reply Reply Quote 0
                • provelsP
                  provels @lastb0isct
                  last edited by

                  @lastb0isct said in Speedtest CLI. Run speedtest on pfSense box:

                  Does anyone have the speedtest.py still? I can't seem to find it.

                  It comes with the package when you install it. SSH to your box and run:

                  pkg search speedtest
                  
                  [2.4.4-RELEASE][root@fw.workgroup]/root: pkg search speedtest
                  py37-speedtest-cli-2.1.1       Command line interface for testing internet bandwidth
                  
                  

                  Then run

                  pkg install py37-speedtest-cli-2.1.1
                  

                  Have fun!

                  Peder

                  MAIN - pfSense+ 24.11-RELEASE - Adlink MXE-5401, i7, 16 GB RAM, 64 GB SSD. 500 GB HDD for SyslogNG
                  BACKUP - pfSense+ 23.01-RELEASE - Hyper-V Virtual Machine, Gen 1, 2 v-CPUs, 3 GB RAM, 8GB VHDX (Dynamic)

                  A 1 Reply Last reply Reply Quote 0
                  • L
                    lastb0isct
                    last edited by

                    Where does the speedtest.py live after installation?

                    provelsP 1 Reply Last reply Reply Quote 0
                    • provelsP
                      provels @lastb0isct
                      last edited by

                      @lastb0isct said in Speedtest CLI. Run speedtest on pfSense box:

                      Where does the speedtest.py live after installation?

                      /usr/local/lib/python3.7/site-packages

                      Peder

                      MAIN - pfSense+ 24.11-RELEASE - Adlink MXE-5401, i7, 16 GB RAM, 64 GB SSD. 500 GB HDD for SyslogNG
                      BACKUP - pfSense+ 23.01-RELEASE - Hyper-V Virtual Machine, Gen 1, 2 v-CPUs, 3 GB RAM, 8GB VHDX (Dynamic)

                      1 Reply Last reply Reply Quote 0
                      • A
                        adamoutler
                        last edited by

                        Run
                        pkg search speedtest
                        py37-speedtest-cli-2.1.1 Command line interface for testing internet bandwidth
                        We can now see the package we need to install
                        pkg install py37-speedtest-cli-2.1.1
                        then run with
                        /usr/local/bin/speedtest

                        1 Reply Last reply Reply Quote 1
                        • A
                          aln
                          last edited by

                          I've created a widget to run speedtest directly from your pfSense dashboard
                          https://github.com/aln-1/pfsense-speedtest-widget

                          provelsP A A A 4 Replies Last reply Reply Quote 4
                          • provelsP
                            provels @aln
                            last edited by

                            @aln Hey, it works! Nice job! :)

                            f0c6ea48-29f5-420f-b02e-ebee2c4a4ec5-image.png

                            Peder

                            MAIN - pfSense+ 24.11-RELEASE - Adlink MXE-5401, i7, 16 GB RAM, 64 GB SSD. 500 GB HDD for SyslogNG
                            BACKUP - pfSense+ 23.01-RELEASE - Hyper-V Virtual Machine, Gen 1, 2 v-CPUs, 3 GB RAM, 8GB VHDX (Dynamic)

                            A 1 Reply Last reply Reply Quote 0
                            • johnpozJ
                              johnpoz LAYER 8 Global Moderator
                              last edited by

                              Pretty slick.. Nice work..

                              Not really a fan of running speedtest on pfsense itself, its always better to do them "thru" pfsense (from a client behind).. But yeah could see how it could come in handy for some.

                              speedtest.jpg

                              Allowing for some settings, like picking server, etc.. would be even extra slick ;)

                              2.4.5-RELEASE][admin@sg4860.local.lan]/: speedtest -h
                              usage: speedtest [-h] [--no-download] [--no-upload] [--single] [--bytes]
                                               [--share] [--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
                                               [--csv-header] [--json] [--list] [--server SERVER]
                                               [--exclude EXCLUDE] [--mini MINI] [--source SOURCE]
                                               [--timeout TIMEOUT] [--secure] [--no-pre-allocate]
                                               [--version]
                              
                              Command line interface for testing internet bandwidth using speedtest.net.
                              --------------------------------------------------------------------------
                              https://github.com/sivel/speedtest-cli
                              
                              optional arguments:
                                -h, --help            show this help message and exit
                                --no-download         Do not perform download test
                                --no-upload           Do not perform upload test
                                --single              Only use a single connection instead of multiple. This
                                                      simulates a typical file transfer.
                                --bytes               Display values in bytes instead of bits. Does not
                                                      affect the image generated by --share, nor output from
                                                      --json or --csv
                                --share               Generate and provide a URL to the speedtest.net share
                                                      results image, not displayed with --csv
                                --simple              Suppress verbose output, only show basic information
                                --csv                 Suppress verbose output, only show basic information
                                                      in CSV format. Speeds listed in bit/s and not affected
                                                      by --bytes
                                --csv-delimiter CSV_DELIMITER
                                                      Single character delimiter to use in CSV output.
                                                      Default ","
                                --csv-header          Print CSV headers
                                --json                Suppress verbose output, only show basic information
                                                      in JSON format. Speeds listed in bit/s and not
                                                      affected by --bytes
                                --list                Display a list of speedtest.net servers sorted by
                                                      distance
                                --server SERVER       Specify a server ID to test against. Can be supplied
                                                      multiple times
                                --exclude EXCLUDE     Exclude a server from selection. Can be supplied
                                                      multiple times
                                --mini MINI           URL of the Speedtest Mini server
                                --source SOURCE       Source IP address to bind to
                                --timeout TIMEOUT     HTTP timeout in seconds. Default 10
                                --secure              Use HTTPS instead of HTTP when communicating with
                                                      speedtest.net operated servers
                                --no-pre-allocate     Do not pre allocate upload data. Pre allocation is
                                                      enabled by default to improve upload performance. To
                                                      support systems with insufficient memory, use this
                                                      option to avoid a MemoryError
                                --version             Show the version number and exit
                              [2.4.5-RELEASE][admin@sg4860.local.lan]/: 
                              

                              An intelligent man is sometimes forced to be drunk to spend time with his fools
                              If you get confused: Listen to the Music Play
                              Please don't Chat/PM me for help, unless mod related
                              SG-4860 24.11 | Lab VMs 2.8, 24.11

                              1 Reply Last reply Reply Quote 0
                              • A
                                aln @provels
                                last edited by

                                @provels I'm glad I could contribute something back to the community.
                                @johnpoz the only reason to run speedtest on pfSense is to test your ISP without speed drops of other elements in your network.

                                A A johnpozJ E 4 Replies Last reply Reply Quote 1
                                • A
                                  adamoutler @aln
                                  last edited by

                                  Thank you very much, @aln!

                                  I don't know why this isn't a stock package. Speed test on a router is a must. Thank you ever so much. This is by far my most needed package and you have just made my dreams come true.

                                  To show my appreciation, I'd like to contribute some easy-install instructions. This short script does what you said to do. It won't install the widget if the pkg install fails. This can be run from the Diagnostics> Command Prompt > Execute Shell Command

                                  pkg update ; pkg install -y py37-speedtest-cli && curl -o /usr/local/www/widgets/widgets/speedtest.widget.php https://raw.githubusercontent.com/aln-1/pfsense-speedtest-widget/master/speedtest.widget.php
                                  

                                  Please consider further development, making this an official pFSense package. I'm very happy this is now a thing and thank you ever so much.

                                  After hitting the refresh button, it comes up blank and never shows my results. I have to refresh the page to see the results. Any ideas?
                                  08dc0b64-1204-4f2c-9836-f026177d00c2-image.png
                                  e1d118c1-0907-4db3-83b8-7a9be7bc93c1-image.png

                                  A 1 Reply Last reply Reply Quote 3
                                  • A
                                    aln @adamoutler
                                    last edited by

                                    @adamoutler when hitting the refresh button did it finish spinning? Can you see if there are any warning or errors in the browser's developer tools?
                                    The widget will show an empty image initially and will cache the last speedtest results. You will be able to see them for as long as Ookla is caching them, as far as I can say this is forever.

                                    A 1 Reply Last reply Reply Quote 0
                                    • provelsP
                                      provels
                                      last edited by provels

                                      FWIW, when I ran it the second time, I also got an empty box, but every subsequent run it went fine. I just hit the chasing arrows again.

                                      Peder

                                      MAIN - pfSense+ 24.11-RELEASE - Adlink MXE-5401, i7, 16 GB RAM, 64 GB SSD. 500 GB HDD for SyslogNG
                                      BACKUP - pfSense+ 23.01-RELEASE - Hyper-V Virtual Machine, Gen 1, 2 v-CPUs, 3 GB RAM, 8GB VHDX (Dynamic)

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        aln @aln
                                        last edited by

                                        I get some positive feedbacks and that's nice.
                                        This was really quick and dirty widget. Maybe I'll take it a step further.
                                        I'll keep you posted.

                                        1 Reply Last reply Reply Quote 1
                                        • A
                                          adamoutler @aln
                                          last edited by

                                          @aln maybe a reboot is required to reload the PHP system? It just stopped spinning and went blank.

                                          A 1 Reply Last reply Reply Quote 0
                                          • A
                                            aln @aln
                                            last edited by

                                            @aln new and improved version is now available
                                            Screenshot 2020-05-21 at 01.22.12.png

                                            A J 2 Replies Last reply Reply Quote 3
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.