rsyslog regex基于表达式的过滤器

时间:2019-06-24 15:19:18

标签: if-statement rsyslog

我想使用正则表达式过滤IP地址并触发模板名称“ DynFile”或“ HostnameDynFile”。有人可以请教吗?

template (name="DynFile" type="string" string="/opt/log/%FROMHOST-IP%/syslog.log")
template (name="HostnameDynFile" type="string" string="/opt/log/%HOSTNAME%/syslog.log")

if $fromhost-ip regex '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' then {
   action(type="omfile" dynaFile="DynFile"
} else { action(type="omfile" dynaFile="HostnameDynFile" }

0 个答案:

没有答案