#!/bin/bash
#
# maggic 2003/05/07
#
# http://meteo.maggic.org

# configuration
# fichier rrd - path to the rrd file
rrdfile=/usr/local/frogd/data/frogd.rrd

# repertoire ou seront ecrites les images
# path where you want the images to be generated
htmldir=/var/www/html/rrd/graph

rrdpath=""
# programme, ne pas editer apres cette ligne
# don't edit after this line
let nbsecond=3600*$1
date=$(date)

$rrdpath/rrdtool graph $htmldir/temp_$1.png --imgformat PNG --lazy -s -$nbsecond --title=Température -v "Température" \
          DEF:tempe=$rrdfile:temp:AVERAGE \
          LINE2:tempe#ff0000:"°C" \
	  GPRINT:tempe:LAST:"Actuelle\: %.1lf " \
          GPRINT:tempe:MIN:"Min\: %.1lf " \
          GPRINT:tempe:MAX:"Max\: %.1lf "\
          GPRINT:tempe:AVERAGE:"Moyenne\: %.1lf\j" \
	  COMMENT:\\n \
 	  COMMENT:"$date\r"

$rrdpath/rrdtool graph $htmldir/press_$1.png --imgformat PNG --lazy -s -$nbsecond --title=Pression -v "Pression" \
          --units-exponent 0 \
          DEF:presse=$rrdfile:press:AVERAGE \
          LINE2:presse#0000ff:"hPa"  \
	  GPRINT:presse:LAST:"Actuelle\: %.1lf " \
	  GPRINT:presse:MIN:"Min\: %.1lf " \
	  GPRINT:presse:MAX:"Max\: %.1lf " \
	  GPRINT:presse:AVERAGE:"Moyenne\: %.1lf\j" \
	  COMMENT:\\n \
 	  COMMENT:"$date\r"          
          
$rrdpath/rrdtool graph $htmldir/hum_$1.png --imgformat PNG --lazy -s -$nbsecond --title=Humidité -v "Humidité" \
          DEF:hume=$rrdfile:hum:AVERAGE \
          LINE2:hume#00a000:"% HR"  \
	  GPRINT:hume:LAST:"Actuelle\: %.1lf " \
	  GPRINT:hume:MIN:"Min\: %.1lf " \
	  GPRINT:hume:MAX:"Max\: %.1lf " \
	  GPRINT:hume:AVERAGE:"Moyenne\: %.1lf\j" \
	  COMMENT:\\n \
 	  COMMENT:"$date\r" 

