Syslog-ng:如何在发送到远程主机之前更改消息

Syslog-ng:如何在发送到远程主机之前更改消息

我在 SLES 10 上使用syslog-ng 1.6.8。从这台机器,我需要将所有事件转发到远程主机 10.30.38.115。但首先我必须稍微更改消息,在事件末尾添加“MyMark”前缀。我尝试了以下操作:

source src {
       internal();
       unix-dgram("/dev/log");
};


destination editredirect { udp("10.30.38.115" port(514) template("<$PRI> $DATE $HOST $MSG MyMark\n") ); };

log { source(src); destination(editredirect); };

但它不起作用。在远程主机上,我根本收不到这些消息。说实话,即使我删除模板,我也收不到它们。远程主机配置为接受传入消息,它确实可以接受。

所以,我的问题是如何调整syslog-ng.conf,以便我可以在将消息发送到远程主机之前更改消息。

更新:已解决

重定向的组织方式如下:

远程机器:

source src {
        #
        # include internal syslog-ng messages
        # note: the internal() soure is required!
        #
        internal();

        #
        # the default log socket for local logging:
        #
        unix-dgram("/dev/log");

        #
        # uncomment to process log messages from network:
        #
        udp(ip("0.0.0.0") port(514));
        tcp(ip("0.0.0.0") port(1470)); };

本地机器:

source src {
        #
        # include internal syslog-ng messages
        # note: the internal() soure is required!
        #
        internal();

        #
        # the following line will be replaced by the
        # socket list generated by SuSEconfig using
        # variables from /etc/sysconfig/syslog:
        #
        #unix-dgram("/dev/log");
        unix-stream("/dev/log");

        #
        # uncomment to process log messages from network:
        #
        #udp(ip("0.0.0.0") port(514));
};


destination editredirect { tcp("10.30.38.115" port(1470) template("<$PRI> $DATE $HOST $MSG MyMark\n")); };
log { source(src); destination(editredirect); };

答案1

尝试这个

source src {

        internal();
        unix-stream("/dev/log");
};


destination editredirect { tcp("10.30.38.115" port(1470) template("$FULLDATE $PROGRAM  $MSGONLY MyMark \n") template_escape(no)); };
log { source(src); destination(editredirect); };

答案2

重定向的组织方式如下:

Remote machine:

source src {
    #
    # include internal syslog-ng messages
    # note: the internal() soure is required!
    #
    internal();

    #
    # the default log socket for local logging:
    #
    unix-dgram("/dev/log");

    #
    # uncomment to process log messages from network:
    #
    udp(ip("0.0.0.0") port(514));
    tcp(ip("0.0.0.0") port(1470)); };
Local machine:

source src {
    #
    # include internal syslog-ng messages
    # note: the internal() soure is required!
    #
    internal();

    #
    # the following line will be replaced by the
    # socket list generated by SuSEconfig using
    # variables from /etc/sysconfig/syslog:
    #
    #unix-dgram("/dev/log");
    unix-stream("/dev/log");

    #
    # uncomment to process log messages from network:
    #
    #udp(ip("0.0.0.0") port(514));

};

destination editredirect { tcp("10.30.38.115" port(1470) template("<$PRI> $DATE $HOST $MSG MyMark\n")); };
log { source(src); destination(editredirect); };

相关内容