summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 109b540)
raw | patch | inline | side by side (parent: 109b540)
author | Florian Forster <octo@verplant.org> | |
Thu, 9 Sep 2010 16:42:55 +0000 (18:42 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Thu, 9 Sep 2010 16:42:55 +0000 (18:42 +0200) |
src/dp_rrdtool.c | patch | blob | history |
diff --git a/src/dp_rrdtool.c b/src/dp_rrdtool.c
index d7ad5ba612360bb05a3853602176ab7594b8ef55..78554c71d36cdf2fbfb3b07bf139d200ae1a9806 100644 (file)
--- a/src/dp_rrdtool.c
+++ b/src/dp_rrdtool.c
#include <rrd.h>
#include "graph_types.h"
+#include "graph_config.h"
#include "graph_ident.h"
#include "data_provider.h"
#include "filesystem.h"
int dp_rrdtool_config (const oconfig_item_t *ci)
{ /* {{{ */
dp_rrdtool_t *conf;
+ int i;
data_provider_t dp =
{
/* private_data = */ NULL
};
- /* FIXME: Actuelly do config parsing here. */
- ci = NULL; /* FIXME */
- conf = malloc (sizeof (dp_rrdtool_t));
- conf->data_dir = strdup ("/var/lib/collectd/rrd");
+ conf = malloc (sizeof (*conf));
+ if (conf == NULL)
+ return (ENOMEM);
+ memset (conf, 0, sizeof (*conf));
+ conf->data_dir = NULL;
+
+ for (i = 0; i < ci->children_num; i++)
+ {
+ oconfig_item_t *child = ci->children + i;
+
+ if (strcasecmp ("DataDir", child->key) == 0)
+ graph_config_get_string (child, &conf->data_dir);
+ else
+ {
+ fprintf (stderr, "dp_rrdtool_config: Ignoring unknown config option "
+ "\"%s\"\n", child->key);
+ fflush (stderr);
+ }
+ }
+
+ if (conf->data_dir == NULL)
+ conf->data_dir = strdup ("/var/lib/collectd/rrd");
+ if (conf->data_dir == NULL)
+ {
+ free (conf);
+ return (ENOMEM);
+ }
dp.private_data = conf;