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

Speedtest CLI. Run speedtest on pfSense box

pfSense Packages
52
167
136.3k
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.
  • P
    provels @kcallis
    last edited by provels Apr 20, 2019, 11:23 AM Apr 19, 2019, 8:52 PM

    @kcallis I just used an Outlook.com account. BTW, the post above from @icewraithuk was posted 2 years ago and it was his only post ever on the forum.

    PS - I found a cool chart in the ThingSpeak forums with a chart template that consolidates the CSV data produced by @icewraithuk 's method that I managed to modify to show my upload/download/ping data all in one chart, but you'll need to muddle through the edits manually. There are notes in the .html file that tell you where to put your info. Not saying it's the best data set, but a fun excercise anyway.
    https://community.thingspeak.com/forum/announcements/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/

    login-to-view

    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
    • 0
      0daymaster @provels
      last edited by May 29, 2019, 6:26 PM

      @provels That is rad but it seems like running speedtest every ten minutes would be quite a burden on your WAN connection. Can you post the PHP you used for the widget? Thanks.

      P 1 Reply Last reply Jun 13, 2019, 2:03 AM Reply Quote 0
      • P
        provels @0daymaster
        last edited by provels Jun 13, 2019, 2:10 AM Jun 13, 2019, 2:03 AM

        @0daymaster I run the speedtest every 30 minutes now, but it's just me, so who cares? You pretty much need everything in this thread to do what I did.
        1 - Install speedtest-cli on the FW. Run some tests from the shell to get a feel for it.
        2 - Setup a Thinkspeak.com account and do the @icewraithuk edits to the speedtest.py file (make @cukal 's edits for Mbps instead of MB if you wish).
        3 - Now you should be able to send the data to Thinkspeak to generate the graphs. Format them in the style/colors as you wish. You'll use the
        Read API Key to post the data you'll add to the widget.
        4 - Then just use @RaidArray 's instruction to add the URL for your chosen Thingspeak graphs and to create the widget you can load from the FW homepage.
        5- You can DL the html file from the Thingspeak forum post and edit it in a text editor to make it useful for your data. I didn't incorporate it into the FW homepage, though. I now also use a Windows version of speedtest-cli (Google) running as a scheduled task on an inside server so the tests actually run through the FW rather than from it
        All credit goes to everyone else. I just managed to screw some parts together, in spite of myself.

        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
        • J
          joeontherun
          last edited by joeontherun Oct 13, 2019, 7:13 PM Oct 13, 2019, 7:08 PM

          Just want to have my input here took me a while to figure my way around all the coding but with a bit of persistence i got my 15 min speed checker working & managed to get it working in pfsense will attach screen shot for you to see well chuffed with the outcome just want to say thanks to all that inputted information to make this happen,

          It would be nice to drop all 3 data UL DL & Ping in to the 1 graph i tried to do it but it just got to complicated

          Thanks

          login-to-view

          P 1 Reply Last reply Oct 13, 2019, 11:05 PM Reply Quote 0
          • P
            provels @joeontherun
            last edited by provels Oct 13, 2019, 11:07 PM Oct 13, 2019, 11:05 PM

            @joeontherun Nice work! Just duplicate what you did for your "Speed Checker" graph. Create the graphs on Thingspeak, create the .inc files pointing to the links and the .php widgets! Then smile! Can help as needed, but I think you got it! :)
            login-to-view

            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
            • J
              justheretohelp
              last edited by Jan 12, 2020, 12:17 AM

              The link for how to make a widgit with speed test is dead.

              Anyone have a instruction for how to get speedtest in the GUI?

              P 1 Reply Last reply Jan 12, 2020, 1:31 AM Reply Quote 0
              • P
                provels @justheretohelp
                last edited by provels Jan 12, 2020, 1:36 AM Jan 12, 2020, 1:31 AM

                @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 Jan 12, 2020, 3:50 PM

                  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.

                  L 1 Reply Last reply Feb 10, 2020, 9:08 PM Reply Quote 0
                  • L
                    luckman212 LAYER 8 @RaidArray
                    last edited by Feb 10, 2020, 9:08 PM

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

                    1 Reply Last reply Reply Quote 0
                    • M
                      MarcO42
                      last edited by MarcO42 Mar 5, 2020, 6:38 PM Mar 4, 2020, 10:13 PM

                      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:
                      login-to-view

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

                      login-to-view
                      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 Apr 24, 2023, 3:08 PM Reply Quote 4
                      • L
                        lastb0isct
                        last edited by Apr 1, 2020, 3:57 PM

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

                        P 1 Reply Last reply Apr 1, 2020, 4:33 PM Reply Quote 0
                        • L
                          luckman212 LAYER 8
                          last edited by Apr 1, 2020, 4:29 PM

                          @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
                          • P
                            provels @lastb0isct
                            last edited by Apr 1, 2020, 4:33 PM

                            @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 Mar 7, 2021, 8:18 PM Reply Quote 0
                            • L
                              lastb0isct
                              last edited by Apr 1, 2020, 4:35 PM

                              Where does the speedtest.py live after installation?

                              P 1 Reply Last reply Apr 1, 2020, 4:40 PM Reply Quote 0
                              • P
                                provels @lastb0isct
                                last edited by Apr 1, 2020, 4:40 PM

                                @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 Apr 8, 2020, 3:23 PM

                                  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 May 19, 2020, 10:54 PM

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

                                    P A A A 4 Replies Last reply May 20, 2020, 9:56 AM Reply Quote 4
                                    • P
                                      provels @aln
                                      last edited by May 20, 2020, 9:56 AM

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

                                      login-to-view

                                      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 May 20, 2020, 3:43 PM Reply Quote 0
                                      • johnpozJ
                                        johnpoz LAYER 8 Global Moderator
                                        last edited by May 20, 2020, 10:44 AM

                                        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.

                                        login-to-view

                                        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.7.2, 24.11

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          aln @provels
                                          last edited by May 20, 2020, 3:43 PM

                                          @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 May 20, 2020, 4:00 PM Reply Quote 1
                                          • First post
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.