speedporter/README.md

75 lines
1.9 KiB
Markdown

# Speedporter
A simple daemon that executes the [Ookla Speedtest CLI](https://www.speedtest.net/apps/cli)
and exposes the metrics via a Prometheus Exporter.
## Usage
The following environment variables can be used to configure the daemon:
| Name | Default | Description |
| --- | --- | --- |
| `SPEEDTEST_METRICS_LISTEN_PORT` | `9090` | Which port to bind to for serving metrics |
| `SPEEDTEST_METRICS_LISTEN_ADDR` | `0.0.0.0` | Which address to bind to for serving metrics |
| `SPEEDTEST_PERIOD_MINS` | `5` | How often to run the test |
| `SPEEDTEST_EXEC` | `/usr/bin/speedtest` | The Path to the Ookla Speedtest Executable |
### Exported Prometheus Metrics
| Name | Unit | Description |
| --- | --- | --- |
| `isp_download_speed` | Mb/s | Download Bandwidth |
| `isp_upload_speed` | Mb/s | Upload Bandwidth |
| `isp_ping_latency` | ms | Internet Connection Latency |
| `isp_packet_loss` | % | Percentage of Packets Lost During Test |
### Example Visualization
![Example Grafana Dashboard](./dashboard-example.png)
This example Grafana dashboard is available to use in your instance
[here](./grafana_dashboard.json).
## Dependencies
Install the [Ookla Speedtest CLI](https://www.speedtest.net/apps/cli)
### Build Dependencies
- `go`
## Build/Installation
- `git clone https://git.sdf.org/CRThaze/speedporter`
- `cd speedporter`
- `go build`
- Copy `speedporter` executable to the desired installation location. Perhaps one of:
- `/usr/local/bin`
- `/opt/speedporter`
- `~/.local/bin`
### SystemD Daemon
Here's an example Unit File you can use for SystemD
```
[Unit]
Description=Speedtest Metrics Reporter
After=network.target
[Service]
Type=simple
ExecStart=/opt/speedporter/speedporter
Restart=always
RestartSec=10
Environment="SPEEDTEST_METRICS_LISTEN_PORT=9091"
[Install]
WantedBy=default.target
```
- Create this unit file in `/etc/systemd/system/speedporter.service`
- Then run: `systemctl enable speedporter`
- And start it with: `systemctl start speedporter`