当我有一个规则的时候
if ($msg contains "foobah"
OR re_match($msg, '(authmgr|cli)\[[0-9]+\]:')
)
then {rsyslog最终抛出了一个分段错误。即使我注释掉了包含re_match的行,它仍然会抛出一个分段错误。
rsyslogd 8.24.0-34.el7, compiled with:
PLATFORM: x86_64-redhat-linux-gnu
PLATFORM (lsb_release -d):
FEATURE_REGEXP: Yes
GSSAPI Kerberos 5 support: Yes
FEATURE_DEBUG (debug build, slow code): No
32bit Atomic operations supported: Yes
64bit Atomic operations supported: Yes
memory allocator: system default
Runtime Instrumentation (slow code): No
uuid support: Yes
Number of Bits in RainerScript integers: 64我希望此规则匹配包含authmgr[123]:或cli:[456]:的事件。
有人能确认正则表达式的格式是正确的,并解释为什么注释掉该行会导致分段错误吗?
发布于 2019-04-18 15:40:41
答案似乎是你需要在字符串中转义反斜杠,所以这应该是可行的:
re_match($msg, '(authmgr|cli)\\[[0-9]+\\]:')在我的rsyslog版本8.30.0中,如果你不这样做,你会得到一条错误消息,它提供了一个线索:表达式中的无效字符‘’-是否在某个地方有一个无效的转义序列?
有一个online tool可以正确转义字符串。如果您提供a\b,它将生成a\\b。
https://stackoverflow.com/questions/55719647
复制相似问题