Search code examples
bashrrdtool

How can I avoid getting blank spaces in my RRDTool graphs?


I've created quite a few RRDTool graphs monitoring various aspects of a Raspberry Pi server.

I'm displaying 36 hours, 10 days, 45 days and 18 months for things like transferred data, CPU temperature, load averages etc.

However, the only "continuous" looking graphs are the 10-day graphs, all the others have gaps in them. I'm recording each data point at a minutely interval.

There are 28 (29) images, so I'm not going to put them all here, so I've put them on imgur for your perusal

But here's an example of what I'm talking about:

10-days works fine!

enter image description here

45-days, not so much.

enter image description here

Here's my .rrd creation script:

rrdtool create data.rrd         \
--start N --step '60'           \
'DS:rx:GAUGE:60:0:U'            \
'DS:tx:GAUGE:60:0:U'            \
'DS:rxc:COUNTER:60:0:U'         \
'DS:txc:COUNTER:60:0:U'         \
'DS:wrx:GAUGE:60:0:U'           \
'DS:wtx:GAUGE:60:0:U'           \
'DS:wrxc:COUNTER:60:0:U'        \
'DS:wtxc:COUNTER:60:0:U'        \
'RRA:AVERAGE:0.5:1:129600'      \
'RRA:AVERAGE:0.5:2:64800'       \
'RRA:AVERAGE:0.5:60:14400'      \
'RRA:AVERAGE:0.5:300:12960'     \
'RRA:AVERAGE:0.5:3600:13140'    

rrdtool create load.rrd         \
--start N                       \
--step '60'                     \
'DS:load:GAUGE:60:0:4'          \
'RRA:AVERAGE:0.5:1:129600'      \
'RRA:AVERAGE:0.5:2:64800'       \
'RRA:AVERAGE:0.5:60:14400'      \
'RRA:AVERAGE:0.5:300:12960'     \
'RRA:AVERAGE:0.5:3600:13140'    

rrdtool create mem.rrd          \
--start N                       \
--step '60'                     \
'DS:mem:GAUGE:60:0:100'         \
'RRA:AVERAGE:0.5:1:129600'      \
'RRA:AVERAGE:0.5:2:64800'       \
'RRA:AVERAGE:0.5:60:14400'      \
'RRA:AVERAGE:0.5:300:12960'     \
'RRA:AVERAGE:0.5:3600:13140'    

rrdtool create pitemp.rrd       \
--start N                       \
--step '60'                     \
'DS:pitemp:GAUGE:60:U:U'        \
'RRA:AVERAGE:0.5:1:129600'      \
'RRA:AVERAGE:0.5:2:64800'       \
'RRA:AVERAGE:0.5:60:14400'      \
'RRA:AVERAGE:0.5:300:12960'     \
'RRA:AVERAGE:0.5:3600:13140'    

My entire draw script is like over 900 lines long, so I'll just include the actual draw code here for one set of graphs ($RRDTOOL is a variable containing the path /usr/bin/rrdtool):

$RRDTOOL graph /var/www/html/images/graphs/data36h.png                  \
--title 'Odin Absolute Traffic (eth0)'                                  \
--watermark "Graph Drawn `date`"                                        \
--vertical-label 'Bytes'                                                \
--lower-limit '0'                                                       \
--rigid                                                                 \
--alt-autoscale                                                         \
--units=si                                                              \
--width '640'                                                           \
--height '300'                                                          \
--full-size-mode                                                        \
--start end-36h                                                         \
'DEF:rx=/usr/local/bin/system/data.rrd:rx:AVERAGE'                      \
'CDEF:cleanrx=rx,UN,PREV,rx,IF'                                         \
'DEF:tx=/usr/local/bin/system/data.rrd:tx:AVERAGE'                      \
'AREA:rx#00CC00FF:Download\:'                                           \
'GPRINT:rx:LAST:\:%8.2lf %s]'                                           \
'STACK:tx#0000FFFF:Upload\:'                                            \
'GPRINT:tx:LAST:\:%8.2lf %s]\n'

$RRDTOOL graph /var/www/html/images/graphs/data10d.png                  \
--title 'Odin Absolute Traffic (eth0) 10 days'                          \
--watermark "Graph Drawn `date`"                                        \
--vertical-label 'Bytes'                                                \
--lower-limit '0'                                                       \
--rigid                                                                 \
--alt-autoscale                                                         \
--units=si                                                              \
--width '640'                                                           \
--height '300'                                                          \
--full-size-mode                                                        \
--start end-10d                                                         \
'DEF:rx=/usr/local/bin/system/data.rrd:rx:AVERAGE'                      \
'DEF:tx=/usr/local/bin/system/data.rrd:tx:AVERAGE'                      \
'AREA:rx#00CC00FF:Download\:'                                           \
'GPRINT:rx:LAST:\:%8.2lf %s]'                                           \
'STACK:tx#0000FFFF:Upload\:'                                            \
'GPRINT:tx:LAST:\:%8.2lf %s]\n'

$RRDTOOL graph /var/www/html/images/graphs/data45d.png                  \
--title 'Odin Absolute Traffic (eth0) 45 days'                          \
--watermark "Graph Drawn `date`"                                        \
--vertical-label 'Bytes'                                                \
--lower-limit '0'                                                       \
--rigid                                                                 \
--alt-autoscale                                                         \
--units=si                                                              \
--width '640'                                                           \
--height '300'                                                          \
--full-size-mode                                                        \
--start end-45d                                                         \
'DEF:rx=/usr/local/bin/system/data.rrd:rx:AVERAGE'                      \
'DEF:tx=/usr/local/bin/system/data.rrd:tx:AVERAGE'                      \
'AREA:rx#00CC00FF:Download\:'                                           \
'GPRINT:rx:LAST:\:%8.2lf %s]'                                           \
'STACK:tx#0000FFFF:Upload\:'                                            \

$RRDTOOL graph /var/www/html/images/graphs/data18m.png                  \
--title 'Odin Absolute Traffic (eth0) 18 month'                         \
--watermark "Graph Drawn `date`"                                        \
--vertical-label 'Bytes'                                                \
--lower-limit '0'                                                       \
--rigid                                                                 \
--alt-autoscale                                                         \
--units=si                                                              \
--width '640'                                                           \
--height '300'                                                          \
--full-size-mode                                                        \
--start end-1y6m                                                        \
'DEF:rx=/usr/local/bin/system/data.rrd:rx:AVERAGE'                      \
'DEF:tx=/usr/local/bin/system/data.rrd:tx:AVERAGE'                      \
'AREA:rx#00CC00FF:Download\:'                                           \
'GPRINT:rx:LAST:\:%8.2lf %s]'                                           \
'STACK:tx#0000FFFF:Upload\:'  

And yes, I know that the title on one of the graphs is wrong, I've fixed that, but only after saving all the images to imgur.


Solution

  • If you choose a --step of 60 seconds, I would choose a mrhb of 120s and not also of 60s because rrdtool will disregard any updates that are more than 60s apart.

    rrdtool create data.rrd         \
    --start N --step '60'           \
    'DS:rx:GAUGE:120:0:U'            \
    'DS:tx:GAUGE:120:0:U'            \
    'DS:rxc:COUNTER:120:0:U'         \
    'DS:txc:COUNTER:120:0:U'         \
    'DS:wrx:GAUGE:120:0:U'           \
    'DS:wtx:GAUGE:120:0:U'           \
    'DS:wrxc:COUNTER:120:0:U'        \
    'DS:wtxc:COUNTER:120:0:U'        \
    'RRA:AVERAGE:0.5:1:129600'      \
    'RRA:AVERAGE:0.5:2:64800'       \
    'RRA:AVERAGE:0.5:60:14400'      \
    'RRA:AVERAGE:0.5:300:12960'     \
    'RRA:AVERAGE:0.5:3600:13140'