Re: [collectd] Collectd complex perl plugin question ...
Hi, On Wed, Apr 04, 2012 at 10:58:07AM +0200, Sebastian Harl wrote: However, you could simple skip a couple of intervals in the read callback function. I.e., use a global variable (for each instance of the callback) to count down the number of intervals to be skipped. Make sure to return 0 in case you skip the current interval. Then, manually set the interval appropriately when dispatching values. Here's my two cents of what I have in all my perl plugins to handle the Interval config option: -- package Collectd::Plugins::Mine; use Collectd qw( :all ); my $interval = $interval_g; my $hostname = $hostname_g; my $last_ts = time(); [...] sub my_config { for my $child (@{$_[0] - {children}}) { if ($child - {key} eq Interval) { $interval = $child - {values} - [0]; [...] sub my_get { my $ts = time; return 1 if ($ts $interval + $last_ts); [...] plugin_dispatch_values(...); [...] $last_ts = $ts; return 1; } -- Cheers ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Collectd complex perl plugin question ...
Hi, On Wed, Apr 04, 2012 at 12:53:18PM +, Sebastien Cramatte wrote: Thanks a lot for snippet. I've still have an issue :( Found a configuration for the Mine plugin, but the plugin isn't loaded or didn't register a configuration callback. In my plugin source I've got this line ... plugin_register (TYPE_CONFIG, mine, mine_config); Any Idea of what occurs ? Yes I scratched my head quite a bit on that one :-) The BaseName/LoadPlugin directive will select the right perl Module. The Plugin ... directive refers to the plugin_register() callback's plugin name. If your __PACKAGE__ is Collectd::Plugins::Mine, and is calling plugin_register ([...], mine) you need something like: -- LoadPlugin perl Globals true /LoadPlugin Plugin perl BaseName Collectd::Plugins LoadPlugin Mine [... this will look for PERL5LIB(s).../Collectd/Plugins/Mine.pm ...] Plugin mine [... this will register with the plugin called mine ...] Interval300 [...] /Plugin /Plugin ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd