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
RRDs::graph "/var/www/graph_temp.png",
"--start= $start_time",
"--end= $cur_time",
"--title= Temp ute",
"--height= 300",
"--width= 500",
"--vertical-label= °Celsius",
"DEF:OutsideTemp=/home/pi/rrddata/outside_temp.rrd:outsidetemp:AVERAGE:",
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#FF0000",
"LINE1:OutsideTemp#FF0000: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:insideTemp=/home/pi/rrddata/inside_temp.rrd:insidetemp:AVERAGE:",
"LINE3:insideTemp#0000FF:Inne\t\t",
"GPRINT:insideTemp:LAST:%6.1lf",
"GPRINT:insideTemp:AVERAGE:%6.1lf",
"GPRINT:insideTemp:MAX:%6.1lf",
"GPRINT:insideTemp:MIN:%6.1lf\\n";
my $err=RRDs::error;
if ($err) {print "problem generating the graph: $err\n";}
print "Done!\n"
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
RRDs::graph "/var/www/graph_temp.png",
"--start= $start_time",
"--end= $cur_time",
"--title= Temp ute",
"--height= 300",
"--width= 500",
"--vertical-label= °Celsius",
"DEF:OutsideTemp=/home/pi/rrddata/outside_temp.rrd:outsidetemp:AVERAGE:",
"DEF:insideTemp=/home/pi/rrddata/inside_temp.rrd:insidetemp:AVERAGE:",
"COMMENT:\t\t\t\tNu Medel Max Min\\n",
"HRULE:0#FF0000",
"LINE1:OutsideTemp#FF0000:Ute\t\t\t",
"GPRINT:OutsideTemp:LAST:%6.1lf",
"GPRINT:OutsideTemp:AVERAGE:%6.1lf",
"GPRINT:OutsideTemp:MAX:%6.1lf",
"GPRINT:OutsideTemp:MIN:%6.1,
"LINE2:insideTemp#0000FF:Inne\t\t",
"GPRINT:insideTemp:LAST:%6.1lf",
"GPRINT:insideTemp:AVERAGE:%6.1lf",
"GPRINT:insideTemp:MAX:%6.1lf",
"GPRINT:insideTemp:MIN:%6.1lf\\n";
my $err=RRDs::error;
if ($err) {print "problem generating the graph: $err\n";}
print "Done!\n"
Kod: Markera allt
#!/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/"
filename1="outside_temp.rrd"
filename2="inside_temp.rrd"
# Check i file already exists
if [ ! -f "$directory$filename" ]
then
# File doesn't exist, create new rrd-file
echo "Creating RRDtool DB for outside temp sensor"
rrdtool create $directory$filename1 \
--step 150 \
DS:outsidetemp: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:24:175200 \
RRA:MAX:0.5:1:5760 \
RRA:MAX:0.5:2:2016 \
RRA:MAX:0.5:4:52560 \
RRA:MAX:0.5:24:175200 \
RRA:MIN:0.5:1:5760 \
RRA:MIN:0.5:2:2016 \
RRA:MIN:0.5:4:52560 \
RRA:MIN:0.5:24:175200
echo "Done!"
echo "Creating RRDtool DB for inside temp sensor"
rrdtool create $directory$filename2 \
--step 150 \
DS:insideTemp: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:24:175200 \
RRA:MAX:0.5:1:5760 \
RRA:MAX:0.5:2:2016 \
RRA:MAX:0.5:4:52560 \
RRA:MAX:0.5:24:175200 \
RRA:MIN:0.5:1:5760 \
RRA:MIN:0.5:2:2016 \
RRA:MIN:0.5:4:52560 \
RRA:MIN:0.5:24:175200
echo "Done!"
else
echo $directory$filename" already exists, delete it first."
fi
Kod: Markera allt
#!/bin/bash
OutsideTempSensor="28.434695040000"
insideTempSensor="28.476395040000"
RRDDataDirectory="/home/pi/rrddata/"
RRDDataFile1="outside_temp.rrd"
RRDDataFile2="inside_temp.rrd"
# Get temps form OWFS
OutsideTemp=`cat /mnt/1wire/$OutsideTempSensor/temperature|sed -e s/" "//g|awk '{$1=$1 + 0.005;printf "%.2f", $1}'`
insideTemp=`cat /mnt/1wire/$insideTempSensor/temperature|sed -e s/" "//g|awk '{$1=$1 + 0.005;printf "%.2f", $1}'`
#Update RRD database
rrdtool update $RRDDataDirectory$RRDDataFile1 N:$OutsideTemp
rrdtool update $RRDDataDirectory$RRDDataFile2 N:$insideTemp
echo $OutsideTemp
echo $insideTemp