|
||
|
rsyslogを別のサーバへ再転送するここではrsyslogの実践的なconf記述を記します。インストールについては別項「rsyslogをインストールする」を参照してください。 rsyslog.confの例 集約したsyslogを再転送する rsyslog.confの例(デフォルトのコメントアウト部は省いてあります)#$ModLoad immark # provides --MARK-- message capability$ModLoad imuxsock # provides support for local system logging (e.g. via logger command) $ModLoad imklog # kernel logging (formerly provided by rklogd) $template customformat,"%timegenerated% %HOSTNAME% %syslogtag%%msg%\n" $template logFileName,"/var/log/syslog/%fromhost%/messages_%fromhost%_%$year%%$month%%$day%.log" $template mailFileName,"/var/log/syslog/%fromhost%/mail_%fromhost%_%$year%%$month%%$day%.log" # Log anything (except mail) of level info or higher. # Don't log private authentication messages! #*.info;mail.none;authpriv.none;cron.none -/var/log/messages *.info;mail.none;authpriv.none;cron.none -?logFileName;customformat *.info;mail.none;authpriv.none;cron.none @remoteserver # The authpriv file has restricted access. authpriv.* /var/log/secure # Log all the mail messages in one place. #mail.* -/var/log/maillog mail.* -?mailFileName;customformat $ModLoad ommail $ActionMailSMTPServer mailserver.address $ActionMailFrom admin@example.local $template mailsubject,"Syslog Warning" $template mailbody,"%fromhost%\r\n%msg%" $ActionMailSubject mailsubject $ActionExecOnlyOnceEveryInterval -1 $ActionMailTo admin-ml@example.local if $fromhost-ip == '192.168.1.100' and $msg contains 'System Warning' then :ommail:;mailbody $ActionMailTo admin-ml@example.local if $fromhost-ip != '127.0.0.1' and $msg contains 'authenticated failure' and $syslogfacility-text == 'daemon' then :ommail:;mailbody $ActionMailTo administrator@example.local if $fromhost-ip =='192.168.1.254' and $syslogfacility-text == 'syslog' and $syslogseverity-text == 'crit' then :ommail:;mailbody # Log cron stuff cron.* -/var/log/cron # Everybody gets emergency messages *.emerg * # Save news errors of level crit and higher in a special file. uucp,news.crit -/var/log/spooler # Save boot messages also to boot.log local7.* /var/log/boot.log # UDP Syslog Server: $ModLoad imudp.so # provides UDP syslog reception $UDPServerRun 514 # start a UDP syslog server at standard port 514 集約したsyslogを再転送するリモートから集約したログをさらに別のsyslogサーバへ転送できます。集約と保存、集約と解析を別々のサーバで実施する場合はこの機能は必須です。 syslogではログの再転送はできません。 rsyslog.conf *.info;mail.none;authpriv.none;cron.none -/var/log/messages *.info;mail.none;authpriv.none;cron.none @192.168.1.200 この記述では 全ての受信したログデータを、messagesへ出力します。 全ての受信したログデータを、リモートサーバ192.168.1.200へUDPで送信します。 この設定では受け取ったUDPのシスログを全て一つのmessagesへ出力します。 一つのファイルへログを出力し続けると、ログも肥大化するし閲覧するのは困難になってくるでしょう。 ログはホスト名別か、ファシリティ別に分けるほうが理に適っています。 ログが正しくリモートログサーバへ再転送されているかをコマンドで確認します。 #logger -p daemon.crit "System Warning" |
|