1

问题是我在 syslog 文件中看不到预期的输出。我写了一个 Python 插件,位于“/home/my/collectd/pyPlugin.py”。“/etc/collectd/collectd.conf”中的 Collectd 配置(Python 插件启用了 globals true)有这个块:

<Plugin python>
    ModulePath "/home/my/collectd/"
    LogTraces true
    Interactive false
    Import pyPlugin

    <Module pyPlugin>
        Test "arg1" "arg2"
    </Module>
</Plugin>

该插件非常简单:

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)

当我查看“/var/log/syslog”时,我看不到任何输出。

4

1 回答 1

1

把它放在你的 collectd.conf 文件的顶部:LoadPlugin "syslog"

常见问题解答

为了获得任何输出,您需要加载一个日志插件。两个主要的日志插件是 LogFile 和 SysLog 插件。我们建议您首先在配置文件中加载其中一个插件,即将 LoadPlugin 行放在最顶部。如果没有加载日志插件,collectd 将写入 STDERR。但是,在守护进程分叉到后台后,您将无法再看到此输出。

默认情况下,系统日志插件将显示info级别。还要确认 Collectd 正在运行,请查看进程列表或/etc/init.d/collectd status.

于 2014-05-21T18:26:01.033 回答