0
2

More than 3 years have passed since last update.

SPEEDTEST CLIの結果をMuninで記録

Last updated at Posted at 2021-05-30

はじめに

SPEEDTEST CLI

$ 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

参考

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2