plugin_register
plugin_unregister
plugin_dispatch_values
+ plugin_get_interval
plugin_write
plugin_flush
plugin_flush_one
my %cf_callbacks : shared = ();
my %types = (
+ TYPE_CONFIG, "config",
TYPE_INIT, "init",
TYPE_READ, "read",
TYPE_WRITE, "write",
FC_TARGET, "invoke"
);
+my %fc_cb_types = (
+ FC_CB_EXEC, "exec",
+ FC_CB_CREATE, "create",
+ FC_CB_DESTROY, "destroy"
+);
+
foreach my $type (keys %types) {
$plugins[$type] = &share ({});
}
my $type = shift;
my %plugins;
+ my $interval;
our $cb_name = undef;
}
if (TYPE_LOG != $type) {
- DEBUG ("Collectd::plugin_call: type = \"$type\", args=\"@_\"");
+ DEBUG ("Collectd::plugin_call: type = \"$type\" ("
+ . $types{$type} . "), args=\""
+ . join(', ', map { defined($_) ? $_ : '<undef>' } @_) . "\"");
}
if (! defined $plugins[$type]) {
%plugins = %{$plugins[$type]};
}
+ $interval = plugin_get_interval ();
+
foreach my $plugin (keys %plugins) {
my $p = $plugins{$plugin};
my $status = 0;
if ($p->{'wait_left'} > 0) {
- $p->{'wait_left'} -= $interval_g;
+ $p->{'wait_left'} -= $interval;
}
next if ($p->{'wait_left'} > 0);
if ($status) {
$p->{'wait_left'} = 0;
- $p->{'wait_time'} = $interval_g;
+ $p->{'wait_time'} = $interval;
}
elsif (TYPE_READ == $type) {
- if ($p->{'wait_time'} < $interval_g) {
- $p->{'wait_time'} = $interval_g;
+ if ($p->{'wait_time'} < $interval) {
+ $p->{'wait_time'} = $interval;
}
$p->{'wait_left'} = $p->{'wait_time'};
my $data = shift;
DEBUG ("Collectd::plugin_register: "
- . "type = \"$type\", name = \"$name\", data = \"$data\"");
+ . "type = \"$type\" (" . $types{$type}
+ . "), name = \"$name\", data = \"$data\"");
if (! ((defined $type) && (defined $name) && (defined $data))) {
ERROR ("Usage: Collectd::plugin_register (type, name, data)");
}
%p = (
- wait_time => $interval_g,
+ wait_time => plugin_get_interval (),
wait_left => 0,
cb_name => $data,
);
my $type = shift;
my $name = shift;
- DEBUG ("Collectd::plugin_unregister: type = \"$type\", name = \"$name\"");
+ DEBUG ("Collectd::plugin_unregister: type = \"$type\" ("
+ . $types{$type} . "), name = \"$name\"");
if (! ((defined $type) && (defined $name))) {
ERROR ("Usage: Collectd::plugin_unregister (type, name)");
}
}
-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);
-}
-
sub fc_call {
my $type = shift;
my $name = shift;
}
DEBUG ("Collectd::fc_call: "
- . "type = \"$type\", name = \"$name\", cb_type = \"$cb_type\"");
+ . "type = \"$type\" (" . $fc_types{$type}
+ . "), name = \"$name\", cb_type = \"$cb_type\" ("
+ . $fc_cb_types{$cb_type} . ")");
{
lock %{$fc_plugins[$type]};
my %fc : shared;
DEBUG ("Collectd::fc_register: "
- . "type = \"$type\", name = \"$name\", proc = \"$proc\"");
+ . "type = \"$type\" (" . $fc_types{$type}
+ . "), name = \"$name\", proc = \"$proc\"");
if (! ((defined $type) && (defined $name) && (defined $proc))) {
ERROR ("Usage: Collectd::fc_register(type, name, proc)");