Python – collectd won’t recognize the python plugin

collectdpython

I am trying to load a super simple plugin I found online as a starting point, and collectd doesn't seem to recognize my python plugin. My conf file has the appropriate lines:

<LoadPlugin python>
    Globals true
</LoadPlugin>

...

<Plugin python>
    ModulePath "/usr/lib/collectd"
    Import "test"

    <module "test">
        test "input"
    </module>

</Plugin>

And my test.py looks like this:

import collectd

def configer(confObj):
    collectd.info('config called')

def init_fun():
    collectd.info('my py module init called')

def reader(input_data=None):
    collectd.info('my py read called')

def writer(input_data=None)
    collectd.info('my py write called')


collectd.register_config(configer)
collectd.register_init(init_fun)
collectd.register_read(reader)
collectd.register_write(writer)

I tried a lot of things including reordering the registers and some other things but no matter what my syslog spits out:

Jul 14 21:10:34 vagrant-ubuntu-trusty-64 collectd[21449]: python plugin: Found a configuration for the "test" plugin, but the plugin isn't loaded or didn't register a configuration callback.
Jul 14 21:10:34 vagrant-ubuntu-trusty-64 collectd[21454]: python plugin: Found a configuration for the "test" plugin, but the plugin isn't loaded or didn't register a configuration callback.

I've been pounding my head for hours and feel totally lost, any help appreciated.

Best Answer

There are two problems:

  1. Missing a trailing : on line 12: "def writer(input_data=None)"
  2. It appears that 'test' as the name of your plugin conflicts with something somewhere in the stack (maybe a 'test' module in python?). Renaming the file test.py to 'foobar.py', and replacing 'test' with 'foobar' in the configuration, causes it to load correctly and 'config called' is output at startup time.
Related Topic