cd /tmp

echo " Get internet traffic in bytes"
#in=$(/sbin/ifconfig eth1 |grep bytes|cut -d":" -f2|cut -d" " -f1)
out=$(/sbin/ifconfig eth1 |grep bytes|cut -d":" -f3|cut -d" " -f1)

echo "outgoing traffic: "$out " bytes"
echo "uploading data to Pachube"

a='{"version":"1.0.0","datastreams":[{"id":"1", "current_value":"'
b='"}]}'
echo $a$out$b
echo $a$out$b > update.json

# you can create your own pachube account if necessary
curl --request PUT --header "X-PachubeApiKey: qpLG77lHBQVhhJlJ5yAhOAin_CggAaW5tnTVnyGj09k" \
--data-binary @update.json http://api.pachube.com/v2/feeds/58411.json


echo " Now do the same for temperature"
echo " "

i=0
while [ $i -lt 10 ]
do
t=$(cat /sys/bus/w1/drivers/w1_slave_driver/28-000002def034/w1_slave)
crc=$(echo $t | awk -F "YES" '{ print $2; }')
t=$(echo $t | awk -F "t=" '{ print $2; }')
t=$(echo "scale=3;$t/1000" | bc -l)

if [ "$crc" = "" ];then echo "Sensor 1 CRC error, repeating"
else echo "CRC ok, continue" $t
break
fi
echo $i
i=$(($i+1))
done

echo "uploading data to Pachube"
a='{"version":"1.0.0","datastreams":[{"id":"1", "current_value":"'
b='"}]}'
echo $a$t$b
echo $a$t$b > update.json

# you can create your own pachube account if necessary
curl --request PUT --header "X-PachubeApiKey: qpLG77lHBQVhhJlJ5yAhOAin_CggAaW5tnTVnyGj09k" \
--data-binary @update.json http://api.pachube.com/v2/feeds/58412.json


