RRDtool data inconsistency -


i using rrdtool graph status of pump on raspberry pi. must doing configuration wrong, since values close inputting, not exact.

the pin status should either 1 or 0.

<!-- 2014-03-10 10:24:00 cdt / 1394465040 --> <row><v>nan</v></row> <!-- 2014-03-10 10:25:00 cdt / 1394465100 --> <row><v>nan</v></row> <!-- 2014-03-10 10:26:00 cdt / 1394465160 --> <row><v>1.0000000000e+00</v></row> <!-- 2014-03-10 10:27:00 cdt / 1394465220 --> <row><v>2.3711630000e-01</v></row> <!-- 2014-03-10 10:28:00 cdt / 1394465280 --> <row><v>9.8168226667e-01</v></row> <!-- 2014-03-10 10:29:00 cdt / 1394465340 --> <row><v>1.6624716667e-02</v></row> <!-- 2014-03-10 10:30:00 cdt / 1394465400 --> <row><v>9.8544061667e-01</v></row> <!-- 2014-03-10 10:31:00 cdt / 1394465460 --> <row><v>2.9590616667e-02</v></row> <!-- 2014-03-10 10:32:00 cdt / 1394465520 --> <row><v>9.7204963333e-01</v></row> <!-- 2014-03-10 10:33:00 cdt / 1394465580 --> <row><v>2.6263616667e-02</v></row> <!-- 2014-03-10 10:34:00 cdt / 1394465640 --> <row><v>9.7533411667e-01</v></row> <!-- 2014-03-10 10:35:00 cdt / 1394465700 --> <row><v>2.3075633333e-02</v></row> <!-- 2014-03-10 10:36:00 cdt / 1394465760 --> <row><v>9.7849575000e-01</v></row> <!-- 2014-03-10 10:37:00 cdt / 1394465820 --> <row><v>1.9948233333e-02</v></row> <!-- 2014-03-10 10:38:00 cdt / 1394465880 --> <row><v>9.8158333333e-01</v></row> <!-- 2014-03-10 10:39:00 cdt / 1394465940 --> <row><v>1.6888216667e-02</v></row> <!-- 2014-03-10 10:40:00 cdt / 1394466000 --> <row><v>9.2141166667e-01</v></row> <!-- 2014-03-10 10:41:00 cdt / 1394466060 --> <row><v>5.2411610000e-01</v></row> <!-- 2014-03-10 10:42:00 cdt / 1394466120 --> <row><v>5.2411610000e-01</v></row> <!-- 2014-03-10 10:43:00 cdt / 1394466180 --> <row><v>9.6672030000e-01</v></row> <!-- 2014-03-10 10:44:00 cdt / 1394466240 --> <row><v>5.0939110833e-01</v></row> <!-- 2014-03-10 10:45:00 cdt / 1394466300 --> <row><v>5.0939110833e-01</v></row> <!-- 2014-03-10 10:46:00 cdt / 1394466360 --> <row><v>4.9845539167e-01</v></row> <!-- 2014-03-10 10:47:00 cdt / 1394466420 --> <row><v>4.9845539167e-01</v></row> <!-- 2014-03-10 10:48:00 cdt / 1394466480 --> <row><v>9.9399037500e-01</v></row> <!-- 2014-03-10 10:49:00 cdt / 1394466540 --> <row><v>9.9399037500e-01</v></row> <!-- 2014-03-10 10:50:00 cdt / 1394466600 --> <row><v>2.6977033333e-02</v></row> <!-- 2014-03-10 10:51:00 cdt / 1394466660 --> <row><v>9.7898348333e-01</v></row> <!-- 2014-03-10 10:52:00 cdt / 1394466720 --> <row><v>9.7898348333e-01</v></row>

create_db.sh #!/bin/bash rrdtool create pinstats.rrd \ --step 60 \ ds:pump:gauge:600:0:1 \ rra:max:0.5:1:2016

update.sh

#!/bin/sh a=0 while [ "$a" == 0 ]; echo "pump ondate" /home/pi/on.sh /home/pi/graph.sh pump=1 rrdtool update pinstats.rrd n:$pump sleep 60 echo "pump offdate" /home/pi/off.sh /home/pi/graph.sh pump=0 rrdtool update pinstats.rrd n:$pump sleep 120 done

you being affected data normalisation.

this adjust values according linear approximation in order make time point lie on interval boundary. ie, if interval 5min, updated value @ 12:00, 12:05, 12:10 ... etc

this makes sense if graphing large number rate; overall averages still work out , data @ regular intervals. however, if using gauge data type small integers becomes problematic.

in order avoid this, have update on interval boundary rather using n time point.

try shell code:

interval=60 timestamp=`date +%s` num_intervals=`expr $timestamp / $interval` adjusted_time=`expr $num_intervals '*' $interval` rrdtool update pistats.rrd $adjusted_time:1 sleep $interval adjusted_time=`expr $adjusted_time + $interval` rrdtool update pistats.rrd $adjusted_time:0 

this code ensures update times on interval boundary, , hence no data normalisation performed (actually, becomes null operation).

for more details, see alex van den bogaerdt's excellent tutorial here.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -