#!@@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_zone' kernel module and the plugin gets the thermal zones from /proc/acpi/thermal_zones/*/ 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 /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 one it will usually 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 0
	}
    done
    echo yes
    exit 0
}

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

exit $?

