summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 71d217e)
raw | patch | inline | side by side (parent: 71d217e)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 27 Apr 2008 18:56:09 +0000 (20:56 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 30 Apr 2008 08:40:50 +0000 (10:40 +0200) |
This adds the following functions to collectd's Perl API which flush the
given plugins using the given interval.
* Collectd::plugin_flush:
This function is a frontend to _flush_one() and _flush_all() and
expects up to two named parameters:
- timeout => $timeout
- name => $name or [ $name1, $name2, ... ]
* Collectd::plugin_flush_one:
This function expects exactly two parameters, namely the timeout and
the plugin name.
* Collectd::plugin_flush_all:
This function expects a single parameter, namely the timeout.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
given plugins using the given interval.
* Collectd::plugin_flush:
This function is a frontend to _flush_one() and _flush_all() and
expects up to two named parameters:
- timeout => $timeout
- name => $name or [ $name1, $name2, ... ]
* Collectd::plugin_flush_one:
This function expects exactly two parameters, namely the timeout and
the plugin name.
* Collectd::plugin_flush_all:
This function expects a single parameter, namely the timeout.
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/perl.c | patch | blob | history |
index 399fca84fa592c3e37ff4974b8f55d1b745f9036..ee265e8026e9d9f39eee3a426e548bcddd8e15c2 100644 (file)
plugin_register
plugin_unregister
plugin_dispatch_values
+ plugin_flush
+ plugin_flush_one
+ plugin_flush_all
plugin_dispatch_notification
plugin_log
) ],
}
}
+sub plugin_flush {
+ my %args = @_;
+
+ my $timeout = -1;
+
+ DEBUG ("Collectd::plugin_flush:"
+ . (defined ($args{'timeout'}) ? " timeout = $args{'timeout'}" : "")
+ . (defined ($args{'name'}) ? " name = $args{'name'}" : ""));
+
+ if (defined ($args{'timeout'}) && ($args{'timeout'} > 0)) {
+ $timeout = $args{'timeout'};
+ }
+
+ if (! defined $args{'name'}) {
+ plugin_flush_all ($timeout);
+ }
+ else {
+ if ("ARRAY" eq ref ($args{'name'})) {
+ foreach my $name (@{$args{'name'}}) {
+ plugin_flush_one ($timeout, $name);
+ }
+ }
+ else {
+ plugin_flush_one ($timeout, $args{'name'});
+ }
+ }
+}
+
1;
# vim: set sw=4 ts=4 tw=78 noexpandtab :
diff --git a/src/perl.c b/src/perl.c
index beea288afc6bc154cedadd62de83da0b7558979a..66a9dbc60e4ccf30991ee53fba044adfc70d89e6 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_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_dispatch_notification",
Collectd_plugin_dispatch_notification },
{ "Collectd::plugin_log", Collectd_plugin_log },
XSRETURN_EMPTY;
} /* static XS (Collectd_plugin_dispatch_values) */
+/*
+ * Collectd::plugin_flush_one (timeout, name).
+ *
+ * timeout:
+ * timeout to use when flushing the data
+ *
+ * name:
+ * name of the plugin to flush
+ */
+static XS (Collectd_plugin_flush_one)
+{
+ dXSARGS;
+
+ if (2 != items) {
+ log_err ("Usage: Collectd::plugin_flush_one(timeout, name)");
+ XSRETURN_EMPTY;
+ }
+
+ log_debug ("Collectd::plugin_flush_one: timeout = %i, name = \"%s\"",
+ (int)SvIV (ST (0)), SvPV_nolen (ST (1)));
+
+ 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 (1 != items) {
+ log_err ("Usage: Collectd::plugin_flush_all(timeout)");
+ XSRETURN_EMPTY;
+ }
+
+ log_debug ("Collectd::plugin_flush_all: timeout = %i", (int)SvIV (ST (0)));
+
+ plugin_flush_all ((int)SvIV (ST (0)));
+ XSRETURN_YES;
+} /* static XS (Collectd_plugin_flush_all) */
+
/*
* Collectd::plugin_dispatch_notification (notif).
*