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

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

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

#  Pfad bei 2.6er Kernel
soekris_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 /proc/driver/soekris_temp ]&&value=`grep "Temp 2" /proc/driver/soekris_temp | cut -d" " -f4`
        [ -f $soekris_io_path/temp3_input ]&&value=`sed 's/\([0-9]\{3\}\)$/.\1/' $soekris_io_path/temp3_input`
        rrdtool update $db_file \
        N:$value
        ;;
    "voltage")
        [ -f /proc/driver/soekris_voltage ]&&value=`grep VPWR /proc/driver/soekris_voltage | cut -d" " -f2`
        [ -f $soekris_io_path/in3_input ]&&value=`echo $(expr '(' $( cat $soekris_io_path/in3_input|cut -d" " -f1 ) '*' 201 + 50 ')' '/' 100 )| sed 's/\([0-9]\{2\}\)$/.\1/'`
        rrdtool update $db_file \
        N:$value
        ;;
    esac
done
