summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c4e824e)
raw | patch | inline | side by side (parent: c4e824e)
author | Florian Forster <octo@huhu.verplant.org> | |
Sun, 19 Dec 2010 13:16:59 +0000 (14:16 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sun, 19 Dec 2010 13:16:59 +0000 (14:16 +0100) |
This special handling hopefully saves the average user from ever getting
in contact with the "Globals" option.
in contact with the "Globals" option.
src/collectd.conf.pod | patch | blob | history | |
src/configfile.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 7579664ba1b146112722d6023dc074c35e8f2236..589e1694c080a3944486020dcd471b9a5df16823 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
If enabled, collectd will export all global symbols of the plugin (and of all
libraries loaded as dependencies of the plugin) and, thus, makes those symbols
available for resolving unresolved symbols in subsequently loaded plugins if
-that is supported by your system. By default, this is disabled.
+that is supported by your system.
-This is useful (or possibly even required), e.E<nbsp>g., when loading a plugin
-that embeds some scripting language into the daemon (e.E<nbsp>g. the C<perl>
-or C<python> plugins). Scripting languages usually provide means to load
+This is useful (or possibly even required), e.g., when loading a plugin that
+embeds some scripting language into the daemon (e.g. the I<Perl> and
+I<Python plugins>). Scripting languages usually provide means to load
extensions written in C. Those extensions require symbols provided by the
-interpreter, which is loaded as a dependency of the respective collectd
-plugin. See the documentation of those plugins (e.E<nbsp>g.,
-L<collectd-perl(5)> or L<collectd-python(5)>) for details.
+interpreter, which is loaded as a dependency of the respective collectd plugin.
+See the documentation of those plugins (e.g., L<collectd-perl(5)> or
+L<collectd-python(5)>) for details.
+
+By default, this is disabled. As a special exception, if the plugin name is
+either C<perl> or C<python>, the default is changed to enabled in order to keep
+the average user from ever having to deal with this low level linking stuff.
=back
diff --git a/src/configfile.c b/src/configfile.c
index 11200f610a0366e9bf4f97604d9aa712d7cf917e..33a7c200dbb3fc95d57e1b731c4e2397a2cbcd61 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
static int dispatch_loadplugin (const oconfig_item_t *ci)
{
int i;
- uint32_t flags = 0;
+ const char *name;
+ unsigned int flags = 0;
assert (strcasecmp (ci->key, "LoadPlugin") == 0);
if (ci->values_num != 1)
if (ci->values[0].type != OCONFIG_TYPE_STRING)
return (-1);
+ name = ci->values[0].value.string;
+
+ /*
+ * XXX: Magic at work:
+ *
+ * Some of the language bindings, for example the Python and Perl
+ * plugins, need to be able to export symbols to the scripts they run.
+ * For this to happen, the "Globals" flag needs to be set.
+ * Unfortunately, this technical detail is hard to explain to the
+ * average user and she shouldn't have to worry about this, ideally.
+ * So in order to save everyone's sanity use a different default for a
+ * handful of special plugins. --octo
+ */
+ if ((strcasecmp ("Perl", name) == 0)
+ || (strcasecmp ("Python", name) == 0))
+ flags |= PLUGIN_FLAGS_GLOBAL;
+
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);
+ if (strcasecmp("Globals", ci->children[i].key) == 0)
+ cf_util_get_flag (ci->children + i, &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));
+
+ return (plugin_load (name, (uint32_t) flags));
} /* int dispatch_value_loadplugin */
static int dispatch_value_plugin (const char *plugin, oconfig_item_t *ci)