Hey guys! Ever wondered how to check your internet speed directly from your Proxmox server? Well, you're in the right place! In this guide, we'll walk you through installing Speedtest CLI on Proxmox. It's super useful for diagnosing network issues or just keeping an eye on your connection. Let's dive in!

    Why Install Speedtest CLI on Proxmox?

    Before we jump into the installation process, let's talk about why you might want to do this in the first place. Proxmox is a powerful virtualization platform, and sometimes you need to troubleshoot network performance directly from the host. Here’s why Speedtest CLI is a great tool:

    • Direct Speed Testing: You can measure the internet speed directly on the Proxmox server without relying on VMs or other devices.
    • Troubleshooting: If you're experiencing slow network speeds in your VMs, testing directly on the host can help you identify whether the issue is with the host's connection or the VM's configuration.
    • Automation: You can script Speedtest CLI to run regularly and log the results, giving you a historical view of your network performance.
    • Resource Efficiency: CLI tools are generally lightweight, meaning they won't hog your server's resources compared to a full-fledged GUI application.

    Having Speedtest CLI on your Proxmox server is like having a network diagnostic tool right at your fingertips. It's especially handy for those of us who like to keep a close eye on our server's performance and ensure everything is running smoothly.

    Prerequisites

    Before we get started, make sure you have the following:

    • Proxmox Server: Obviously, you need a Proxmox server up and running.
    • SSH Access: You'll need SSH access to your Proxmox server.
    • Root or Sudo Privileges: You'll need to be able to run commands with root or sudo privileges.
    • Internet Connection: A stable internet connection on your Proxmox server.

    These prerequisites are pretty basic, but it's always good to double-check before you start any installation. Now that we've got that covered, let's move on to the actual installation!

    Step-by-Step Installation Guide

    Alright, let's get down to business! Follow these steps to install Speedtest CLI on your Proxmox server:

    Step 1: Update Your Package List

    First, you'll want to update your package list to make sure you have the latest information about available packages. Open your terminal and SSH into your Proxmox server. Then, run the following command:

    apt update
    

    This command updates the list of available packages and their versions, ensuring you're working with the most current information. It's always a good practice to run this before installing any new software.

    Step 2: Install Dependencies

    Speedtest CLI requires a few dependencies to run properly. Let's install those now. Run the following command:

    apt install apt-transport-https ca-certificates curl gnupg debian-keyring
    

    This command installs the necessary packages for handling HTTPS repositories and verifying the authenticity of the Speedtest CLI package. These dependencies are essential for a secure and smooth installation process.

    Step 3: Add the Speedtest CLI Repository

    Next, we need to add the Speedtest CLI repository to your system's package sources. This tells your system where to find the Speedtest CLI package. Run the following commands:

    curl -s https://install.speedtest.net/app/cli/install.gpg.key | gpg --dearmor | tee /usr/share/keyrings/speedtestcli.gpg > /dev/null
    
    echo "deb [signed-by=/usr/share/keyrings/speedtestcli.gpg] https://install.speedtest.net/app/cli stable main" | tee /etc/apt/sources.list.d/speedtestcli.list
    

    The first command downloads the GPG key for the Speedtest CLI repository and adds it to your system's keyring. The second command adds the Speedtest CLI repository to your system's package sources. This ensures that your system trusts the packages from the Speedtest CLI repository.

    Step 4: Update Package List Again

    Now that we've added the Speedtest CLI repository, we need to update the package list again to include the new repository. Run the following command:

    apt update
    

    This command updates the package list, including the Speedtest CLI repository we just added. This ensures that your system is aware of the Speedtest CLI package and its dependencies.

    Step 5: Install Speedtest CLI

    Finally, we're ready to install Speedtest CLI! Run the following command:

    apt install speedtest
    

    This command downloads and installs the Speedtest CLI package from the Speedtest CLI repository. Once the installation is complete, you'll be able to run Speedtest CLI from your terminal.

    Step 6: Verify the Installation

    To make sure everything is installed correctly, run the following command:

    speedtest --version
    

    This command displays the version of Speedtest CLI that is installed on your system. If you see a version number, congratulations! You've successfully installed Speedtest CLI on your Proxmox server.

    How to Use Speedtest CLI

    Now that you've installed Speedtest CLI, let's talk about how to use it. It's pretty straightforward. Just open your terminal and run the following command:

    speedtest
    

    This command runs a speed test and displays the results in your terminal. You'll see your download speed, upload speed, and ping time. It's that simple!

    Additional Options

    Speedtest CLI also has a few additional options you can use to customize your speed tests. Here are a few examples:

    • speedtest --server [server ID]: This option allows you to specify a specific server to test against. You can find a list of server IDs by running speedtest --list.
    • speedtest --bytes: This option displays the results in bytes instead of bits.
    • speedtest --no-upload: This option skips the upload test.
    • speedtest --no-download: This option skips the download test.
    • speedtest --accept-license: This option automatically accepts the license agreement.

    These options can be useful for tailoring your speed tests to your specific needs. For example, if you're only interested in your download speed, you can use the --no-upload option to save time.

    Automating Speed Tests

    One of the coolest things about Speedtest CLI is that you can automate it to run regularly and log the results. This can be super useful for tracking your network performance over time. Here's how you can do it:

    Step 1: Create a Script

    First, create a script that runs the speed test and logs the results. Here's an example script:

    #!/bin/bash
    
    DATE=$(date +"%Y-%m-%d %H:%M:%S")
    DOWNLOAD=$(speedtest --accept-license --no-upload | grep Download: | awk '{print $2}')
    UPLOAD=$(speedtest  --accept-license --no-download | grep Upload: | awk '{print $2}')
    PING=$(speedtest  --accept-license | grep Ping: | awk '{print $2}')
    
    echo "$DATE, $PING, $DOWNLOAD, $UPLOAD" >> /var/log/speedtest.log
    

    This script runs a speed test, extracts the download speed, upload speed and ping, and logs the results to a file called /var/log/speedtest.log. Make sure to adjust the path to the log file to your liking.

    Step 2: Make the Script Executable

    Next, make the script executable by running the following command:

    chmod +x /path/to/your/script.sh
    

    Replace /path/to/your/script.sh with the actual path to your script.

    Step 3: Create a Cron Job

    Finally, create a cron job to run the script regularly. Open the crontab editor by running the following command:

    crontab -e
    

    Then, add a line to the crontab file that specifies when to run the script. For example, to run the script every hour, add the following line:

    0 * * * * /path/to/your/script.sh
    

    Replace /path/to/your/script.sh with the actual path to your script. Save the crontab file and exit the editor.

    Now, your script will run automatically according to the schedule you specified in the crontab file. You can then analyze the log file to track your network performance over time.

    Troubleshooting

    Sometimes, things don't go as planned. Here are a few common issues you might encounter and how to fix them:

    • speedtest: command not found: This means that the Speedtest CLI executable is not in your system's PATH. Make sure that the /usr/bin directory is included in your PATH environment variable.
    • Error retrieving speedtest.net configuration: This could be due to a DNS resolution issue. Try setting the DNS server in /etc/resolv.conf to a public DNS server like Google's (8.8.8.8 or 8.8.4.4).
    • Slow Speed Test Results: This could be due to a variety of factors, such as network congestion, server issues, or problems with your internet connection. Try running the speed test at different times of the day to see if the results improve.

    If you encounter any other issues, feel free to ask for help in the comments section. We're always happy to help!

    Conclusion

    And there you have it! You've successfully installed Speedtest CLI on your Proxmox server and learned how to use it to test your network speed. You've also learned how to automate speed tests and troubleshoot common issues. Now you can keep a close eye on your network performance and ensure that everything is running smoothly. Happy testing!