$cb_name = $p->{'cb_name'};
$status = call_by_name (@_);
- if (! defined $status) {
+ if (! $status) {
+ my $err = undef;
+
+ if ($@) {
+ $err = $@;
+ }
+ else {
+ $err = "callback returned false";
+ }
+
if (TYPE_LOG != $type) {
- ERROR ("Could not execute callback \"$cb_name\": $@");
+ ERROR ("Execution of callback \"$cb_name\" failed: $err");
}
- next;
+ $status = 0;
}
if ($status) {
$p->{'wait_time'} = 10;
}
elsif (TYPE_READ == $type) {
+ WARNING ("${plugin}->read() failed with status $status. "
+ . "Will suspend it for $p->{'wait_left'} seconds.");
+
$p->{'wait_left'} = $p->{'wait_time'};
$p->{'wait_time'} *= 2;
if ($p->{'wait_time'} > 86400) {
$p->{'wait_time'} = 86400;
}
-
- WARNING ("${plugin}->read() failed with status $status. "
- . "Will suspend it for $p->{'wait_left'} seconds.");
}
elsif (TYPE_INIT == $type) {
+ ERROR ("${plugin}->init() failed with status $status. "
+ . "Plugin will be disabled.");
+
foreach my $type (keys %types) {
plugin_unregister ($type, $plugin);
}
-
- ERROR ("${plugin}->init() failed with status $status. "
- . "Plugin will be disabled.");
}
elsif (TYPE_LOG != $type) {
WARNING ("${plugin}->$types{$type}() failed with status $status.");
=back
+Any function may set the B<$@> variable to describe errors in more detail. The
+message will be passed on to the user using collectd's logging mechanism.
+
See the documentation of the B<plugin_register> method in the section
"METHODS" below for the number and types of arguments passed to each
B<callback function>. This section also explains how to register B<callback