#!/bin/sh
#
# Plugin to graph temperatures based on i5k_amb-isa-0000 FB-DIMM sensor
#
# Parameters:
#
# 	
#
#%# family=auto
#%# capabilities=autoconf

SENSORS="/usr/bin/sensors"

if [ "$1" = "autoconf" ]; then
	# testing if the i5k FB-DIMM sensors are working. (0->working)
	RETVAL=`$SENSORS -A i5k_amb-isa-0000|grep -q DIMM; echo $?`
	if [ $RETVAL = 0 ]; then
		echo yes
		exit 0
	else
		echo "no (i5k FB-DIMM sensors not working.)"
		exit 1
	fi
fi

if [ "$1" = "config" ]; then
	echo 'graph_title FB-DIMM temperature'
	echo 'graph_args --base 1000 -l 0'
	echo 'graph_vlabel temp in °C'
	echo 'graph_category sensors'
	echo 'graph_info This graph shows FB-DIMM temperatures based on reports generated by intel 5000 series chipsets.'
	echo fbdimmtemp.info FB-DIMM temperature.
	$SENSORS -A i5k_amb-isa-0000|grep DIMM|tr -d ":+"|awk -F "." '{print $2}'|awk '{print "ch"$1"dimm"$3".label Channel "$1" DIMM "$3}'
	exit 0
fi

$SENSORS -A i5k_amb-isa-0000|grep DIMM|tr -d ":+"|awk -F "." '{print $2}'|awk '{print "ch"$1"dimm"$3".value "$4}'
