Har skapat databasen så här:
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/temp/rrddata/"
filename="domoticz_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$filename \
--step 120 \
DS:probe:GAUGE:120:-50:60 \
DS:xxxx1:GAUGE:120:-50:60 \
DS:vardagsrum:GAUGE:120:-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
rrdtool update /home/pi/temp/rrddata/domoticz_temp.rrd --template probe N:`head -n 1 </home/pi/temp/output/temp_probe.txt`
Koden för att skapa grafer:
Kod: Markera allt
#!/bin/bash
rrdtool graph /home/pi/temp/output/img/test/hour.png \
-w 697 -h 287 -a PNG \
--slope-mode \
--start -6h --end now \
--vertical-label "Last 6 hour temperature" \
DEF:probe=/home/pi/temp/rrddata/domoticz_temp.rrd:probe:AVERAGE \
DEF:xxxx1=/home/pi/temp/rrddata/domoticz_temp.rrd:xxxx1:AVERAGE \
DEF:vardagsrum=/home/pi/temp/rrddata/domoticz_temp.rrd:vardagsrum:AVERAGE \
COMMENT:" Location Min Max Senaste\l" \
LINE1:probe#ff0000:"Utetemp" \
LINE1:0#ff0000: \
GPRINT:probe:MIN:" %5.1lf" \
GPRINT:probe:MAX:" %5.1lf" \
GPRINT:probe:LAST:" %5.1lf\n" \
LINE1:xxxx1#00ff00:"Xxxx1" \
LINE1:0#00ff00: \
GPRINT:probe:MIN:" %5.1lf" \
GPRINT:probe:MAX:" %5.1lf" \
GPRINT:probe:LAST:" %5.1lf\n" \
LINE1:vardagsrum#0000ff:"vardagsrum" \
LINE1:0#0000ff: \
GPRINT:probe:MIN:" %5.1lf" \
GPRINT:probe:MAX:" %5.1lf" \
GPRINT:probe:LAST:" %5.1lf\n" \
Har provat att göra så här men då blir grafen helt tokig/korrupt. Vad har jag missat??
Hoppas det finns någon kunnig människa här inne som kan hjälpa till.
Kod: Markera allt
#!/bin/bash
rrdtool update /home/pi/temp/rrddata/domoticz_temp.rrd --template probe N:`head -n 1 </home/pi/temp/output/temp_probe.txt`
rrdtool update /home/pi/temp/rrddata/domoticz_temp.rrd --template xxxx1 N:`head -n 1 </home/pi/temp/output/temp_xxxx1.txt`