#!@@GOODSH@@
# -*- sh -*-

: <<=cut 

=head1 NAME

acpi - Munin plugin to monitor the temperature in different ACPI Thermal zones.

=head1 APPLICABLE SYSTEMS

Linux systems with ACPI support.

=head1 CONFIGURATION

Load the 'thermal' kernel module and the plugin gets the thermal zones from /sys/class/thermal/thermal_zone*/ automagically.

=head1 USAGE

Link this plugin to @@CONFDIR@@/plugins/ and restart the munin-node.

=head1 INTERPRETATION

The plugin shows the temperature from the different thermal zones. 

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=head1 BUGS

None known.

=head1 VERSION

$Id:$

=head1 AUTHOR

Nicolai Langfeldt (janl@linpro.no) 2006-11-13

=head1 LICENSE

GPLv2

=cut


ATZ="$(echo /sys/class/thermal/thermal_zone*)"

do_ () { # Fetch
    for ZONE in $ATZ; do
         TEMP=`cat $ZONE/temp`
         echo `basename $ZONE`.value `echo $TEMP \* 0.001 | bc`
    done
    exit 0
}

do_config () {
    echo "graph_title ACPI Thermal zone temperatures"
    echo "graph_vlabel Celsius"
    echo "graph_category sensors"
    echo "graph_info This graph shows the temperature in different ACPI Thermal zones.  If there is only one it will usually be the case temperature."
    for ZONE in $ATZ; do
         TYPE=`cat $ZONE/type`
         echo `basename $ZONE`.label $TYPE
    done
}

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

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

exit $?

