call to cf_util_get_service
I'm tryhing to build collectd-write_graphite on openSuse but got errors about unexisting cf_util_get_service function with collectd-5.0.0.
I also tried with collectd 5.0.3 and 5.0.4 of collectd, but same error :
mkdir -p build
mkdir -p work
( if [ ! -d work/collectd-5.0.4/src ] ; then
if which fetch ; then
DOWNLOAD_TOOL=which fetch ;
elif which wget ; then
DOWNLOAD_TOOL=which wget ;
fi ;
cd work ;
${DOWNLOAD_TOOL} http://collectd.org/files/collectd-5.0.4.tar.gz ;
tar zxvf collectd-5.0.4.tar.gz ;
cd collectd-5.0.4 ;
if [ ! -f libtool ] ; then
./configure ;
fi ;
fi )
work/collectd-5.0.4/libtool --mode=compile gcc -DHAVE_CONFIG_H -I src
-I work/collectd-5.0.4/src -Wall -Werror -DNDEBUG -O3 -MD -MP -c
-o build/write_graphite.lo src/write_graphite.c
libtool: compile: gcc -DHAVE_CONFIG_H -I src -I work/collectd-5.0.4/src -Wall -Werror -DNDEBUG -O3 -MD -MP -c src/write_graphite.c -fPIC -DPIC -o build/.libs/write_graphite.o
src/write_graphite.c: In function ‘wg_config_carbon’:
src/write_graphite.c:635:13: error: implicit declaration of function ‘cf_util_get_service’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make: *** [build/write_graphite.lo] Erreur 1
cf_util_get_service is undefined in 5.0.x and only appears in 5.1.0
Write_graphite has been merged into collectd since version 5.1.
http://collectd.org/wiki/index.php/Plugin:Write_Graphite
I strongly suggest upgrading to 5.1 if you can. At this point I'm unable to maintain the code for the plugin and backwards compatibility with older collectd releases.
I can't upgrade to 5.1 for now, many distributions are still locked with 5.0, that's why using your plugin was useful for pre 5.1 users, since 5.1 came with graphite support built-in.
So it make sense to keep your git repo for Collectd 5.0 (and may be 4.x) and maintain graphite support into collectd git repository.
I see what you mean. The master branch contains Florian's integration work, but I have a v0.1.0 tag from before that should reflect a stable 5.0 (and 4.x with some minor tweaks to cd_time) build.
https://github.com/jssjr/collectd-write_graphite/tree/0.1.0
Hope this helps. =)
Trying it right now, and figuring how to hack cd_time
Replace all instance of cd_time with time, include the structs and function calls.
On Mon, Sep 17, 2012 at 11:00 AM, Gomez Henri [email protected]:
Trying it right now, and figuring how to hack cd_time
— Reply to this email directly or view it on GitHubhttps://github.com/jssjr/collectd-write_graphite/issues/15#issuecomment-8617631.
patch to make it build under collectd 4.10.7
--- src/write_graphite.c 2012-09-17 17:13:48.124776784 +0200
+++ src/write_graphite.c.410 2012-09-17 17:13:00.821775270 +0200
@@ -79,7 +79,7 @@
char send_buf[WG_SEND_BUF_SIZE];
size_t send_buf_free;
size_t send_buf_fill;
- cdtime_t send_buf_init_time;
+ time_t send_buf_init_time;
pthread_mutex_t send_lock;
};
@@ -93,7 +93,7 @@
memset (cb->send_buf, 0, sizeof (cb->send_buf));
cb->send_buf_free = sizeof (cb->send_buf);
cb->send_buf_fill = 0;
- cb->send_buf_init_time = cdtime ();
+ cb->send_buf_init_time = time (NULL);
}
static int wg_send_buffer (struct wg_callback *cb)
@@ -122,7 +122,7 @@
return (0);
}
-static int wg_flush_nolock (cdtime_t timeout, struct wg_callback *cb)
+static int wg_flush_nolock (time_t timeout, struct wg_callback *cb)
{
int status;
@@ -134,16 +134,16 @@
/* timeout == 0 => flush unconditionally */
if (timeout > 0)
{
- cdtime_t now;
+ time_t now;
- now = cdtime ();
+ now = time (NULL);
if ((cb->send_buf_init_time + timeout) > now)
return (0);
}
if (cb->send_buf_fill <= 0)
{
- cb->send_buf_init_time = cdtime ();
+ cb->send_buf_init_time = time (NULL);
return (0);
}
@@ -218,7 +218,7 @@
sfree(cb);
}
-static int wg_flush (cdtime_t timeout,
+static int wg_flush (time_t timeout,
const char *identifier __attribute__((unused)),
user_data_t *user_data)
{
@@ -431,7 +431,7 @@
}
static int wg_send_message (const char* key, const char* value,
- cdtime_t time, struct wg_callback *cb)
+ time_t time, struct wg_callback *cb)
{
int status;
size_t message_len;
@@ -441,7 +441,7 @@
"%s %s %.0f\n",
key,
value,
- CDTIME_T_TO_DOUBLE(time));
+ (double)time);
if (message_len >= sizeof (message)) {
ERROR ("write_graphite plugin: message buffer too small: "
"Need %zu bytes.", message_len + 1);
@@ -716,7 +716,7 @@
memset (&user_data, 0, sizeof (user_data));
user_data.data = cb;
user_data.free_func = NULL;
- plugin_register_flush ("write_graphite", wg_flush, &user_data);
+ plugin_register_flush ("write_graphite", (plugin_flush_cb)wg_flush, &user_data);
user_data.free_func = wg_callback_free;
plugin_register_write ("write_graphite", wg_write, &user_data);
@@ -749,4 +749,5 @@
plugin_register_complex_config ("write_graphite", wg_config);
}
-/* vim: set sw=4 ts=4 sts=4 tw=78 et : */
+/* vim: set sw=4 ts=4 sts=4 tw=78 et : */
+
Unfortunately I've got the same issue. I'm locked to collectd 5.0.4 and I need the graphite plugin. I fixed the error related to cdtime_t but not the one related to cf_util_get_service.
Can anyone help with this, please? I can't get my head around.
This is probably well out of date being a 2015 issue but for anyone else who has the problem of being locked into an early version of collectd just revert this change in the code and it will compile and work:
https://github.com/jssjr/collectd-write_graphite/commit/18e0a5da0dcf016a068fd011edc5d53cd15f0b74