问题描述
我已经创建了一个特定时间的rrd文件.但是,当我将其转换为xml时,我发现开始时间与指定的时间不一致.
I had created a rrd file with a specific time. But when i convert it into xml, i find the start time is inconsitent with the specified time.
rrdtool的版本为1.5.5.
The version of rrdtool is 1.5.5.
代码是
> rrdtool create abc.rrd \
> step 15 --start 1554122342 \ DS:sum:GAUGE:120:U:U \ RRA:AVERAGE:0.5:1:5856 \ RRA:AVERAGE:0.5:4:20160 \
> RRA:AVERAGE:0.5:40:52704
前几行就像
> <!-- 2019-03-31 20:15:15 CST / 1554034515 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:15:30 CST / 1554034530 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:15:45 CST / 1554034545 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:16:00 CST / 1554034560 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:16:15 CST / 1554034575 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:16:30 CST / 1554034590 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:16:45 CST / 1554034605 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:17:00 CST / 1554034620 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:17:15 CST / 1554034635 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:17:30 CST / 1554034650 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:17:45 CST / 1554034665 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:18:00 CST / 1554034680 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:18:15 CST / 1554034695 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:18:30 CST / 1554034710 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:18:45 CST / 1554034725 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:19:00 CST / 1554034740 --> <row><v>NaN</v></row>
> <!-- 2019-03-31 20:19:15 CST / 1554034755 --> <row><v>NaN</v></row>
我尝试了其他参数,例如默认值(now-10s),但是间隔大约是一天.
I tried other parameters such as the default(now-10s), but the interval is about one day.
推荐答案
(下面的示例已使用RRDTool 1.5.5进行了测试)
(My example below tested with RRDTool 1.5.5)
您的RRA大约为1年,每10分钟间隔一次;设置了15秒的RRD.
Your RRA is approximately 1 year long, in 10min intervals; with a 15s set up the RRD.
创建RRD时,start
时间是最近数据点或最后一次更新的时间;换句话说,您不能在此之前的任何时间添加任何数据. RRA将始终以unknown
初始化.
When you create an RRD, the start
time is the time of the most recent data point or last update; in other words, you cannot add any data for a time earlier than this. The RRA will be initialised with unknown
throughout.
因此,当您使用以下方法创建RRD时:
So, when you create your RRD with:
rrdtool create abc.rrd --step 15 --start 1554122342 \
DS:sum:GAUGE:120:U:U RRA:AVERAGE:0.5:40:52704`
您可以使用rrdtool info
看到此内容(为清楚起见,对输出进行了修剪):
you can see this using rrdtool info
(output trimmed for clarity):
$ rrdtool info abc.rrd
filename = "abc.rrd"
...
last_update = 1554122342
然后当您使用rrdtool dump
立即查看RRA的内容时,您可以看到它开始于大约一年之前:
When you then use rrdtool dump
to immediately view the content of the RRA, you can see that it starts about a year earlier:
$ rrdtool dump abc.rrd
...
<lastupdate>1554122342</lastupdate> <!-- 2019-04-02 01:39:02 NZDT -->
...
<database>
<!-- 2018-04-01 01:40:00 NZDT / 1522500000 --> <row><v>NaN</v></row>
<!-- 2018-04-01 01:50:00 NZDT / 1522500600 --> <row><v>NaN</v></row>
...
<!-- 2019-04-02 01:20:00 NZDT / 1554121200 --> <row><v>NaN</v></row>
<!-- 2019-04-02 01:30:00 NZDT / 1554121800 --> <row><v>NaN</v></row>
</database>
但是请稍等!这结束于1554121800,但是我们的上一次更新(开始时间)是1554122342!相差542.为什么会这样?
But wait a minute! This ends on 1554121800, but our last update (start time) was 1554122342! This is a difference of 542. Why would this be?
原因是,尽管您的步长为15秒,但RRA间隔为40步,即IE 600s.直到有600数据,才能添加下一个条目,而我们只有542.因此,RRA中的最后一个条目如图所示.请注意,所有间隔都相对于UCT进行了归一化,因此,无论何时将开始"设置为,您的RRA cdp(复合数据点)将始终是间隔大小的倍数(在这种情况下为600). RRDTool只会选择最接近的.当您滚动到较长的时间段时,例如,这种行为会变得更加明显. 1天-而您所在的时区更极端-例如奥克兰(UCT + 13).
The reason is that although your step is 15s, the RRA interval is 40 steps, IE 600s. The next entry cannot be added until there is 600s of data, and we only have 542. Therefore, the last entry in the RRA is as shown. Note that all intervals are normalised relative to UCT, and so your RRA cdp (consolodated data points) will always be a multiple of the interval size - in this case, 600 - regardless of when you set 'start' to be. RRDTool will simply pick the closest. This behaviour becomes much more obvious when you are rolling up to a large time period - e.g. 1 day - and you live in a more extreme timezone - e.g. Auckland with UCT+13.
当然,一旦您向RRD写入任何内容,那么lastupdate就会更改,并且RRA将添加所需的新点(当然也要删除旧的点).
Of course, once you write anything to the RRD, then lastupdate will change, and the RRA will add however many new points are required (and drop the old ones of course).
这篇关于如何在特定时间创建rrd文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!