[rrd-users] rrdtool - manually creating a rrd database with multiple records
Simon Hobson
linux at thehobsons.co.uk
Sun Dec 13 10:33:16 CET 2009
skaarj wrote:
>I'm trying to run a simulation for an university project. The graph must
>have 9 records (I am monitoring 9 parameters from 3 different rivers -
>"quantity of rain fallen", "level" and "quantity of water which flows".
>
>I got some numbers from some simulating software someone wrote in C. The
>following script is used for creating and updating a rrd database:
>
>#!/bin/bash
>rm -rf rivers.rrd
>rrdtool create rivers.rrd \
>--start 1260399480 \
>--step 300 \
>DS:rain_river0:GAUGE:600:1:450 \
>DS:level_river0:GAUGE:600:40:450 \
>DS:flow_river0:GAUGE:600:1:459 \
>DS:rain_river1:GAUGE:600:1:450 \
>DS:level_river1:GAUGE:600:40:450 \
>DS:flow_river1:GAUGE:600:2:450 \
>DS:rain_river2:GAUGE:600:1:450 \
>DS:level_river2:GAUGE:600:40:450 \
>DS:flow_river2:GAUGE:600:2:450 \
>RRA:AVERAGE:0.5:12:24 \
>RRA:AVERAGE:0.5:288:31
>
>
>rrdtool update rivers.rrd --template
>rain_river0:level_river0:flow_river0:rain_river1:level_river1:flow_river1:rain_river2:level_river2:flow_river2
>\
>1260399486:1:171:7.08:1.5:113:26.51:1:191:24.12 \
>1260399786:7:189:20:2.41:101:16.19:3.11:202:30.31 \
>1260400086:16:214:44.1:2.41:100:15.63:3.11:200:29.25 \
>1260400386:23:244:83.94:11:164:94.11:3.07:2.14:38.11 \
>1260400686:13:227:59.74:6.25:148:47.56:7.39:309:115.43 \
>1260400986:19:234:69.61:18.07:193:155.15:13.57:362:169.35 \
>1260401286:19:234:69.61:18.07:193:159.88:13.57:362:169.35 \
>1260401586:17:221:52.22:60.15:175:116.74:14.7:367:174.74 \
>1260401886:14:223:55.17:15.11:187:140.16:18.93:120:254.06 \
>1260402186:10:223:55.1:11.49:190:148.96:15.03:120:282 \
>1260402486:7:223:55.17:7.42:185:133.62:12.14:120:326.01 \
>1260402786:5:223:55.10:5.22:184:135.42:8.68:120:325.79 \
>1260403086:2:223:54.53:1.92:17.9:123.5:5.11:120:474.56 \
>1260403386:1:198:28.55:1.15:154:77.51:1.75:363:170.2 \
>1260403686:1:191:22.04:1.15:143:59.83:1.75:325:131.37 \
>1260403986:1:189:20.24:1.15:140:54.95:1.75:314:120.65 \
>1260404286:1:207:37.73:1.10:165:97.58:1:322:128.51 \
>1260404586:1:197:28.24:1.10:151:73.05:1:288:96.2 \
>1260404886:1:196:26.62:1.10:149:68.84:1:282:90.66 \
>1260405186:1:194:24.54:1.10:145:63.47:1:270.4:83.6 \
>1260405486:1:192:23.09:1.10:143:59.73:1:269:37.66 \
>1260405786:1:192:23.04:1.10:143:59.6:1:268:70.48 \
>1260406086:1:191:22.23:1.10:141:57.48:1:265:75.71 \
>1260406386:2:190:20.99:2.20:140:54.31:2:260:71.52 \
>1260406686:2:195:25.97:2.18:148:67.16:2:279:88.45 \
>1260406986:4:198:28.35:5.22:160:87.1:4.37:298:105.39 \
>
>
>time for creating the database is 1260399480, stepping is 300 seconds.
>
>start time for entering data is 1260399486, then data is entered with
>initial time + 300 seconds.
OK, first of all, go to http://www.vandenbogaerdt.nl/rrdtool/ and
read Alex's tutorial on normalisation. Then realise that ALL periods
in rrd are referenced to unix epoch (ie midnight on 1st Jan 1970
UTC). Since 1260399486 (Wed 9 Dec 2009 22:58:06 GMT) is not
divisible by 300, then the data will be normalised to steps that
start and end on timestamps which are divisible by 300. The same
applies to aggregations, by aggregating 12 steps you will reduce the
data to slots that start and end on whole hours - eg 11am, not 10:47
am.
>now: rrdtool fetch does NOT provide any data from the rrd database. I just
>have the header line with all the DS names, then two rows each with a
>timestamp which I cannot find in the input lines, each row displays "nan"
>(not a number?) 9 times.
Did you specify a resolution or time period when fetching the data ?
It's quite possible that rrd is trying to give you the larger
aggregation (288 steps, 24 hours). If that is the case, then you
simply don't have enough data for the results to be valid - you need
at least 12 hours worth of data (0.5 x 24hr) - and the rows would
have timestamps of 1260316800 and 1260403200.
In case you are wondering, GNU Date has a useful feature of being
able to work with these dates. "date -r n" will convert from n
seconds after epoch into a readable date, and "date '+%s'" will
format a date in seconds since epoch.
--
Simon Hobson
Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.
More information about the rrd-users
mailing list