Skip to content

Instantly share code, notes, and snippets.

@janaz
Created September 12, 2020 12:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janaz/edc26e298e00d8bc172a78eff4bea770 to your computer and use it in GitHub Desktop.
Save janaz/edc26e298e00d8bc172a78eff4bea770 to your computer and use it in GitHub Desktop.
Speedtest script for collectd-exec plugin
#!/bin/sh
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-3600}"
while true; do
result="$(speedtest --csv)"
upload="$(echo "$result" | cut -d, -f8)"
download="$(echo "$result" | cut -d, -f7)"
echo "PUTVAL \"$HOSTNAME/speedtest/upload\" interval=$INTERVAL N:$upload"
echo "PUTVAL \"$HOSTNAME/speedtest/download\" interval=$INTERVAL N:$download"
sleep "$INTERVAL"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment