Created
February 1, 2024 20:21
-
-
Save mtak/a17de661df2271f76cddb07a930244a2 to your computer and use it in GitHub Desktop.
Run Ookla speedtest and post to Graphite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
exec >run_speedtest.log 2>&1 | |
PATH=/home/mtak/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
graphite_server=dom2.int.mtak.nl | |
graphite_port=2003 | |
speedtest=$(/home/mtak/bin/speedtest -f json -u bps) | |
ping_latency=$(echo "$speedtest" | jq .ping.latency) | |
ping_jitter=$(echo "$speedtest" | jq .ping.jitter) | |
ping_min=$(echo "$speedtest" | jq .ping.low) | |
ping_max=$(echo "$speedtest" | jq .ping.high) | |
download_bandwidth=$(echo "$speedtest" | jq .download.bandwidth) | |
upload_bandwidth=$(echo "$speedtest" | jq .upload.bandwidth) | |
packetloss=$(echo "$speedtest" | jq .packetLoss) | |
# metrics: system.internet.speedtest. | |
timestamp=$(date +%s) | |
echo "system.internet.speedtest.ping.latency $ping_latency $timestamp" | nc -N $graphite_server $graphite_port | |
echo "system.internet.speedtest.ping.jitter $ping_jitter $timestamp" | nc -N $graphite_server $graphite_port | |
echo "system.internet.speedtest.ping.min $ping_min $timestamp" | nc -N $graphite_server $graphite_port | |
echo "system.internet.speedtest.ping.max $ping_max $timestamp" | nc -N $graphite_server $graphite_port | |
echo "system.internet.speedtest.download.bandwidth $download_bandwidth $timestamp" | nc -N $graphite_server $graphite_port | |
echo "system.internet.speedtest.upload.bandwidth $upload_bandwidth $timestamp" | nc -N $graphite_server $graphite_port | |
echo "system.internet.speedtest.packetloss $packetloss $timestamp" | nc -N $graphite_server $graphite_port |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment