summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44c7818)
raw | patch | inline | side by side (parent: 44c7818)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 21 Aug 2008 08:45:43 +0000 (10:45 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Thu, 21 Aug 2008 09:12:58 +0000 (11:12 +0200) |
plugin_flush() now accepts three parameters, 'timeout', 'plugins' and
'identifiers'. The meaning of the former two did not change. 'identifiers' may
be a string or an array of strings specifying identifiers that are to be
passed along to the plugins' flush callbacks. This brings the Perl API in sync
with the C API.
plugin_flush_one() and plugin_flush_all() have been re-implemented in plain
Perl and marked as deprecated. A new XSUB, Collectd::_plugin_flush, has been
added which provides a small wrapper around the C implementation of
plugin_flush().
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
'identifiers'. The meaning of the former two did not change. 'identifiers' may
be a string or an array of strings specifying identifiers that are to be
passed along to the plugins' flush callbacks. This brings the Perl API in sync
with the C API.
plugin_flush_one() and plugin_flush_all() have been re-implemented in plain
Perl and marked as deprecated. A new XSUB, Collectd::_plugin_flush, has been
added which provides a small wrapper around the C implementation of
plugin_flush().
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
bindings/perl/Collectd.pm | patch | blob | history | |
src/collectd-perl.pod | patch | blob | history | |
src/perl.c | patch | blob | history |
index afe92b2ccc57b5779f5770601ad4b10b61fe30eb..bfc30805d3cb86204a8ef7a10bb43f2cf4ee6f64 100644 (file)
my %args = @_;
my $timeout = -1;
+ my @plugins = ();
+ my @ids = ();
DEBUG ("Collectd::plugin_flush:"
. (defined ($args{'timeout'}) ? " timeout = $args{'timeout'}" : "")
- . (defined ($args{'plugins'}) ? " plugins = $args{'plugins'}" : ""));
+ . (defined ($args{'plugins'}) ? " plugins = $args{'plugins'}" : "")
+ . (defined ($args{'identifiers'})
+ ? " identifiers = $args{'identifiers'}" : ""));
if (defined ($args{'timeout'}) && ($args{'timeout'} > 0)) {
$timeout = $args{'timeout'};
}
- if (! defined $args{'plugins'}) {
- plugin_flush_all ($timeout);
+ if (defined ($args{'plugins'})) {
+ if ("ARRAY" eq ref ($args{'plugins'})) {
+ @plugins = @{$args{'plugins'}};
+ }
+ else {
+ @plugins = ($args{'plugins'});
+ }
}
else {
- if ("ARRAY" eq ref ($args{'plugins'})) {
- foreach my $plugin (@{$args{'plugins'}}) {
- plugin_flush_one ($timeout, $plugin);
- }
+ @plugins = (undef);
+ }
+
+ if (defined ($args{'identifiers'})) {
+ if ("ARRAY" eq ref ($args{'identifiers'})) {
+ @ids = @{$args{'identifiers'}};
}
else {
- plugin_flush_one ($timeout, $args{'plugins'});
+ @ids = ($args{'identifiers'});
}
}
+ else {
+ @ids = (undef);
+ }
+
+ foreach my $plugin (@plugins) {
+ foreach my $id (@ids) {
+ _plugin_flush($plugin, $timeout, $id);
+ }
+ }
+}
+
+sub plugin_flush_one {
+ my $timeout = shift;
+ my $name = shift;
+
+ WARNING ("Collectd::plugin_flush_one is deprecated - "
+ . "use Collectd::plugin_flush instead.");
+
+ if (! (defined ($timeout) && defined ($name))) {
+ ERROR ("Usage: Collectd::plugin_flush_one(timeout, name)");
+ return;
+ }
+
+ plugin_flush (plugins => $name, timeout => $timeout);
+}
+
+sub plugin_flush_all {
+ my $timeout = shift;
+
+ WARNING ("Collectd::plugin_flush_all is deprecated - "
+ . "use Collectd::plugin_flush instead.");
+
+ if (! defined ($timeout)) {
+ ERROR ("Usage: Collectd::plugin_flush_all(timeout)");
+ return;
+ }
+
+ plugin_flush (timeout => $timeout);
}
1;
diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod
index b7ae9cace9c89f636172c1d27e5ccc5fbd4b3c9c..6396bc8e89e9886fdadb7a16cd25661ab5887919 100644 (file)
--- a/src/collectd-perl.pod
+++ b/src/collectd-perl.pod
for backwards compatibility but has been deprecated and will be removed in
some future version of collectd.
-=item B<plugin_flush> ([B<timeout> => I<timeout>,] [B<plugins> => I<...>])
+=item B<plugin_flush> ([B<timeout> => I<timeout>][, B<plugins> => I<...>][,
+B<identifiers> => I<...>])
-Flush one or more plugins. I<timeout> is passed on to the registered
-flush-callbacks. If omitted, C<-1> is used. If the I<plugins> argument has
-been specified, only named plugins will be flushed. The argument's value may
-either be a string or a reference to an array of strings.
+Flush one or more plugins. I<timeout> and the specified I<identifiers> are
+passed on to the registered flush-callbacks. If omitted, the timeout defaults
+to C<-1>. The identifier defaults to the undefined value. If the I<plugins>
+argument has been specified, only named plugins will be flushed. The value of
+the B<plugins> and B<identifiers> arguments may either be a string or a
+reference to an array of strings.
=item B<plugin_flush_one> (I<timeout>, I<plugin>)
This is identical to using "plugin_flush (timeout =E<gt> I<timeout>, plugins
=E<gt> I<plugin>".
+B<Note>: Starting with version 4.5 of collectd, B<plugin_flush_one> has been
+deprecated and will be removed in some future version of collectd. Use
+B<plugin_flush> instead.
+
=item B<plugin_flush_all> (I<timeout>)
This is identical to using "plugin_flush (timeout =E<gt> I<timeout>)".
+B<Note>: Starting with version 4.5 of collectd, B<plugin_flush_all> has been
+deprecated and will be removed in some future version of collectd. Use
+B<plugin_flush> instead.
+
=item B<plugin_dispatch_notification> (I<notification>)
Submits a I<notification> to the daemon which will then pass it to all
diff --git a/src/perl.c b/src/perl.c
index 268e1d1428968b5d0eb4f9269ec7e2a004615bcc..e6bb25ef21ec2c86330d92666b9b5852f08554b8 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
static XS (Collectd_plugin_register_ds);
static XS (Collectd_plugin_unregister_ds);
static XS (Collectd_plugin_dispatch_values);
-static XS (Collectd_plugin_flush_one);
-static XS (Collectd_plugin_flush_all);
+static XS (Collectd__plugin_flush);
static XS (Collectd_plugin_dispatch_notification);
static XS (Collectd_plugin_log);
static XS (Collectd_call_by_name);
{ "Collectd::plugin_register_data_set", Collectd_plugin_register_ds },
{ "Collectd::plugin_unregister_data_set", Collectd_plugin_unregister_ds },
{ "Collectd::plugin_dispatch_values", Collectd_plugin_dispatch_values },
- { "Collectd::plugin_flush_one", Collectd_plugin_flush_one },
- { "Collectd::plugin_flush_all", Collectd_plugin_flush_all },
+ { "Collectd::_plugin_flush", Collectd__plugin_flush },
{ "Collectd::plugin_dispatch_notification",
Collectd_plugin_dispatch_notification },
{ "Collectd::plugin_log", Collectd_plugin_log },
} /* static XS (Collectd_plugin_dispatch_values) */
/*
- * Collectd::plugin_flush_one (timeout, name).
+ * Collectd::_plugin_flush (plugin, timeout, identifier).
+ *
+ * plugin:
+ * name of the plugin to flush
*
* timeout:
* timeout to use when flushing the data
*
- * name:
- * name of the plugin to flush
+ * identifier:
+ * data-set identifier to flush
*/
-static XS (Collectd_plugin_flush_one)
+static XS (Collectd__plugin_flush)
{
+ char *plugin = NULL;
+ int timeout = -1;
+ char *id = NULL;
+
dXSARGS;
- if (2 != items) {
- log_err ("Usage: Collectd::plugin_flush_one(timeout, name)");
+ if (3 != items) {
+ log_err ("Usage: Collectd::_plugin_flush(plugin, timeout, id)");
XSRETURN_EMPTY;
}
- log_debug ("Collectd::plugin_flush_one: timeout = %i, name = \"%s\"",
- (int)SvIV (ST (0)), SvPV_nolen (ST (1)));
+ if (SvOK (ST (0)))
+ plugin = SvPV_nolen (ST (0));
- if (0 == plugin_flush_one ((int)SvIV (ST (0)), SvPV_nolen (ST (1))))
- XSRETURN_YES;
- else
- XSRETURN_EMPTY;
-} /* static XS (Collectd_plugin_flush_one) */
-
-/*
- * Collectd::plugin_flush_all (timeout).
- *
- * timeout:
- * timeout to use when flushing the data
- */
-static XS (Collectd_plugin_flush_all)
-{
- dXSARGS;
+ if (SvOK (ST (1)))
+ timeout = (int)SvIV (ST (1));
- if (1 != items) {
- log_err ("Usage: Collectd::plugin_flush_all(timeout)");
- XSRETURN_EMPTY;
- }
+ if (SvOK (ST (2)))
+ id = SvPV_nolen (ST (2));
- log_debug ("Collectd::plugin_flush_all: timeout = %i", (int)SvIV (ST (0)));
+ log_debug ("Collectd::_plugin_flush: plugin = \"%s\", timeout = %i, "
+ "id = \"%s\"", plugin, timeout, id);
- plugin_flush_all ((int)SvIV (ST (0)));
- XSRETURN_YES;
-} /* static XS (Collectd_plugin_flush_all) */
+ if (0 == plugin_flush (plugin, timeout, id))
+ XSRETURN_YES;
+ else
+ XSRETURN_EMPTY;
+} /* static XS (Collectd__plugin_flush) */
/*
* Collectd::plugin_dispatch_notification (notif).