summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a4a5b5e)
raw | patch | inline | side by side (parent: a4a5b5e)
author | Florian Forster <octo@verplant.org> | |
Wed, 8 Sep 2010 11:33:37 +0000 (13:33 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 8 Sep 2010 11:33:37 +0000 (13:33 +0200) |
src/data_provider.c | patch | blob | history | |
src/data_provider.h | patch | blob | history | |
src/dp_rrdtool.c | patch | blob | history | |
src/graph_list.c | patch | blob | history |
diff --git a/src/data_provider.c b/src/data_provider.c
index bf4cf889213d1a29109d91c8f849750aea5e81bb..e0028f8a4c309545e0efac4a6754a56a95a7ff39 100644 (file)
--- a/src/data_provider.c
+++ b/src/data_provider.c
* Florian octo Forster <ff at octo.it>
**/
+#include <stdlib.h>
+#include <errno.h>
+
#include "data_provider.h"
#include "dp_rrdtool.h"
+#include <fcgiapp.h>
+#include <fcgi_stdio.h>
+
+/* TODO: Turn this into an array for multiple data providers. */
+static data_provider_t *data_provider = NULL;
+
int data_provider_config (const oconfig_item_t *ci) /* {{{ */
{
/* FIXME: Actually determine which data provider to call. */
return (dp_rrdtool_config (ci));
} /* }}} int data_provider_config */
+int data_provider_register (const char *name, data_provider_t *p) /* {{{ */
+{
+ fprintf (stderr, "data_provider_register (name = %s, ptr = %p)\n",
+ name, (void *) p);
+
+ if (data_provider == NULL)
+ data_provider = malloc (sizeof (*data_provider));
+ if (data_provider == NULL)
+ return (ENOMEM);
+
+ *data_provider = *p;
+
+ return (0);
+} /* }}} int data_provider_register */
+
+int data_provider_get_idents (dp_get_idents_callback callback, /* {{{ */
+ void *user_data)
+{
+ int status;
+
+ if (data_provider == NULL)
+ return (EINVAL);
+
+ /* TODO: Iterate over all data providers */
+ status = data_provider->get_idents (data_provider->private_data,
+ callback, user_data);
+
+ return (status);
+} /* }}} int data_provider_get_idents */
+
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/data_provider.h b/src/data_provider.h
index 6dbcd1e8702cdfd79a67eb820910bdab4f7df502..054c0a9c67ae1406e19240bfa68e56367eb250c1 100644 (file)
--- a/src/data_provider.h
+++ b/src/data_provider.h
int data_provider_config (const oconfig_item_t *ci);
+int data_provider_register (const char *name, data_provider_t *p);
+int data_provider_get_idents (dp_get_idents_callback callback, void *user_data);
+
#endif /* DATA_PROVIDER_H */
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/dp_rrdtool.c b/src/dp_rrdtool.c
index b72e512c9fe9a2a570050889470d35cfb045cf15..6db02059d6a95ebfe87fd17b2a0b98e5bd6f8eeb 100644 (file)
--- a/src/dp_rrdtool.c
+++ b/src/dp_rrdtool.c
#include "graph_types.h"
#include "graph_ident.h"
-#include "graph_list.h"
#include "data_provider.h"
#include "filesystem.h"
#include "oconfig.h"
dp.private_data = conf;
- gl_register_data_provider ("rrdtool", &dp);
+ data_provider_register ("rrdtool", &dp);
return (0);
} /* }}} int dp_rrdtool_config */
diff --git a/src/graph_list.c b/src/graph_list.c
index ecd873bae4824e90258821865e7ff12e3dc0c9e6..d767ef945585198691fd737c2d2de5c750f5eb9b 100644 (file)
--- a/src/graph_list.c
+++ b/src/graph_list.c
#include "graph_list.h"
#include "common.h"
+#include "data_provider.h"
#include "filesystem.h"
#include "graph.h"
#include "graph_config.h"
static time_t gl_last_update = 0;
-/* TODO: Turn this into an array for multiple data providers. */
-static data_provider_t *data_provider = NULL;
-
/*
* Private functions
*/
return (0);
} /* }}} int graph_config_submit */
-int gl_register_data_provider (const char *name, data_provider_t *p) /* {{{ */
-{
- fprintf (stderr, "gl_register_data_provider (name = %s, ptr = %p)\n",
- name, (void *) p);
-
- if (data_provider == NULL)
- data_provider = malloc (sizeof (*data_provider));
- if (data_provider == NULL)
- return (ENOMEM);
-
- *data_provider = *p;
-
- return (0);
-} /* }}} int gl_register_data_provider */
-
int gl_graph_get_all (_Bool include_dynamic, /* {{{ */
graph_callback_t callback, void *user_data)
{
if ((status != 0)
|| ((gl_last_update + UPDATE_INTERVAL) < now))
{
- if (data_provider == NULL)
- {
- fprintf (stderr, "No data provider has been registered\n");
- return (ENOENT);
- }
-
/* Clear state */
gl_clear_instances ();
gl_clear_hosts ();
gl_destroy (&gl_dynamic, &gl_dynamic_num);
- /* TODO: Iterate over all data providers */
- data_provider->get_idents (data_provider->private_data,
- gl_register_ident, /* user data = */ NULL);
+ data_provider_get_idents (gl_register_ident, /* user data = */ NULL);
gl_last_update = now;
}