A speedtest plugin for LibreNMS, build with RRD and Ooklas' Speedtest CLI.
Go to file
Sophia Atkinson 8a516b8664 Modernized the plugin
Implemented fixes from Gitlab issues
from Marc Hagen & Trent Robinson (https://gitlab.com/jackgreyhat/librenms-speedtest/-/issues/2)
and fixes from m0nsieur Psych0 (https://gitlab.com/jackgreyhat/librenms-speedtest/-/issues/6)

I added support for darkmode, this is done by generating the graphs with white text, then using CSS to invert the image, for light mode users.

I also moved branding PNGs to vectors for higher resolutions

I will not be opening a PR at https://gitlab.com/jackgreyhat/librenms-speedtest as this seems to have been abbandoned.
2023-09-15 15:59:51 -07:00
images Modernized the plugin 2023-09-15 15:59:51 -07:00
png typos, add png directory etc...small changes:] 2021-01-21 14:44:18 +01:00
rrd typos, add png directory etc...small changes:] 2021-01-21 14:44:18 +01:00
tmp change tmp location 2021-01-21 15:00:13 +01:00
LICENSE Add LICENSE 2021-01-21 13:09:37 +00:00
README.md Update README.md 2021-01-29 08:45:02 +00:00
Speedtest.inc.php Modernized the plugin 2023-09-15 15:59:51 -07:00
Speedtest.php proper code being added again 2021-01-26 15:56:07 +01:00
install.sh Modernized the plugin 2023-09-15 15:59:51 -07:00
librenms-speedtest.sh Modernized the plugin 2023-09-15 15:59:51 -07:00

README.md

LibreNMS Speedtest

A Speedtest plugin for LibreNMS, built with RRD and Speedtest CLI by Ookla

Introduction

This is a plugin that enables internet uplink bandwidth graphing in a LibreNMS dashboard. It uses Ookla servers to perform the speedtest by calling Ookla's Speedtest CLI application. Data is stored in the backend into RRD and is visualized by using a LibreNMS style dashboard. Installation should be pretty straight forward.

Prerequisites

  • A working LibreNMS installation. :D
  • Shell access to the LibreNMS server.
  • Speedtest CLI by Ookla. To install this, use the following link and instructions:
    • https://www.speedtest.net/apps/cli
    • Verify you are running Speedtest CLI by Ookla by issuing the following command on your CLI:
      speedtest --version
      Expected example output:
      Speedtest by Ookla 1.0.0.2
There is also the "speedtest-cli" package, which is possibly provided by your distribution's repository. 
This package, however, does not follow the same cli commands as the Ookla's Speedtest CLI package and is 
built with Python. It is known to under perform in some cases.
This dashboard will not work out of the box with the "speedtest-cli" package. Prefer to install Ookla's package.

Installation

These instructions assume you are the root user. If you are not, prepend sudo 
to the shell commands or temporarily become a user with root privileges.

After logging in to your LibreNMS server CLI:

  • Go to your home dir:
    cd ~/
  • Clone this repository into your home dir:
    git clone https://gitlab.com/jackgreyhat/librenms-speedtest.git
  • Create the plugin directory into LibreNMS plugin folder:
    mkdir /opt/librenms/html/plugins/Speedtest
  • Copy the LibreNMS speedtest plugin contents into the newly created directory:
    cp -r ~/librenms-speedtest/. /opt/librenms/html/plugins/Speedtest
  • Ensure correct ownership and permissions on the Speedtest plugin directory and files:
    chown -R librenms:librenms /opt/librenms/html/plugins/Speedtest
    chmod -R --reference=/opt/librenms/html/plugins /opt/librenms/html/plugins/Speedtest
    chmod +x /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh
  • Create a cron job to run the speedtest periodically. Edit the following file:
    vi /etc/cron.d/librenms
    and add:
    30 * * * * librenms /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh run && /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh graph
  • Switch to the librenms user:
    su - librenms
  • Accept the speedtest EULA and GDPR notice (if applicable) and run an initial speedtest:
    speedtest --accept-license --accept-gdpr
  • Go to the Speedtest plugins directory:
    cd /opt/librenms/html/plugins/Speedtest/
  • Create the RRD files:
    ./librenms-speedtest.sh create
  • Test and run the speedtest script:
    ./librenms-speedtest.sh run
  • Output the speedtest results into PNG files:
    ./librenms-speedtest.sh graph
  • Go to your LibreNMS web interface, and go to "Overview" -> "Plugins" -> "Plugin Admin"
  • Enable the "Speedtest" plugin.
  • Find the "Speedtest" plugin under "Overview" -> "Plugins" -> "Speedtest"
  • Wait at least one hour (2 speedtest runs, one every 30 mins), for data to be properly populated in your graphs.
  • Profit.

FAQs

Most of the below FAQs are related to how the speedtest command can be adjusted. All of these commands or adjustments must be made to the speedtest command on line 37 in the librenms-speedtest.sh script. In the future, I will make it easier to adjust settings.

  • How can I select a speedtest server manually?
    Use speedtest -L to find the nearest speedtest servers, note the first column, this is the speedtest server id.
    Adjust the speedtest command on line 37 to include the server id with the -s parameter, so it looks like this:
    speedtest --accept-license --accept-gdpr -p no -s 1234 > $SpeedtestResultDir/speedtest-results 2>/dev/null

Roadmap

  • Include more metrics, such as:
    • Jitter during tests
    • Transfered data during test
    • Packet loss during test
  • Add other speedtest providers, such as:
    • Cloudflare
    • Fast.com
    • ...