Munin + Raspberry Pi + temperature: updated

I got a mail in my inbox about a week ago from Anthony, telling me how to improve my Munin & temp script for a RPi:

Hi,

I just read your (old) blog post about monitoring the temperature of the Raspberry Pi with munin[1].

I had the exact same error as you did when I was trying to let munin do the job all by himself:

> temp.value VCHI initialization failed)

It turns out the solution was quite easy: in

/etc/munin/plugin-conf.d/munin-node

You simply need to tell munin that it needs to run as root for this specific plugin:

> [pisense_]

> user root

(the plugins also tracks clock speeds and voltages but any other will work just fine as long as the “user root” is set in the munin-node plugin config file : [2]). Probably the easiest way to check if it’s working is to use munin-run command before and after the change.

“Demo”: [3]

By the way, “Connect different LANs over openVPN” is pretty tempting, I always wondered what the performances would be like through a USB-to-ethernet adapter.

Have a nice one !

Apteno

[1] https://yeri.be/munin-raspberry-pi-temperature
[2] https://github.com/perception101/pisense/blob/master/pisense_
[3] http://ronon.jefter.com/jefter.com/adama.jefter.com/index.html#sensors

And indeed, I knew it was a permission issue, but instead of running this script as root, I tried adding Munin to a group that was supposed to be able to run  vcgencmd (which didn’t work out).

But, let’s look at a simpler solution:

  1. Go to /etc/munin/plugins and create a file temp with this content (and some indentation yourself):
    #!/bin/sh
    case $1 in
    config)
    cat <<'EOM'
    graph_category system
    graph_title Temperature
    graph_vlabel temp
    temp.label Celsius
    EOM
    exit 0;;
    esac
    echo -n "temp.value "
    /opt/vc/bin/vcgencmd measure_temp | cut -d "=" -f2 | cut -d "'" -f1
  2. As you noticed, this doesn’t require any more scripts to run from cron (and thus, in case you used my previous script, remove it from cron)
  3. chmod +x temp
  4. Make sure it runs as root; in /etc/munin/plugin-conf.d create the file temp.conf with this content:
    [temp]
    user root
  5. Test it:
    # munin-run temp
    temp.value 59.5

Tadaaaa. Simpler.

Thanks Anthony 🙂

3 comments

  1. Only 1 error
    /etc/munin/plugins/temp

    #!/bin/sh
    case $1 in
    config)
    cat <<'EOM'
    graph_category system
    graph_title Temperature
    graph_vlabel temp
    temp.label Celsius
    EOM
    exit 0;;
    esac
    echo -n "temp.value "
    /opt/vc/bin/vcgencmd measure_temp | cut -d "=" -f2 | cut -d "'" -f1

  2. Yeri Tiete says:

    Thanks, updated. Missed it when editing the html.

  3. Alexandre Detiste says:

    this also works with a recent kernel
    echo `cat /sys/class/thermal/thermal_zone0/temp`.0 / 1000 | bc

Leave a Reply...