#!/bin/sh
#
# ACPI Thermal zone plugin for munin.
#   - Nicolai Langfeldt (janl@linpro.no) 2006-11-13
# License: GPL
#
#%# family=auto
#%# capabvilities=autoconf

ATZ="$(echo /proc/acpi/thermal_zone/*/temperature)"

do_ () { # Fetch
    echo "$ATZ" | tr ' ' '\n' | awk -F'[ /\t]*' '{
         ZONE=$5
         getline < $0
         print ZONE"_value "$2
    }'
    exit 0
}

do_config () {
    echo "graph_title ACPI Thermal zone temperatures"
    echo "graph_vlabel Celcius"
    echo "graph_category sensors"
    echo "graph_info This graph shows the temperature in different ACPI Thermal zones.  If there is only on it will usualy be the case temperature."
    echo "$ATZ" |
    awk -F'[ /]' '{
         print $5".label "$5;
    }'
                  
}

do_autoconf () {
    for f in $ATZ; do
	test -r $f || {
	    echo "no (cannot read $f)"
	    exit 1
	}
    done
    echo yes
    exit 0
}

case $1 in
    config|autoconf|'')
	eval do_$1
esac
