#!/bin/bash
TEMPO=600

sleep 30
memtot=`free | awk '{ print $1,$2 }' | grep Mem: | cut -d' ' -f2`
curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.MemTotal/$memtot"
echo " MemTotal=$memtot"

while true
 do
   systemp=`vcgencmd measure_temp | cut -d'=' -f2 | awk -F'\x27' '{ print $1 }'`
   memsys=`free | awk '{ print $1,$3 }' | grep Mem: | cut -d' ' -f2`
   tpscpu=`ps aux | awk '{ print $3,$11 }' | grep mono | cut -d' ' -f1`
   memcpu=`ps aux | awk '{ print $4,$11 }' | grep mono | cut -d' ' -f1`
   vszmem=`ps aux | awk '{ print $5,$11 }' | grep mono | cut -d' ' -f1`
   rssmem=`ps aux | awk '{ print $6,$11 }' | grep mono | cut -d' ' -f1`
   curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.Temperature/$systemp"
   echo " SysTemp=$systemp"
   curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.MemUsed/$memsys"
   echo " MemUsed=$memsys"
   curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.LoadMem/$memcpu"
   echo " LoadMem=$memcpu"
   curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.LoadTime/$tpscpu"
   echo " LoadTime=$tpscpu"
   curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.RSSMem/$rssmem"
   echo " RSSMem=$rssmem"
   curl "http://127.0.0.1/api/HomeAutomation.HomeGenie.Automation/CPUData/Sensor.VSZMem/$vszmem"
   echo " VSZMem=$vszmem"
   sleep $TEMPO
 done

