#!/bin/sh
#------------------------------------------------------------------------------
# OPT_EMBEDDED  /etc/rrdtool/fscpc.val                             __FLI4LVER__
# Creation:     2005-12-23 gdw
# Last Update:  $Id$
# 
# rrdtool fscpc Datenerfassung
#------------------------------------------------------------------------------

[ -z "$RDTOOL_CONF_LOADED" ] && . /var/run/rrdtool.conf

local source=fscpc
eval local idx='$RRDTOOL_'$source'_ID'
eval local options='$RRDTOOL_'$idx'_OPTIONS_STRING'

#  Pfad bei 2.6er Kernel
fscpc_io_path='/sys/class/hwmon/hwmon0/device'

for item in $options
do
    local db_file=$RRDTOOL_DB_PATH/$source/$item.rrd
    value="U"
    case "$item" in
    "temperature")
        [ -f $fscpc_io_path/temp1_input ]&&value1=`sed 's/\([0-9]\{3\}\)$/.\1/' $fscpc_io_path/temp1_input`
        [ -f $fscpc_io_path/temp2_input ]&&value2=`sed 's/\([0-9]\{3\}\)$/.\1/' $fscpc_io_path/temp2_input`
        rrdtool update $db_file \
        N:$value1:$value2
        ;;
    "voltage")
	[ -f $fscpc_io_path/in0_input ]&&value0=`sed 's/\([0-9]\{3\}\)$/.\1/' $fscpc_io_path/in0_input`
	[ -f $fscpc_io_path/in1_input ]&&value1=`sed 's/\([0-9]\{3\}\)$/.\1/' $fscpc_io_path/in1_input`
	[ -f $fscpc_io_path/in2_input ]&&value2=`sed 's/\([0-9]\{3\}\)$/.\1/' $fscpc_io_path/in2_input`
        rrdtool update $db_file \
        N:$value0:$value1:$value2
        ;;
    esac
done
