I would like to ask about Collectd's plugins Perl and Python and their registration functions.
I tried to code plugin in Perl (and also in Python), set up read and write functions and after that register them into Collectd (plugin_register functions). In all cases it wasnt working. Everytime, the logs show:
Found a configuration for the "my_plugin" plugin, but the plugin isn't loaded or didn't register a configuration callback. severity=warning
I load my plugin in perl.conf.
Below I attach example of plugin which is directly from Collectd.perl documentation. This plugin, as well as my plugin, has the same result.
package Collectd::Plugins::FooBar;
use strict;
use warnings;
use Collectd qw( :all );
sub foobar_read
{
my $vl = { plugin => 'foobar', type => 'gauge' };
$vl->{'values'} = [ rand(42) ];
plugin_dispatch_values ($vl);
return 1;
}
sub foobar_write
{
my ($type, $ds, $vl) = @_;
for (my $i = 0; $i < scalar (@$ds); ++$i) {
print "$vl->{'plugin'} ($vl->{'type'}): $vl->{'values'}->[$i]\n";
}
return 1;
}
sub foobar_match
{
my ($ds, $vl, $meta, $user_data) = @_;
if (matches($ds, $vl)) {
return FC_MATCH_MATCHES;
} else {
return FC_MATCH_NO_MATCH;
}
}
plugin_register (TYPE_READ, "foobar", "foobar_read");
plugin_register (TYPE_WRITE, "foobar", "foobar_write");
fc_register (FC_MATCH, "foobar", "foobar_match");