![rsyslog conf ファイル構文 複数のフィルター](https://rvso.com/image/762152/rsyslog%20conf%20%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E6%A7%8B%E6%96%87%20%E8%A4%87%E6%95%B0%E3%81%AE%E3%83%95%E3%82%A3%E3%83%AB%E3%82%BF%E3%83%BC.png)
Red Hat 8 システムで rsyslog を設定しています。ソース IP に基づいてフィルタリングし、次のように特定のファイルにログを書き込む最初の部分が機能しています。
if $fromhost-ip startswith '10.1.2.45' then /var/log/test_all.log
& ~
私がやりたいのは、正しい構文が分からないのですが、ホストIPそしてその認証権限機能を使用してファイルに書き込みます。
上に挙げたステートメントの前にそのステートメントが必要なのはわかっていますが、うまくいきません。local7
(ブート ログ) も試しましたが、これもうまくいきませんでした。次の 2 つの例は、試したがうまくいかなかった構文です。
例1:
if $fromhost-ip startswith '10.1.2.45' and $syslogfacility-text == 'local7' then /var/log/test_boot.log
& stop
if $fromhost-ip startswith '10.1.2.45' and $syslogfacility-text == 'local10' then /var/log/test_secure.log
& stop
if $fromhost-ip startswith '10.1.2.45' then /var/log/test_all.log
& stop
例2:
if $fromhost-ip startswith '10.1.2.45' and $syslogfacility-text == 'authpriv.*' then /var/log/test_secure.log
& stop
if $fromhost-ip startswith '10.1.2.45' then /var/log/test_all.log
& stop
答え1
解決策はここにあります: rsyslog 設定構文
if $fromhost-ip startswith '10.1.2.45' then {
authpriv.* -/var/log/test_secure.log
-/var/log/test_all.log
& stop
}