はじめに
SPEEDTEST CLI
- 「Speedtest CLI - Internet connection measurement for developers」の「Install Options」で「Ubuntu/Debian」をクリック
- 表示された以下を実行
$ curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
$ sudo apt-get install speedtest
- 定期実行
$ sudo crontab -e
...
18,38,58 * * * * /usr/bin/speedtest --server-id=7139 --format=csv > /usr/share/munin/plugins/speedtest.out 2>&1
...
Munin
- プラグイン作成
$ cd /usr/share/munin/plugins
$ sudo nano speedtest
speedtest
#!/bin/bash
case $1 in
config)
echo "graph_category network"
echo "graph_title Speedtest"
echo "graph_args -l 0 -u 1000000000 -r"
echo "graph_vlabel download / upload (bps)"
echo "down.label download"
echo "down.type GAUGE"
echo "down.draw LINE1"
echo "up.label upload"
echo "up.type GAUGE"
echo "up.draw LINE1"
echo "graph_info Graph of Internet Connection Speed"
exit 0;;
esac
OUTPUT=`/usr/bin/cat /usr/share/munin/plugins/speedtest.out`
DOWNLOAD=`echo "$OUTPUT" | /usr/bin/cut -d ',' -f 6 | /usr/bin/sed 's/"//g'`
DOWNLOAD=`echo $((DOWNLOAD*8))`
UPLOAD=`echo "$OUTPUT" | /usr/bin/cut -d ',' -f 7 | /usr/bin/sed 's/"//g'`
UPLOAD=`echo $((UPLOAD*8))`
echo "down.value $DOWNLOAD"
echo "up.value $UPLOAD"
- プラグイン有効化
$ sudo chmod 755 speedtest
$ sudo ln -s /usr/share/munin/plugins/speedtest /etc/munin/plugins/speedtest
$ sudo /etc/init.d/munin-node restart
- Webブラウザで http://debian/munin/localdomain/localhost.localdomain/speedtest.html を表示
- 土日と平日夕方~夜の落ち込みが激しい・・・