[collectd] [PATCH] perl plugin: Added the "IncludeDir" config
option.
Sebastian Harl
sh<span style="display: none;">.trailing-username</span>(a)<span style="display: none;">leading-domain.</span>tokkee.org
Sun Apr 22 22:57:43 CEST 2007
"IncludeDir <Dir>" adds <Dir> to the @INC array.
A segfault when parsing unknown config options has been fixed and documentation
about the perl plugin has been added to collectd.conf.pod.
Signed-off-by: Sebastian Harl <sh.trailing-username(a)leading-domain.tokkee.org>
---
src/collectd.conf.in | 1 +
src/collectd.conf.pod | 21 +++++++++++++++++++++
src/perl.c | 7 ++++++-
3 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 4cfa694..2986edf 100644
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
@@ -149,6 +149,7 @@
#</Plugin>
#<Plugin perl>
+# IncludeDir "/my/include/path"
# BaseName "Collectd::Plugin"
# LoadPlugin foo
#</Plugin>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index da50a34..32f74cd 100644
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -437,6 +437,27 @@ L<upsc(8)>.
=back
+=head2 Plugin C<perl>
+
+=over 4
+
+=item B<LoadPlugin> I<Plugin>
+
+Loads the Perl plugin I<Plugin>. This does basically the same as B<use> would
+do in a Perl program.
+
+=item B<BaseName> I<Name>
+
+Prepends I<Name>B<::> to all plugin names loaded after this option. This is
+provided for convenience to keep plugin names short.
+
+=item B<IncludeDir> I<Dir>
+
+Adds I<Dir> to the B<@INC> array. This is the same as using the B<-IDir>
+command line option or B<use lib Dir> in the source code.
+
+=back
+
=head2 Plugin C<ping>
=over 4
diff --git a/src/perl.c b/src/perl.c
index f42708d..c997749 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -85,7 +85,7 @@ static const char *config_keys[] =
{
"LoadPlugin",
"BaseName",
- NULL
+ "IncludeDir"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
@@ -973,6 +973,11 @@ static int perl_config (const char *key, const char *value)
strncpy (base_name, value, sizeof (base_name));
base_name[sizeof (base_name) - 1] = '\0';
}
+ else if (0 == strcasecmp (key, "IncludeDir")) {
+ Perl_av_unshift (perl, GvAVn (PL_incgv), 1);
+ Perl_av_store (perl, GvAVn (PL_incgv),
+ 0, Perl_newSVpv (perl, value, strlen (value)));
+ }
else {
return -1;
}
--
1.4.4.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20070422/27e48705/attachment.pgp
More information about the collectd
mailing list