#!/bin/sh
#
# Plugin to graph temperatures based on output from ACPI. Needs the
# "acpi" program to work.
#
# Parameters:
#
# 	acpi      - Override path to acpi program
#
#
# $Log$
# Revision 1.6  2004/10/19 19:14:18  jimmyo
# Plugin generic/acpi now autodetects even if the acpi version does not contain the acpi_available program.
#
# Revision 1.5  2004/09/14 20:47:34  jimmyo
# Updated/simplified plugin.
#
# Revision 1.4  2004/05/20 19:02:36  jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.3  2004/05/14 21:16:46  jimmyo
# "Upped" som plugins from contrib/manual to auto.
#
# Revision 1.2  2004/05/14 20:32:06  jimmyo
# Improved autoconf mechanism
#
# Revision 1.1  2004/05/06 21:39:54  jimmyo
# Added plugin acpi, contributed by Alexandre Dupouy.
#
#
#%# family=auto
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
	acpi_available 2>/dev/null >/dev/null || ${acpi:-acpi} -t -B 2>/dev/null >/dev/null
        if [ "$?" = "0" ]; then
		acpi -t -B 2>/dev/null | grep '\d' >/dev/null 2>/dev/null
		if [ "$?" = "0" ]; then
		    echo yes
		    exit 0
		fi
		echo "no (thermal not supported by ACPI)"
		exit 1
	else
		echo "no (ACPI program not found)"
		exit 2
	fi
fi

if [ "$1" = "config" ]; then

        echo 'graph_title CPU temperature'
        echo 'graph_args --base 1000 -l 0'
        echo 'graph_vlabel temp in C'
        echo 'graph_category sensors'
		echo 'graph_info This graph shows temperatures based on output from ACPI.'
        echo cpu.label cpu
		echo cpu.info CPU temperature.
        exit 0
fi

${acpi:-acpi} -t -B | awk '{print "cpu.value " $4}'
