summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 84e361e)
raw | patch | inline | side by side (parent: 84e361e)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 1 Mar 2007 11:14:39 +0000 (12:14 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 1 Mar 2007 11:14:39 +0000 (12:14 +0100) |
Since the `rrdtool' and `csv' plugins may be loaded at the same time, one may
want to configure another path for this plugin, too.
want to configure another path for this plugin, too.
src/collectd.conf.pod | patch | blob | history | |
src/csv.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 3c34905f726195e313ce5a471a3100fc36f85087..5a04fce7926a0e2cd4c6381b35ad01ca73440d2f 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=back
+=head2 Plugin C<csv>
+
+=over 4
+
+=item B<DataDir> I<Directory>
+
+Set the directory to store RRD-files under. Per default RRD-files are generated
+beneath the daemon's working directory, i.E<nbsp>e. the B<BaseDir>.
+
+=back
+
=head2 Plugin C<df>
=over 4
=item B<DataDir> I<Directory>
-Set the directory to store RRD-files under. Per default RRD-files are generated
+Set the directory to store CSV-files under. Per default CSV-files are generated
beneath the daemon's working directory, i.E<nbsp>e. the B<BaseDir>.
=item B<StepSize> I<Seconds>
diff --git a/src/csv.c b/src/csv.c
index dd33ca5e4876ea42d33f1db618a72c4d1d70b58f..268bdbf57447a49325b3fb448e76694a166ada30 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
#include "common.h"
#include "utils_debug.h"
+/*
+ * Private variables
+ */
+static const char *config_keys[] =
+{
+ "DataDir"
+};
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+
+static char *datadir = NULL;
+
static int value_list_to_string (char *buffer, int buffer_len,
const data_set_t *ds, const value_list_t *vl)
{
int offset = 0;
int status;
+ if (datadir != NULL)
+ {
+ status = snprintf (buffer + offset, buffer_len - offset,
+ "%s/", datadir);
+ if ((status < 1) || (status >= buffer_len - offset))
+ return (-1);
+ offset += status;
+ }
+
status = snprintf (buffer + offset, buffer_len - offset,
"%s/", vl->host);
if ((status < 1) || (status >= buffer_len - offset))
return 0;
} /* int csv_create_file */
+static int csv_config (const char *key, const char *value)
+{
+ if (strcasecmp ("DataDir", key) == 0)
+ {
+ if (datadir != NULL)
+ free (datadir);
+ datadir = strdup (value);
+ if (datadir != NULL)
+ {
+ int len = strlen (datadir);
+ while ((len > 0) && (datadir[len - 1] == '/'))
+ {
+ len--;
+ datadir[len] = '\0';
+ }
+ if (len <= 0)
+ {
+ free (datadir);
+ datadir = NULL;
+ }
+ }
+ }
+ else
+ {
+ return (-1);
+ }
+ return (0);
+} /* int csv_config */
+
static int csv_write (const data_set_t *ds, const value_list_t *vl)
{
struct stat statbuf;
if (value_list_to_filename (filename, sizeof (filename), ds, vl) != 0)
return (-1);
+ DBG ("filename = %s;", filename);
+
if (value_list_to_string (values, sizeof (values), ds, vl) != 0)
return (-1);
void module_register (void)
{
+ plugin_register_config ("csv", csv_config,
+ config_keys, config_keys_num);
plugin_register_write ("csv", csv_write);
}