Skip to content

Instantly share code, notes, and snippets.

@drscream
Created July 5, 2017 06:54
Show Gist options
  • Save drscream/915a8232e1834c8cf4e1aa09a24c0b15 to your computer and use it in GitHub Desktop.
Save drscream/915a8232e1834c8cf4e1aa09a24c0b15 to your computer and use it in GitHub Desktop.
  1. Install speedtest-cli from pip and be sure pip exists:
$ pkgin in py34-pip
$ pip install speedtest-cli
  1. Configure cronjob to run speedtest-cli every X hours or minutes:
2,42 * * * * /opt/local/bin/speedtest-cli --simple > /tmp/speedtest.tmp && cat /tmp/speedtest.tmp > /tmp/speedtest.out
  1. The file speedtest need to be placed in the plugins folder of munin-node. For example: /opt/local/etc/munin/plugins.
#!/usr/bin/env bash
case $1 in
config)
echo "graph_category network"
echo "graph_title Speedtest"
echo "graph_args --base 1000 -l 0"
echo "graph_vlabel DL / UL"
echo "graph_scale no"
echo "down.label DL (Mbit/s)"
echo "down.type GAUGE"
echo "down.draw LINE1"
echo "up.label UL (Mbit/s)"
echo "up.type GAUGE"
echo "up.draw LINE1"
echo "graph_info Graph of Internet Connection Speed"
exit 0;;
esac
OUTPUT=`cat /tmp/speedtest.out`
DOWNLOAD=`echo "$OUTPUT" | grep Download | sed 's/[a-zA-Z:]* \([0-9]*\.[0-9]*\) [a-zA-Z/]*/\1/'`
UPLOAD=`echo "$OUTPUT" | grep Upload | sed 's/[a-zA-Z:]* \([0-9]*\.[0-9]*\) [a-zA-Z/]*/\1/'`
echo "down.value $DOWNLOAD"
echo "up.value $UPLOAD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment