#!/bin/bash

case $1 in
   config)
        cat <<'EOM'
graph_title Temperature
graph_vlabel temperature
graph_category environment
container_temp.label container
magic_temp.label MAGIC
container_temp.warning 40
container_temp.critical 45
container_temp.min 0
magic_temp.min 0
EOM
        exit 0;;
esac


DATA=`curl -s "http://10.0.100.234/statusjsn.js?components=18179&_=1365876572736"`

RC=$?

if [ "$RC" == "0" ] ; then

     . /etc/munin/plugins/ticktick.sh

     tickParse "$DATA"

     VAL1=``sensor_values[0].values[0][0].v``
     MIN1=``sensor_values[0].values[0][0].st[0]``
     MAX1=``sensor_values[0].values[0][0].st[1]``

     echo container_temp.value $VAL1

fi


VAL2=`wget -q -O- http://www.magic.iac.es/site/weather/weather_data.txt | grep TE | cut -c3-`

RC=$?

if [ "$RC" == "0" ] ; then

    echo magic_temp.value $VAL2

fi
