Files
opt/collectd/usr/local/bin/speedtest-data
2024-12-23 10:54:34 +01:00

16 lines
582 B
Bash
Executable File

#!/bin/bash
SPEEDTEST=/usr/bin/speedtest-cli
COLLECTION=server
INTERVAL=900
while :; do
SECONDS=0
RESULT=($($SPEEDTEST | grep Mbit | cut -d' ' -f 2))
TIMESTAMP=$(date +%s)
#echo "PUTVAL $COLLECTION/exec-speedtest/gauge-download interval=$INTERVAL N:${RESULT[0]}"
#echo "PUTVAL $COLLECTION/exec-speedtest/gauge-upload interval=$INTERVAL N:${RESULT[1]}"
echo "PUTVAL $COLLECTION/exec-speedtest/gauge-download ${TIMESTAMP}:${RESULT[0]}"
echo "PUTVAL $COLLECTION/exec-speedtest/gauge-upload ${TIMESTAMP}:${RESULT[1]}"
sleep $((INTERVAL-$SECONDS))
done