summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c98b98b)
raw | patch | inline | side by side (parent: c98b98b)
author | Sven Trenkel <collectd@semidefinite.de> | |
Thu, 29 Oct 2009 12:24:39 +0000 (13:24 +0100) | ||
committer | Sven Trenkel <collectd@semidefinite.de> | |
Thu, 29 Oct 2009 12:24:39 +0000 (13:24 +0100) |
src/configfile.c | patch | blob | history | |
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history | |
src/pyvalues.c | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index 1a957f67463f138c673cc5dd5f23ebcbabffa8c3..79ad9f6d4f6e2ae6cb60af07fab551f645f3cb1f 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
*/
static int dispatch_value_typesdb (const oconfig_item_t *ci);
static int dispatch_value_plugindir (const oconfig_item_t *ci);
-static int dispatch_value_loadplugin (const oconfig_item_t *ci);
+static int dispatch_loadplugin (const oconfig_item_t *ci);
/*
* Private variables
{
{"TypesDB", dispatch_value_typesdb},
{"PluginDir", dispatch_value_plugindir},
- {"LoadPlugin", dispatch_value_loadplugin}
+ {"LoadPlugin", dispatch_loadplugin}
};
static int cf_value_map_num = STATIC_ARRAY_LEN (cf_value_map);
return (0);
}
-static int dispatch_value_loadplugin (const oconfig_item_t *ci)
+static int dispatch_loadplugin (const oconfig_item_t *ci)
{
+ int i;
+ uint32_t flags = 0;
assert (strcasecmp (ci->key, "LoadPlugin") == 0);
if (ci->values_num != 1)
if (ci->values[0].type != OCONFIG_TYPE_STRING)
return (-1);
- return (plugin_load (ci->values[0].value.string));
+ for (i = 0; i < ci->children_num; ++i) {
+ if (ci->children[i].values_num != 1 ||
+ ci->children[i].values[0].type != OCONFIG_TYPE_BOOLEAN) {
+ WARNING("Ignoring unknown LoadPlugin option %s for plugin %s", ci->children[i].key, ci->values[0].value.string);
+ continue;
+ }
+ if (strcasecmp(ci->children[i].key, "globals") == 0) {
+ flags |= PLUGIN_FLAGS_GLOBAL;
+ } else {
+ WARNING("Ignoring unknown LoadPlugin option %s for plugin %s", ci->children[i].key, ci->values[0].value.string);
+ }
+ }
+ return (plugin_load (ci->values[0].value.string, flags));
} /* int dispatch_value_loadplugin */
static int dispatch_value_plugin (const char *plugin, oconfig_item_t *ci)
static int dispatch_block (oconfig_item_t *ci)
{
- if (strcasecmp (ci->key, "Plugin") == 0)
+ if (strcasecmp (ci->key, "LoadPlugin") == 0)
+ return (dispatch_loadplugin (ci));
+ else if (strcasecmp (ci->key, "Plugin") == 0)
return (dispatch_block_plugin (ci));
else if (strcasecmp (ci->key, "Threshold") == 0)
return (ut_config (ci));
diff --git a/src/plugin.c b/src/plugin.c
index 97885a3b6280bac4f1de84d8ec76e63b6de394d4..7b30e21176d2552bfbeacf4726e40875d61821c8 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
* object, but it will bitch about a shared object not having a
* ``module_register'' symbol..
*/
-static int plugin_load_file (char *file)
+static int plugin_load_file (char *file, uint32_t flags)
{
lt_dlhandle dlh;
void (*reg_handle) (void);
lt_dlinit ();
lt_dlerror (); /* clear errors */
- /* XXX BUG FIXME */
- if (strstr(file, "python") != NULL) {
+ if (flags & PLUGIN_FLAGS_GLOBAL) {
lt_dladvise advise;
lt_dladvise_init(&advise);
lt_dladvise_global(&advise);
}
#define BUFSIZE 512
-int plugin_load (const char *type)
+int plugin_load (const char *type, uint32_t flags)
{
DIR *dh;
const char *dir;
continue;
}
- if (plugin_load_file (filename) == 0)
+ if (plugin_load_file (filename, flags) == 0)
{
/* success */
ret = 0;
diff --git a/src/plugin.h b/src/plugin.h
index b35fcf189874b452aff00c03138ec068db54b36a..e576141f7c02d890ab9abfb9d4faad1d02aaec56 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
#include "configfile.h"
#include "meta_data.h"
+#define PLUGIN_FLAGS_GLOBAL 0x0001
+
#define DATA_MAX_NAME_LEN 64
#define DS_TYPE_COUNTER 0
*
* ARGUMENTS
* `name' Name of the plugin to load.
- * `mr' Types of functions to request from the plugin.
+ * `flags' Hints on how to handle this plugin.
*
* RETURN VALUE
* Returns zero upon success, a value greater than zero if no plugin was found
* NOTES
* No attempt is made to re-load an already loaded module.
*/
-int plugin_load (const char *name);
+int plugin_load (const char *name, uint32_t flags);
void plugin_init_all (void);
void plugin_read_all (void);
diff --git a/src/pyvalues.c b/src/pyvalues.c
index 215907435a194d4b824b3eff7dd02b83c957dae5..9a0c87f39f9df61494bed3d58ab7a45ce8a4ca49 100644 (file)
--- a/src/pyvalues.c
+++ b/src/pyvalues.c
@@ -209,13 +209,13 @@ static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) {
* Not much we can do about it */
num = PyNumber_Long(item);
if (num != NULL)
- value[i].gauge = PyLong_AsLongLong(num);
+ value[i].derive = PyLong_AsLongLong(num);
} else if (ds->ds->type == DS_TYPE_ABSOLUTE) {
/* This might overflow without raising an exception.
* Not much we can do about it */
num = PyNumber_Long(item);
if (num != NULL)
- value[i].gauge = PyLong_AsUnsignedLongLong(num);
+ value[i].absolute = PyLong_AsUnsignedLongLong(num);
} else {
free(value);
PyErr_Format(PyExc_RuntimeError, "unknown data type %d for %s", ds->ds->type, type);