【问题标题】:run bash script when ERROR spotted in logs in nxlog在 nxlog 的日志中发现错误时运行 bash 脚本
【发布时间】:2020-05-05 10:58:50
【问题描述】:

每次在日志中发现错误时,我都会尝试运行脚本

<Extension _exec>
    Module  xm_exec
</Extension>

<Input in>
    Module  im_file
    File    "/home/rafal/gitprojects/mst-sender/hub.cloudradar-error.log"
        <Exec>
        if $raw_event =~ /(\S+)\ (.+) \[ERROR (.+)/
        {
                exec_async("/bin/sh", "/home/rafal/gitprojects/mst-sender/run.sh");
        }

        </Exec>
</Input>

从他们的文档看来,如果正则表达式匹配,它应该执行异步,但我只看到以下日志 警告没有启动未使用的模块 并且脚本没有被执行。 我不需要输出它,只运行那个脚本。

[更新]添加路线

<Output out1>
    Module  om_null
</Output>

<Route 1>
    # Basic route
    Path    in => out1
</Route>

【问题讨论】:

    标签: nxlog


    【解决方案1】:

    我不需要输出它,只运行那个脚本。

    你需要。
    您可以做的是使用om_null 创建一个路由,以便丢弃输出。

    【讨论】:

    • 是的,我得到了它的工作,这有帮助,我的代码中有一个小错字,谢谢
    猜你喜欢
    • 2016-02-24
    • 1970-01-01
    • 1970-01-01
    • 2016-08-19
    • 2019-10-18
    • 2014-03-28
    • 2014-12-08
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多