如何避免在RRDTool图形中出现空格?

时间:2016-08-02 14:19:27

标签: bash rrdtool

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

我显示36小时,10天,45天和18个月的内容,例如转移数据,CPU温度,平均负载等。

然而,唯一的"连续"看图是10天图,所有其他图都有差距。我以微小的间隔记录每个数据点。

有28(29)张图片,所以我不打算把它们全部放在这里,所以我把它们放在imgur for your perusal

但这是我所谈论的一个例子:

10天的工作正常!

enter image description here

45天,而不是那么多。

enter image description here

这是我的.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之后。

1 个答案:

答案 0 :(得分: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'