From 65d25664df9fdc9bedf23f02a981b85cd6722970 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 14 Nov 2012 18:55:43 +0100 Subject: [PATCH] perl plugin: Export plugin_get_interval() to Perl plugins. --- bindings/perl/lib/Collectd.pm | 1 + src/collectd-perl.pod | 7 +++++++ src/perl.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/bindings/perl/lib/Collectd.pm b/bindings/perl/lib/Collectd.pm index ca3b5d23..251412cf 100644 --- a/bindings/perl/lib/Collectd.pm +++ b/bindings/perl/lib/Collectd.pm @@ -42,6 +42,7 @@ our %EXPORT_TAGS = ( plugin_register plugin_unregister plugin_dispatch_values + plugin_get_interval plugin_write plugin_flush plugin_flush_one diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod index d5401dd4..a19274e4 100644 --- a/src/collectd-perl.pod +++ b/src/collectd-perl.pod @@ -415,6 +415,13 @@ The message is passed to all log-callbacks that are registered with collectd. Wrappers around B, using B, B, B, B and B respectively as I. +=item B () + +Returns the interval of the current plugin as a floating point number in +seconds. This value depends on the interval configured within the +C block or the global interval (see L for +details). + =back The following function provides the filter chain C-interface to Perl-modules. diff --git a/src/perl.c b/src/perl.c index f8a48227..e5dc6c75 100644 --- a/src/perl.c +++ b/src/perl.c @@ -102,6 +102,7 @@ void boot_DynaLoader (PerlInterpreter *, CV *); static XS (Collectd_plugin_register_ds); static XS (Collectd_plugin_unregister_ds); static XS (Collectd_plugin_dispatch_values); +static XS (Collectd_plugin_get_interval); static XS (Collectd__plugin_write); static XS (Collectd__plugin_flush); static XS (Collectd_plugin_dispatch_notification); @@ -177,6 +178,7 @@ static struct { { "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_get_interval", Collectd_plugin_get_interval }, { "Collectd::_plugin_write", Collectd__plugin_write }, { "Collectd::_plugin_flush", Collectd__plugin_flush }, { "Collectd::plugin_dispatch_notification", @@ -1659,6 +1661,21 @@ static XS (Collectd_plugin_dispatch_values) XSRETURN_EMPTY; } /* static XS (Collectd_plugin_dispatch_values) */ +/* + * Collectd::plugin_get_interval (). + */ +static XS (Collectd_plugin_get_interval) +{ + dXSARGS; + + /* make sure we don't get any unused variable warnings for 'items'; + * don't abort, though */ + if (items) + log_err ("Usage: Collectd::plugin_get_interval()"); + + XSRETURN_NV ((NV) CDTIME_T_TO_DOUBLE (plugin_get_interval ())); +} /* static XS (Collectd_plugin_get_interval) */ + /* Collectd::plugin_write (plugin, ds, vl). * * plugin: -- 2.30.2