如何使用 RRDtool 更新数据?
我正在使用 RRDtool 来存储用于显示图形的数据。 我通过 RRDs::update 更新 RRD,并且在尝试重写信息时失败,这意味着更新过去一段时间的数据(例如,有人将系统计时器移回原来的位置)。 我得到的错误是:
ERROR: Cannot update /opt/dashboard/rrd/Disk/192.168.120.168_disk_1.rrd with
'1228032301:24:24' illegal attempt to update using time 1228032301 when last
update time is 1228050001 (minimum one second step)
我想始终允许重写,我该怎么做?
I am using RRDtool for storing data for displaying graphs. I update the RRD by RRDs::update and this fails when trying to rewrite the information, means update data for a time in the past (e.g. someone moved the system timer back). The error I get is:
ERROR: Cannot update /opt/dashboard/rrd/Disk/192.168.120.168_disk_1.rrd with
'1228032301:24:24' illegal attempt to update using time 1228032301 when last
update time is 1228050001 (minimum one second step)
I want to always allow the rewrite, how can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
rrdtool 不会将您的输入写入 rrd 文件。 它而是对您输入的内容进行采样,然后存储结果数据点。 因此,向 rrdtool 更新提供“旧数据”不会以同样的方式工作,因为您无法轻松地跳回录音来“修复”一些错误的音符。
显然,有一些方法可以更改旧数据,在rrdtool中执行此操作的方法是将rrd文件“转储”到xml,修改内容并“恢复”它。 这不是人们愿意定期做的事情。
rrdtool does not write your input into the rrd file. It rather samples what you enter and then stores the resulting datapoints. So providing 'old data' to rrdtool update will not work in the same way, as you can not easily skip back in a sound recording to 'fix' a few bad notes.
Obviously there are ways to alter old data, the way todo this in rrdtool, is to 'dump' the rrd file to xml, modify the content and 'restore' it. Not something one would like todo on a regular basis.
我在这种情况下使用以下脚本:
这有点......怪异,但我找不到另一个自动解决方案。
I use following script in such situations:
It's a little... freaky, but i could not find another automatic solution.
根据 RRD 文档,该时间戳数字必须随着每次更新而增加。 考虑到您的限制,我将修改您的更新例程,以便如果更新失败,您将捕获异常并重做更新,并将时间字段设置为“N”。 这将使 RRDtool 使用当前时间作为更新时间。
或者,如果您不想处理捕获并重试代码,只需修改更新代码以始终使用“N”作为时间值 - 那么更新将始终有效。
快速查看 RRDtool 的文档可能会有所帮助 更新命令< /a>.
According to the RRD documentation, that timestamp number must increase with each update. Given your constraints, I'd modify your update routine so that if the update fails, you catch the exception and redo the update with the time field set to 'N'. That will make RRDtool use the current time as the update time.
Alternatively, if you don't want to deal with the catch-and-retry code, just modify your update code to always use 'N' as the time value -- then the update will always work.
It may be helpful to have a quick look at the documentation for the RRDtool update command.