【问题标题】:rsyslog config with both "$msg contains" and "$fromhost-ip startswith"带有“$msg contains”和“$fromhost-ip startswith”的 rsyslog 配置
【发布时间】:2021-04-22 15:35:51
【问题描述】:

我可以在 rsyslog 配置中同时使用 "$msg contains" 和 "$fromhost-ip startswith" 语句吗?

当我使用 follow 进行 rsyslog 配置时,它可以工作!

if $msg contains 'src_port=6699' then -?DynFileA
& ~
if $fromhost-ip startswith '10.10.10.1' then -?DynFileB
& ~

但是当我将它们结合起来时,它失败了!

if $fromhost-ip startswith '10.10.10.1' and $msg !contains 'src_port=6699' then -?DynFileA
& ~

我从网上搜索了很多文章,尤其是 rsyslog 办公文档,但没有找到任何有用的建议!

谁能告诉我怎么做?

【问题讨论】:

    标签: config rsyslog


    【解决方案1】:

    嗯...你确定你的替代品吗?乍一看,如果您的主机 IP 是 10.10.10.1,您将应用 -?DynFileA 而不是 -?DynFileB。你的第一个例子有两个不同的操作......(不知道它是什么)

    问候,

    【讨论】:

      【解决方案2】:

      我现在只想使用完整的 rsyslog Reiner 脚本,您的第一个示例是 ,而不是具有两个不同动态文件模板的 ,如果这是您想要的只需将下面的 and 替换为 or

      if ($fromhost-ip startswith '10.10.10.1') and ($msg !contains 'src_port=6699') then {
          -?DynFileA
          stop
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-10
        • 2016-08-29
        • 2021-01-07
        • 1970-01-01
        • 2012-03-18
        • 2011-03-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多