3

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");
Martin
  • 33
  • 5

1 Answers1

1

Post your configuration if you can.

The documentation says that the LoadPlugin configuration goes in the collectd.conf file (not that that seems to matter in your case from your log file).

Put your foobar.pm module at /path/to/perl/plugins/Collectd/Plugins/FoorBar.pm matching it with the path that you specified ... (match the case of names of plugin and plugin pm file).

LoadPlugin perl
# ...
<Plugin perl>
  IncludeDir "/path/to/perl/plugins"
  BaseName "Collectd::Plugins"
  EnableDebugger ""
  LoadPlugin "FooBar"

  <Plugin FooBar>
    Foo "Bar"
  </Plugin>
</Plugin>
blackpen
  • 2,339
  • 13
  • 15
  • I use the command `LoadPlugin name_of_my_plugin` . Because it is my own plugin, so I need somehow register functions/method there, but I wasnt successful in it in spite of the documentation instructions. – Martin Oct 03 '16 at 07:29
  • Unfortunalety not. With the DBI plugin and Postgres database - it ends on this log: `dbi plugin: cdbi_connect_database: dbi_driver_open_r (Pg) failed. severity=err` – Martin Oct 03 '16 at 09:18
  • I hope that it works now. The driver is not Pg but pgsql. Thank you – Martin Oct 03 '16 at 10:05
  • Check if you are able to connect it postgres db from outside, on command-line using Perl. If that is the case, then you may need to replicate the same PATH, LD_LIBRARY_PATH to your collectd server (In order to possibly find the correct postgres library). – blackpen Oct 03 '16 at 10:32