Svårt att förklara men om jag kör en graf med temperaturen de senaste 12 månaderna så får jag inte med alla värden.. så lägsta/högsta stämmer ej..
Kolla här så ser ni:
http://www.gordalen.nu/sv/html.asp?ID=277
Vill ju ha det korrewkta "min"-värdet tex även om grafen visar de senaste 10 åren... Eller går det att ta ut min-värdet ur rrdtool på annat sätt?
min kod för skapande av rrd databas:
#!/bin/bash
# Script to create rrd-file
# 24h with 2,5 min resolution
# 7d with 5 min resolution
# 1y with 10 min resolution
# 20y with 1h resolution
directory="/home/pi/rrddata/"
filename="temp_gordalen_new.rrd"
# Check i file already exists
#if [ ! -f "$directory$filename" ]
#then
# File doesn't exist, create new rrd-file
echo "Creating RRDtool DB for temp sensors"
rrdtool create $directory$filename \
--step 150 \
DS:outsidetemp:GAUGE:300:-50:60 \
DS:watertemp:GAUGE:300:-50:60 \
DS:extrasensor:GAUGE:300:-50:60 \
RRA:AVERAGE:0.5:1:576 \
RRA:AVERAGE:0.5:2:2016 \
RRA:AVERAGE:0.5:4:52560 \
RRA:AVERAGE:0.5:4:175200 \
RRA:MAX:0.5:1:5760 \
RRA:MAX:0.5:2:2016 \
RRA:MAX:0.5:4:52560 \
RRA:MAX:0.5:4:175200 \
RRA:MIN:0.5:1:5760 \
RRA:MIN:0.5:2:2016 \
RRA:MIN:0.5:4:52560 \
RRA:MIN:0.5:4:175200
echo "Done!"
#else
# echo $directory$filename" already exists, delete it first."
#fi
Min kod för att skapa graf för 24 timmar:
#!/usr/bin/perl
use POSIX qw(strftime);
my $displaydate= strftime('%Y-%m-%d %H:%M:%S', localtime);
use RRDs;
my $cur_time = time();
my $start_time = $cur_time - 86400; # set end time to 24 hours ago
RRDs::graph "/home/pi/rrddata/graph_temp.png",
"--start= $start_time",
"--end= $cur_time",
"--title= Temperatur www.Gordalen.nu 24h - $displaydate$
"--height= 300",
"--width= 500",
"--vertical-label=Celcius",
"DEF:outsidetemp=/home/pi/rrddata/temp_gordalen.rrd:outsidetemp:A$
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#858585",
"LINE2:outsidetemp#0000FF:Temp ute\t\t\t",
"GPRINT:outsidetemp:LAST:%6.1lf",
"GPRINT:outsidetemp:AVERAGE:%6.1lf",
"GPRINT:outsidetemp:MAX:%6.1lf",
"GPRINT:outsidetemp:MIN:%6.1lf\\n",
"DEF:watertemp=/home/pi/rrddata/temp_gordalen.rrd:watertemp:AVERAGE",
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#858585",
"LINE2:watertemp#FF0000:Temp vatten\t\t\t",
"GPRINT:watertemp:LAST:%6.1lf",
"GPRINT:watertemp:AVERAGE:%6.1lf",
"GPRINT:watertemp:MAX:%6.1lf",
"GPRINT:watertemp:MIN:%6.1lf\\n";
my $err=RRDs::error;
if ($err) {print "problem generating the graph: $err\n";}
print "Done!\n"
Min kod för graf 12 mån:
#!/usr/bin/perl
use POSIX qw(strftime);
my $displaydate= strftime('%Y-%m-%d %H:%M:%S', localtime);
use RRDs;
my $cur_time = time();
my $start_time = $cur_time - 31556926; # set end time to 24 hours ago
RRDs::graph "/home/pi/rrddata/graph_temp_1y.png",
"--start= $start_time",
"--end= $cur_time",
"--title= Temperatur 1 year www.Gordalen.nu - $displayd$
"--height= 300",
"--width= 500",
"--vertical-label=Celcius",
"DEF:outsidetemp=/home/pi/rrddata/temp_gordalen.rrd:outsidetemp:A$
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#858585",
"LINE2:outsidetemp#0000FF:Temp ute\t\t\t",
"GPRINT:outsidetemp:LAST:%6.1lf",
"GPRINT:outsidetemp:AVERAGE:%6.1lf",
"GPRINT:outsidetemp:MAX:%6.1lf",
"GPRINT:outsidetemp:MIN:%6.1lf\\n",
"DEF:watertemp=/home/pi/rrddata/temp_gordalen.rrd:watertemp:AVERAGE",
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#858585",
"LINE2:watertemp#FF0000:Temp vatten\t\t\t",
"GPRINT:watertemp:LAST:%6.1lf",
"GPRINT:watertemp:AVERAGE:%6.1lf",
"GPRINT:watertemp:MAX:%6.1lf",
"GPRINT:watertemp:MIN:%6.1lf\\n";
my $err=RRDs::error;
if ($err) {print "problem generating the graph: $err\n";}
print "Done!\n"