【问题标题】:Rsyslog: how to negate 'contains' in if-then statementRsyslog:如何在 if-then 语句中否定“包含”
【发布时间】:2018-12-01 17:57:14
【问题描述】:
if $programname == "service" then {
     if $msg !contains "test" then
         action(type="omfwd" 
            target="10.0.0.5"
            ...
            ) 
}

我正在尝试排除包含单词“test”的消息。不知道如何否定“包含”。

document 看来,它似乎是“!包含”。试过但没有运气。

有什么想法吗?

【问题讨论】:

    标签: rsyslog


    【解决方案1】:

    用于否定的语法! 适用于表单的遗留选择器

    :msg, !contains, "test"  /some/file
    

    您正在使用 RainerScript,因此适当的语法是关键字not

    if not ($msg contains "test") then
    

    【讨论】:

    • 太棒了!谢谢!
    猜你喜欢
    • 2013-01-14
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    相关资源
    最近更新 更多