如何使用 C API 调用线程安全 rrd_update_r 循环数据库函数?
任何人都可以帮我找出如何从 http:// 调用rrdtool c API 的rrd_update_r 函数/oss.oetiker.ch/rrdtool/index.en.html?
调用非线程安全版本的rrd_update非常容易,但是这个版本更棘手...
普通rrd_update:
char *updateparams[] = {
"rrdupdate",
rrd_file,
values,
NULL
};
rrd_clear_error();
result = rrd_update(3, updateparams); //argc is first arg
因为程序必须在多线程环境中运行,所以我因不使用线程安全函数而出现了几个错误! 但使用rrd_update_r并不那么容易,因为它也需要一个模板...
int rrd_update_r(const char *filename, const char *_template,
int argc, const char **argv);
而且我真的不知道如何创建一个...
char *updateparams[] = {
"rrdupdate",
rrd_file,
values,
NULL
};
rrd_clear_error();
result = rrd_update_r(rrd_file, NULL,3, updateparams);
不起作用并在执行时产生以下错误...
error: /var/tmp/rrds/1.rrd: expected timestamp not found in data source from rrdupdate
希望有人可以提供帮助我!
谢谢和br, 罗埃吉
Can anybody help me to find out how to call rrd_update_r function of the rrdtool c API from http://oss.oetiker.ch/rrdtool/index.en.html?
It was quite easy to call the non-threadsafe version of rrd_update, but this one is more tricky...
normal rrd_update:
char *updateparams[] = {
"rrdupdate",
rrd_file,
values,
NULL
};
rrd_clear_error();
result = rrd_update(3, updateparams); //argc is first arg
Because the programm has to run in a multithreaded environment I got several errors by not using the threadsafe functions!
But it is not so easy to use rrd_update_r, because it requires a template too...
int rrd_update_r(const char *filename, const char *_template,
int argc, const char **argv);
and I really have no idea how to create one...
char *updateparams[] = {
"rrdupdate",
rrd_file,
values,
NULL
};
rrd_clear_error();
result = rrd_update_r(rrd_file, NULL,3, updateparams);
does not work and produces the following error when executing it...
error: /var/tmp/rrds/1.rrd: expected timestamp not found in data source from rrdupdate
Hopefully someone can help me!
thx and br,
roegi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,看看源代码...
看来
rrd_update_r
不想看到"rrupdate"
参数。因此,请尝试仅将rrd_file
和values
作为 2 元素argv
传递。实际上rrd_update的源代码并不难读;你可以在 src/rrd_update.c 中找到它。
rrd_update_r
似乎是rrd_update
本身调用的低级函数。所以这可能并不能真正解决你的根本问题。Well, looking at the source code...
It appears that
rrd_update_r
does not want to see the"rrupdate"
argument. So try just passingrrd_file
andvalues
as a 2-elementargv
.Actually the source for
rrd_update
is not hard to read; you can find it in src/rrd_update.c. Andrrd_update_r
appears to be a much lower-level function thatrrd_update
itself calls. So this may not actually fix your underlying problem.现在它正在工作!
尼莫 - 谢谢你的帮助!
这不完全是您的解决方案,但它是正确方向的提示!
它适用于:
Now it is working!
Nemo - thx for your help!
It was not exactly your solution but it was a hint to the right direction!
It works with: