summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b10fcf)
raw | patch | inline | side by side (parent: 3b10fcf)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 17 Nov 2007 17:45:58 +0000 (18:45 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 20 Nov 2007 08:04:43 +0000 (09:04 +0100) |
If call_by_name() failed, it will be handled the same way as if the callback
returned "false". The $@ variable may now be used by plugins as well to
describe errors in greater detail.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
returned "false". The $@ variable may now be used by plugins as well to
describe errors in greater detail.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
bindings/perl/Collectd.pm | patch | blob | history | |
src/collectd-perl.pod | patch | blob | history |
index 8c3159c71939c8cd83611e7dd7096d1050b71e2c..2de98850f5eeb6808aed5d040acf5fc40c816070 100644 (file)
$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.");
diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod
index 2b7766740540a51dd7731a6f0e09320155526a22..73bacc6d67713eed826386af90b4a3a7f17de94f 100644 (file)
--- a/src/collectd-perl.pod
+++ b/src/collectd-perl.pod
=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