#!/bin/sh
#
# Plugin to graph temperatures based on output from ACPI. Needs the
# "acpi" program to work.
#
# Parameters:
#
# 	acpi      - Override path to acpi program
#
#
#%# 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}'
