summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1411661)
raw | patch | inline | side by side (parent: 1411661)
author | Florian Forster <octo@noris.net> | |
Wed, 2 Feb 2011 14:07:26 +0000 (15:07 +0100) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 2 Feb 2011 14:07:26 +0000 (15:07 +0100) |
src/rrdcached.c | patch | blob | history |
diff --git a/src/rrdcached.c b/src/rrdcached.c
index fb7eb79e8ec50eca5ab5d9273ff349d9fb5dd4cf..3099421384c25be3684da8ae3f222782443fe589 100644 (file)
--- a/src/rrdcached.c
+++ b/src/rrdcached.c
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;
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 ();
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 */