summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 06adec2)
raw | patch | inline | side by side (parent: 06adec2)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 10 Apr 2007 22:25:57 +0000 (00:25 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 11 Apr 2007 06:27:30 +0000 (08:27 +0200) |
This option sets the basename of a Perl plugin, i.e. the prefix to its name
when loading the module. It defaults to "Collectd::Plugin".
Signed-off-by: Sebastian Harl <sh@tokkee.org>
when loading the module. It defaults to "Collectd::Plugin".
Signed-off-by: Sebastian Harl <sh@tokkee.org>
src/collectd.conf.in | patch | blob | history | |
src/perl.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 3aa1306587edbbb9ef25b6a863db1a03f8319560..67b2bcf42cf76db142852e69996d5d6d917f322c 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#</Plugin>
#<Plugin perl>
+# BaseName "Collectd::Plugin"
# LoadPlugin foo
#</Plugin>
diff --git a/src/perl.c b/src/perl.c
index 0c5e8829556c17b70a1e62ca4604ba454f4de7cd..566a62c7eefee4c345df8512119708c5fdeb2050 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
static const char *config_keys[] =
{
"LoadPlugin",
+ "BaseName",
NULL
};
-static int config_keys_num = 1;
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static PerlInterpreter *perl = NULL;
+static char base_name[DATA_MAX_NAME_LEN] = "Collectd::Plugin";
+
static char *plugin_types[] = { "init", "read", "write", "shutdown" };
static HV *plugins[PLUGIN_TYPES];
static HV *data_sets;
if (NULL != (tmp = Perl_hv_fetch (perl, values, "host", 4, 0))) {
strncpy (list.host, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN);
+ list.host[DATA_MAX_NAME_LEN - 1] = '\0';
}
else {
strcpy (list.host, hostname_g);
/* prevent an endless loop */
if (PLUGIN_LOG != type)
- log_debug ("pplugin_call: executing Collectd::plugin::%s->%s()",
- name, plugin_types[type]);
+ log_debug ("pplugin_call: executing %s::%s->%s()",
+ base_name, name, plugin_types[type]);
retvals = Perl_call_sv (perl, sub, G_SCALAR | xflags);
if (1 > retvals) {
if (PLUGIN_LOG != type)
log_warn ("pplugin_call: "
- "Collectd::plugin::%s->%s() returned void - assuming true",
- name, plugin_types[type]);
+ "%s::%s->%s() returned void - assuming true",
+ base_name, name, plugin_types[type]);
}
else {
SV *tmp = POPs;
if (p->wait_time > 86400)
p->wait_time = 86400;
- log_warn ("Collectd::plugin::%s->read() failed. "
- "Will suspend it for %i seconds.",
- plugin, p->wait_left);
+ log_warn ("%s::%s->read() failed. Will suspend it for %i seconds.",
+ base_name, plugin, p->wait_left);
}
else if (PLUGIN_INIT == type) {
int i = 0;
- log_err ("Collectd::plugin::%s->init() failed. "
- "Plugin will be disabled.", plugin, status);
+ log_err ("%s::%s->init() failed. Plugin will be disabled.",
+ base_name, plugin, status);
for (i = 0; i < PLUGIN_TYPES; ++i)
pplugin_unregister (i, plugin);
}
else if (PLUGIN_LOG != type) {
- log_warn ("Collectd::plugin::%s->%s() failed with status %i.",
- plugin, plugin_types[type], status);
+ log_warn ("%s::%s->%s() failed with status %i.",
+ base_name, plugin, plugin_types[type], status);
}
va_end (ap);
log_debug ("perl_config: loading perl plugin \"%s\"", value);
Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
- Perl_newSVpvf (perl, "Collectd::plugin::%s", value),
+ Perl_newSVpvf (perl, "%s::%s", base_name, value),
Nullsv);
}
+ else if (0 == strcasecmp (key, "BaseName")) {
+ log_debug ("perl_config: Setting plugin basename to \"%s\"", value);
+ strncpy (base_name, value, DATA_MAX_NAME_LEN);
+ base_name[DATA_MAX_NAME_LEN - 1] = '\0';
+ }
else {
return -1;
}