gpt4 book ai didi

c - 如何使用 C API 调用线程安全的 rrd_update_r Round Robin 数据库函数?

转载 作者:太空宇宙 更新时间:2023-11-04 04:05:18 25 4
gpt4 key购买 nike

谁能帮我找出如何从 http://oss.oetiker.ch/rrdtool/index.en.html 调用 rrdtool c API 的 rrd_update_r 函数?

调用非线程安全版本的 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,罗吉

最佳答案

嗯,看源码...

rrd_update_r 似乎不想看到 "rrupdate" 参数。因此,请尝试将 rrd_filevalues 作为 2 元素 argv 传递。

实际上 rrd_update 的源代码并不难读;你可以在 src/rrd_update.c 中找到它。 rrd_update_r 似乎是 rrd_update 本身调用的低级函数。所以这实际上可能无法解决您的根本问题。

关于c - 如何使用 C API 调用线程安全的 rrd_update_r Round Robin 数据库函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6681090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com