Kod: Markera allt
#!/usr/bin/perl
use RRDs;
my $cur_time = time();
my $start_time = $cur_time - 86400; # set end time to 24 hours ago
$cur_clk = get_timestamp();
sub get_timestamp {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$mon = $mon+1;
if ($mon < 10) { $mon = "0$mon"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
$year=$year+1900;
return $year . '-' . $mon . '-' . $mday . ' ' . $hour . ':' . $min . ':' . $sec;
}
RRDs::graph "/var/www/graph_vardagsrum.png",
"--start= end-1d",
"--end= now",
"--title= Attarpsbo $cur_clk",
"--height= 768",
"--width= 1024",
"--vertical-label= °C",
"DEF:vardagsrum=/home/bjorn/rrddata/temperature1-5.rrd:data1:AVERAGE",
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#0000FF",
"LINE2:vardagsrum#FF00FF:vardagsrum\t\t",
"GPRINT:vardagsrum:LAST:%6.1lf",
"GPRINT:vardagsrum:AVERAGE:%6.1lf",
"GPRINT:vardagsrum:MAX:%6.1lf",
"GPRINT:vardagsrum:MIN:%6.1lf\\n";
my $err=RRDs::error;
if ($err) {print "problem generating the graph: $err\n";}
print "Done!\n"
Kod: Markera allt
rrdtool graph /var/www/temp/temp.png \
--start -1d --end now --step 300 \
--title "<big><b>Bedroom thermometer</b></big>" \
--vertical-label "Temperature (ºC)" \
--width 800 --height 200 --pango-markup --slope-mode \
--y-grid 0.5:1 \
--right-axis 1:0 --right-axis-format "%2.1lf" \
DEF:bedroomtemp=/var/www/temp/temp.rrd:bedroom:AVERAGE \
LINE1.5:bedroomtemp#FF0000 \
GPRINT:bedroomtemp:LAST:"<b>Last\:</b> %2.2lf ºC" \
GPRINT:bedroomtemp:AVERAGE:"<b>Avg\:</b> %2.2lf ºC" \
GPRINT:bedroomtemp:MIN:"<b>Min\:</b> %2.2lf ºC" \
GPRINT:bedroomtemp:MAX:"<b>Max\:</b> %2.2lf ºC\c" \
VDEF:time=bedroomtemp,LAST \
GPRINT:time:"<b>Last update\:</b> %c\c":strftime