• 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

Scheduled Pinned Locked Moved pfSense Packages
167 Posts 52 Posters 138.8k 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.
  • G
    getrav
    last edited by Jan 17, 2014, 10:57 PM

    I have nanobsd I don't know if the instructions would be different for normal installation
    I found the speedtest code https://github.com/sivel/speedtest-cli

    Login thru SSH

    /etc/rc.conf_mount_rw
    setenv PKG_TMPDIR /root/
    pkg_add -r http://files.pfsense.org/packages/8/All/python26-2.6.6.tbz
    fetch -o /root/speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
    chmod +x /root/speedtest-cli
    /etc/rc.conf_mount_ro
    

    To run speedtest after installation:

    /root/speedtest-cli
    

    for help type:

    /root/speedtest-cli -h
    
    A 1 Reply Last reply May 21, 2020, 2:10 PM Reply Quote 0
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Jan 27, 2014, 7:22 PM

      That looks nice, though it's usually better to test bandwidth through the firewall and not from the firewall itself. pfSense has been optimized to work in a routing role, so sometimes you might see reduced numbers when pfSense itself is acting like the client.

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      C S 2 Replies Last reply May 22, 2020, 7:13 PM Reply Quote 0
      • F
        fholzer
        last edited by Aug 27, 2014, 10:22 AM

        Just my 50Cents,

        It would be nice to have this Feature via GUI.
        I now its better to test the Speed through the firewall and not from the firewall itself.

        But in many cases i need to test it from the pfsense itself.
        (no - or limited access to the clients)

        Generally i would use it to test if the WAN Connection give me the 16Mbit the customer had buyed or if the connection is below 10MBit (or lower)

        regards,

        Franz

        1 Reply Last reply Reply Quote 0
        • P
          pfBlense
          last edited by May 10, 2015, 3:23 AM

          Just a brief update for people using pfSense 2.2+. Instead of using pkg_add you now need to do:

          pkg update
          pkg install python
          

          Thanks for the post on this!!

          1 Reply Last reply Reply Quote 0
          • N
            nikkon
            last edited by May 12, 2015, 8:01 AM

            Got this on 2.2
            On a 1000 Mbit/s connection i barely get 350.20 Mbit/s on my setup.
            is there any way to tweak network settings and improve this?

            pfsense 2.3.4 on Supermicro A1SRi-2758F + 8GB ECC + SSD

            Happy PfSense user :)

            1 Reply Last reply Reply Quote 0
            • Z
              Zaphon
              last edited by May 13, 2015, 1:41 PM

              @nikkon:

              Got this on 2.2
              On a 1000 Mbit/s connection i barely get 350.20 Mbit/s on my setup.
              is there any way to tweak network settings and improve this?

              Well as was suggested, don't run this on the box, run it behind the box.  Also, your speed through the box is going to vary greatly based on the type of NIC's you have and the speed of your CPU.  I had a computer that had a pair of Realtek nic's on the motherboard (single core box, about 6-7 years old, makes a great little router), and with gigabit I was maxing out in the 300-400Mbit range.  I bought a dual port Intel NIC and now I'm pushing in the 995Mbit range (this is tested from behind the box to a server on the other side in a lab).  However if the box is much more recent, has a nice fast CPU, your mileage may vary.

              1 Reply Last reply Reply Quote 0
              • N
                nikkon
                last edited by May 13, 2015, 2:47 PM

                in any case i tested the speed via iperf from my box to a miktorik switch and i got 1Gbit/s full
                I suspect 2 things:

                • ISP - they came once and tested with another machie…worked well
                • pppoe performance

                pfsense 2.3.4 on Supermicro A1SRi-2758F + 8GB ECC + SSD

                Happy PfSense user :)

                1 Reply Last reply Reply Quote 0
                • L
                  luckman212 LAYER 8
                  last edited by May 20, 2015, 1:35 AM

                  @getrav:

                  …I found the speedtest code...

                  Wanted to thank you for posting this. Today I used this to do a remote speed test at a site where I did not have physical access to nor any remote access to a machine behind the firewall.  The vendor needed us to confirm that a speed increase had been implemented by the ISP and this was the perfect tool for this. Got the job done and saved us a few hours of travel time for what amounted to a 5 minute test.

                  Thank you 8)

                  1 Reply Last reply Reply Quote 1
                  • F
                    floz
                    last edited by Oct 24, 2015, 6:42 PM

                    Thanks for this, exactly what I was looking for.

                    Just my little 2 cents how to get this working on pfSense 2.2 and later.

                    
                    #/etc/rc.conf_mount_rw
                    setenv PKG_TMPDIR /root/
                    pkg install python27-2.7.10_1
                    ln -s /usr/local/bin/python2 /usr/local/bin/python
                    pkg_add -r http://files.pfsense.org/packages/8/All/python26-2.6.6.tbz
                    fetch -o /root/speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
                    chmod +x /root/speedtest-cli
                    #/etc/rc.conf_mount_ro
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • D
                      doktornotor Banned
                      last edited by Oct 24, 2015, 7:09 PM

                      Or just use 2.2.5; python is already there.

                      
                      $ file /usr/local/bin/python2.7
                      /usr/local/bin/python2.7: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 10.1, stripped
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • A
                        ariyako
                        last edited by Aug 3, 2016, 7:33 AM

                        curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
                        chmod +x speedtest-cli

                        nano speedtest-cli

                        change

                        #!/usr/bin/env python
                        

                        to

                        #!/usr/local/bin/python2.7
                        

                        ;)

                        1 Reply Last reply Reply Quote 0
                        • M
                          mdmogren
                          last edited by Dec 23, 2016, 8:20 PM

                          Just wanted to post this update here for others who use this tool - it is now a package and can be installed using

                          
                          pkg install py27-speedtest-cli
                          
                          

                          Then just run

                          ./usr/local/bin/speedtest-cli
                          
                          1 Reply Last reply Reply Quote 0
                          • S
                            Smoothrunnings
                            last edited by Jan 25, 2017, 3:00 PM

                            Is there no GUI version of this?

                            My ubnt USG Pro has a speed tester app on it's firewall GUI. I don't see how it's anymore complicated to get one for Pfsense.

                            Thanks,

                            1 Reply Last reply Reply Quote 0
                            • J
                              jimp Rebel Alliance Developer Netgate
                              last edited by Jan 25, 2017, 3:07 PM

                              @Smoothrunnings:

                              Is there no GUI version of this?

                              My ubnt USG Pro has a speed tester app on it's firewall GUI. I don't see how it's anymore complicated to get one for Pfsense.

                              Thanks,

                              No, because speed testing from the firewall itself is inaccurate and unreliable. We don't want to encourage people to rely on bad data. See my previous response on this thread.

                              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                              Need help fast? Netgate Global Support!

                              Do not Chat/PM for help!

                              1 Reply Last reply Reply Quote 0
                              • A
                                authenticx
                                last edited by Mar 24, 2017, 3:52 PM

                                Actually this is a good thing to use if you suspect your switch or cabling may be contributing to a loss of bandwidth.  This would narrow the points of failure to your firewall, the connection between your firewall and gateway and the gateway itself.  If you have a large difference between what this cli test reports and what you see in a speed test from your pc you just gained valuable troubleshooting information.

                                1 Reply Last reply Reply Quote 1
                                • L
                                  luckman212 LAYER 8
                                  last edited by Mar 24, 2017, 4:02 PM

                                  I agree. It can have the standard YMMV/caveat attached, but I have gotten a ton of useful information from having the speedtest_cli pkg installed on my remote units. In my testing, a C2xxxx CPU is more than capable of pulling 400-500Mbps directly with this tool. Very useful!

                                  1 Reply Last reply Reply Quote 0
                                  • I
                                    icewraithuk
                                    last edited by May 6, 2017, 7:34 PM

                                    I use this to keep my ISP honest, which is a trick in itself :) For those that are interested here's my hack:

                                    Go to www.thingspeak.com and register for a free account, create a channel with three fields (I only care about ping, DL and UL, you may want more), go to the API page and make a note of your write API.

                                    Do the stuff to get speedtest on your firewall, run a speedtest and note which server it decides is your local/fastest - I use the one hosted by my ISP, for example. Then run a speedtest –list | grep <your chosen="" server="" name="">to get the ID (eg. speedtest --list | grep Virgin in my case)

                                    Run a speedtest --server <the id="" you="" found="">--csv to test

                                    Edit the speedtest.py file and add these bits - note, this isn't clean or clever, I've gone with functional!

                                    • Under the other import lines at the top:
                                    import urllib2
                                    
                                    myAPI="<your api="" key="" goes="" here,="" in="" the="" quotes="">"
                                    baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI
                                    print baseURL</your>
                                    

                                    Then go down to around line 700 and look for the CSV output section, add the lines with -> below

                                    def csv(self, delimiter=','):
                                            """Return data in CSV format"""
                                    
                                            data = self.dict()
                                            out = StringIO()
                                            writer = csv.writer(out, delimiter=delimiter, lineterminator='')
                                            row = [data['server']['id'], data['server']['sponsor'],
                                                   data['server']['name'], data['timestamp'],
                                                   data['server']['d'], data['ping'], data['download'],
                                                   data['upload']]
                                            writer.writerow([to_utf8(v) for v in row])
                                    ->      f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (self.ping, self.download, self.upload))
                                    ->      print f.read()
                                    ->      f.close ()
                                            return out.getvalue()
                                    

                                    Now run speedtest.py –server 1234 --csv and wait for it to finish, now check on ThingSpeak and check your three fields now have data.

                                    I then put the command in my crontab:

                                    */30 * * * * /usr/local/bin/python2.7 speedtest.py --server 1234 --csv >/dev/null 2>&1
                                    
                                    

                                    and now every 30 minutes my firewall does a speed test and updates ThingSpeak, which I can check the lovely graphs and make sure I'm relatively consistently getting decent metrics.</the></your>

                                    cukalC provelsP K P 4 Replies Last reply Aug 12, 2018, 2:14 AM Reply Quote 4
                                    • S
                                      Sergestux
                                      last edited by Feb 11, 2018, 6:53 PM

                                      @mdmogren:

                                      Just wanted to post this update here for others who use this tool - it is now a package and can be installed using

                                      
                                      pkg install py27-speedtest-cli
                                      
                                      

                                      Then just run

                                      ./usr/local/bin/speedtest-cli
                                      

                                      Gracias era lo que buscaba

                                      1 Reply Last reply Reply Quote 0
                                      • cukalC
                                        cukal @icewraithuk
                                        last edited by Aug 12, 2018, 2:14 AM

                                        @icewraithuk What a great hack & thanks for letting me discover ThingSpeak!

                                        I changed the output from bits/sec to Mbit/sec:

                                        f = urllib2.urlopen(baseURL + "&field1=%s&field2=%s&field3=%s" % (self.ping, int(self.download) / 1048576, int(self.upload) / 1048576))
                                        
                                        1 Reply Last reply Reply Quote 2
                                        • S
                                          S762
                                          last edited by Feb 16, 2019, 2:55 PM

                                          Sorry, I know this is an old topic but how to I uninstall this package? I used the following to install but don't see it listed under the package manager and would like to remove it.

                                          pkg install py27-speedtest-cli
                                          
                                          1 Reply Last reply Reply Quote 1
                                          • First post
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                                            [[user:consent.lead]]
                                            [[user:consent.not_received]]