如何避免在我的 RRDTool 图表中出现空白?

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

我已经创建了很多 RRDTool 图表来监控 Raspberry Pi 服务器的各个方面。

我显示的是 36 小时、10 天、45 天和 18 个月的传输数据、CPU 温度、平均负载等

然而,唯一 "continuous" 看起来的图表是 10 天图表,所有其他图表都存在差距。我正在以分钟为间隔记录每个数据点。

共有 28 (29) 张图片,所以我不会把它们都放在这里,所以我把它们放在了 imgur for your perusal

但这里有一个我正在谈论的例子:

10 天没问题!

45 天,没那么多。

这是我的 .rrd 创建脚本:

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'    

我的整个绘制脚本有 900 多行,所以我只在这里包含一组图形的实际绘制代码($RRDTOOL 是一个包含路径 /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\:'  

是的,我知道其中一张图上的标题是错误的,我已经修复了,但只有在将所有图像保存到 imgur 之后。

如果您选择 60 秒的 --step,我会选择 120 秒的 mrhb 而不是 60 秒,因为 rrdtool 将忽略任何间隔超过 60 秒的更新。

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'