【问题标题】:How can I avoid getting blank spaces in my RRDTool graphs?如何避免在我的 RRDTool 图表中出现空格?
【发布时间】:2018-04-03 23:54:35
【问题描述】:

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

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

但是,唯一看起来“连续”的图表是 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 之后。

【问题讨论】:

    标签: bash rrdtool


    【解决方案1】:

    如果您选择 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'    
    

    【讨论】:

    • 哇,这个人!谢谢托比。我将按照您的建议重新创建具有更长心跳的.rrds。试一试。我会让它运行几个星期以确定它是否有效。
    • 可能还会将 RRA 定义中的 xff 增加到更高的值。默认值 0.5 通常很好,但如果你得到一些未填充的数据点,那么你可能会得到未知数。也许将其提高到 0.75,看看这是否有帮助。您的图表可能使用的是 60 尺寸的 RRA,因此这可能会有所不同。
    • 我一直在运行 120 秒的心跳,它已经看起来好多了,Odin Absolute Traffic (eth0) 图表的顶部不再有“抖动”......永远不明白为什么不断增加的数量会很小减少,但现在已被消除。我会留意这些图表,并在几天后将其标记为正确。
    • 造成这种影响的原因是,您已经配置了 rras,使得它们需要知道 50% 的基础数据......或者 rra 条目变得未知
    猜你喜欢
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-09
    • 1970-01-01
    • 2012-03-29
    • 1970-01-01
    相关资源
    最近更新 更多