#!/bin/bash

declare -a core;
declare -a tmp;
i=0
for line in `sensors -A | grep -o "Core \([0-9]*\): *+\([0-9.]*\)" | sed 's/ /_/g'`; do
	core[$i]=${line%%:*}
        temp[$i]=${line##*+}
	i=$(($i+1))
done
iterator=`seq 0 $((${#temp[*]}-1))`;

. $MUNIN_LIBDIR/plugins/plugin.sh

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

# If run with the "config"-parameter, give out information on how the
# graphs should look.

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

        # The host name this plugin is for. (Can be overridden to have
        # one machine answer for several)

        # The title of the graph
        echo 'graph_title Core Temperature'
        echo 'graph_category temperature'
	for i in $iterator; do
		echo "${core[$i]:1}.label ${core[$i]/_/ }"
        done
        exit 0
fi

for i in $iterator; do
	echo "${core[$i]:1}.value ${temp[$i]}"
done
