LoginSignup
0
0

More than 3 years have passed since last update.

Raspberry PiにインストールしたArchLinuxでMuninを使ってCPU温度を監視する

Posted at

こんがりラズベリーパイ

Raspberry Piは非常にかわいいシングルボードコンピューターで格安自宅サーバーを営むおっさんを惹きつけてやまないのですが、初期状態ではファンは愚かヒートシンクすらついていないので、常にサーマルスロットリング状態ということも稀によくあるようです。
そこで、CPU温度をグラフ化して監視することにしました。今回はOSにArch Linux、監視ソフトはMunin、WebサーバーはNginxです。Raspberry Pi OSでも大体一緒だと思います。

Mununのセットアップ

まず、必要なソフトをインストールします。

$ sudo pacman -S munin cronie nginx

各種設定

/etc/munin/munin.conf の htmldir を修正

htmldir /srv/http/munin

/etc/nginx/nginx.conf の location / を修正

location / {
    root /srv/http;
    index index.html index.htm;
}

サービスの有効化と起動

$ sudo mkdir -p /srv/http/munin
$ sudo chown munin:munin /srv/http/munin
$ sudo systemctl enable munin-node
$ sudo systemctl start munin-node
$ sudo systemctl enable cronie
$ sudo systemctl start cronie
$ sudo systemctl enable nginx
$ sudo systemctl start nginx
$ sudo crontab /etc/munin/munin-cron-entry -u munin

CPU温度モニタープラグイン

プラグインスクリプトを書きます。
/usr/lib/munin/plugins/cpu_temp

#!/bin/sh

. /usr/lib/munin/plugins/plugin.sh

if [ "$1" = "autoconf" ]; then
    if [ -r /sys/class/thermal/thermal_zone0/temp ];then
        echo yes
        exit 0
    else
        echo "no (missing /sys/class/thermal/thermal_zone0/temp)"
        exit 0
    fi
fi


if [ "$1" = "config" ]; then
    echo graph_title CPU core temperature
    echo graph_args --base 1000  -l 0
    echo graph_info CPU core temperature
    echo graph_category system

    echo temp0.label Core
    echo temp0.cdef temp0,1000,/

    exit 0;
fi

echo temp0.value `cat /sys/class/thermal/thermal_zone0/temp`

シンボリックリンクを張ることでプラグインが有効になります。

$ sudo ln -s /usr/lib/munin/plugins/cpu_temp /etc/munin/plugins/cpu_temp

munin-nodeを再起動します。

$ sudo systemctl restart munin-node

しばらく待ってから、 http://localhost/munin にアクセスします。
CPU core temperatureが表示されるようになっているハズです。
cpu_temp-day.png
お疲れ様でした。

0
0
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
0