[collectd] Collectd complex perl plugin question ...
Fabien Wernli
collectd at faxm0dem.org
Wed Apr 4 13:50:10 CEST 2012
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
More information about the collectd
mailing list