From: Florian Forster Date: Wed, 2 Feb 2011 14:07:26 +0000 (+0100) Subject: rrdcached plugin: Pass FLUSHes on to the caching daemon. X-Git-Tag: collectd-5.1.0~79^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=776e65a46fb7e69931267b9a4380ec56cb325386;p=collectd.git rrdcached plugin: Pass FLUSHes on to the caching daemon. --- diff --git a/src/rrdcached.c b/src/rrdcached.c index fb7eb79e..30994213 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -328,7 +328,7 @@ static int rc_init (void) static int rc_write (const data_set_t *ds, const value_list_t *vl, user_data_t __attribute__((unused)) *user_data) { - char filename[512]; + char filename[PATH_MAX]; char values[512]; char *values_array[2]; int status; @@ -406,6 +406,41 @@ static int rc_write (const data_set_t *ds, const value_list_t *vl, return (0); } /* int rc_write */ +static int rc_flush (__attribute__((unused)) cdtime_t timeout, /* {{{ */ + const char *identifier, + __attribute__((unused)) user_data_t *ud) +{ + char filename[PATH_MAX + 1]; + int status; + + if (identifier == NULL) + return (EINVAL); + + if (datadir != NULL) + ssnprintf (filename, sizeof (filename), "%s/%s.rrd", datadir, identifier); + else + ssnprintf (filename, sizeof (filename), "%s.rrd", identifier); + + status = rrdc_connect (daemon_address); + if (status != 0) + { + ERROR ("rrdcached plugin: rrdc_connect (%s) failed with status %i.", + daemon_address, status); + return (-1); + } + + status = rrdc_flush (filename); + if (status != 0) + { + ERROR ("rrdcached plugin: rrdc_flush (%s) failed with status %i.", + filename, status); + return (-1); + } + DEBUG ("rrdcached plugin: rrdc_flush (%s): Success.", filename); + + return (0); +} /* }}} int rc_flush */ + static int rc_shutdown (void) { rrdc_disconnect (); @@ -418,6 +453,7 @@ void module_register (void) config_keys, config_keys_num); plugin_register_init ("rrdcached", rc_init); plugin_register_write ("rrdcached", rc_write, /* user_data = */ NULL); + plugin_register_flush ("rrdcached", rc_flush, /* user_data = */ NULL); plugin_register_shutdown ("rrdcached", rc_shutdown); } /* void module_register */