差異處
這裏顯示兩個版本的差異處。
兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
tech:logsrv [2013/05/21 16:01] – [CentOS 啟動 Log Server 功能] jonathan | tech:logsrv [2016/05/29 23:27] (目前版本) – jonathan | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== CentOS 啟動 Log Server 功能 ====== | ||
+ | 因為一些 Embeded System 提供送出 log 到 Log Server 的功能, 所以就上網找了一下.. | ||
+ | |||
+ | * Log Server : 192.168.11.252 | ||
+ | * / | ||
+ | # Options for rsyslogd | ||
+ | # Syslogd options are deprecated since rsyslog v3. | ||
+ | # If you want to use them, switch to compatibility mode 2 by "-c 2" | ||
+ | # See rsyslogd(8) for more details | ||
+ | SYSLOGD_OPTIONS=" | ||
+ | </ | ||
+ | * / | ||
+ | : | ||
+ | : | ||
+ | #### RULES #### | ||
+ | $template DYNmessages,"/ | ||
+ | $template DYNsecure,"/ | ||
+ | $template DYNmaillog,"/ | ||
+ | $template DYNcron,"/ | ||
+ | $template DYNspooler,"/ | ||
+ | $template DYNboot,"/ | ||
+ | $template DYNdaemon,"/ | ||
+ | $template DYNother,"/ | ||
+ | |||
+ | |||
+ | # Log all kernel messages to the console. | ||
+ | # Logging much else clutters up the screen. | ||
+ | # | ||
+ | |||
+ | # Log anything (except mail) of level info or higher. | ||
+ | # Don't log private authentication messages! | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | | ||
+ | and ( \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | ) \ | ||
+ | then / | ||
+ | |||
+ | # The authpriv file has restricted access. | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then / | ||
+ | |||
+ | # Log all the mail messages in one place. | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then -/ | ||
+ | |||
+ | |||
+ | # Log cron stuff | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then / | ||
+ | |||
+ | # Everybody gets emergency messages | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | $syslogseverity-text == ' | ||
+ | then * | ||
+ | |||
+ | # Save news errors of level crit and higher in a special file. | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | (\ | ||
+ | $syslogfacility-text == ' | ||
+ | or \ | ||
+ | $syslogfacility-text == ' | ||
+ | )\ | ||
+ | and \ | ||
+ | $syslogseverity-text == ' | ||
+ | then / | ||
+ | |||
+ | # Save boot messages also to boot.log | ||
+ | # | ||
+ | if \ | ||
+ | $source == ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then / | ||
+ | |||
+ | |||
+ | # not log server 's log | ||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | | ||
+ | and ( \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | ) \ | ||
+ | then ? | ||
+ | |||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then ?DYNsecure | ||
+ | |||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then -? | ||
+ | |||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then ?DYNcron | ||
+ | |||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | (\ | ||
+ | $syslogfacility-text == ' | ||
+ | or \ | ||
+ | $syslogfacility-text == ' | ||
+ | )\ | ||
+ | and \ | ||
+ | $syslogseverity-text == ' | ||
+ | then ?DYNspooler | ||
+ | |||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then ?DYNboot | ||
+ | |||
+ | if \ | ||
+ | $source != ' | ||
+ | and \ | ||
+ | $syslogfacility-text == ' | ||
+ | then ?DYNdaemon | ||
+ | if \ | ||
+ | $source != ' | ||
+ | and ( \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | and \ | ||
+ | $syslogfacility-text != ' | ||
+ | ) \ | ||
+ | then ?DYNother | ||
+ | |||
+ | |||
+ | # ### begin forwarding rule ### | ||
+ | # The statement between the begin ... end define a SINGLE forwarding | ||
+ | : | ||
+ | : | ||
+ | </ | ||
+ | * / | ||
+ | $ModLoad imudp.so | ||
+ | # load the network stuff | ||
+ | $UDPServerAddress 0.0.0.0 | ||
+ | $UDPServerRun 514 | ||
+ | # reduce any duplicates | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | * CentOS 6.x <code sh> | ||
+ | service rsyslog restart | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | * 如果有 firewall 要開啟 udp port 514 | ||
+ | </ | ||
+ | |||
+ | 然後就可以看到外部主機紀錄出現在 / | ||
+ | < | ||
+ | : | ||
+ | May 29 23:25:26 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:26 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:26 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:28 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:28 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:29 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:29 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:30 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:32 rt-n56u kernel: DROP < | ||
+ | May 29 23:25:32 rt-n56u kernel: DROP < | ||
+ | : | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | 其他 Linux 主機的 Log 也可以透過設定 / | ||
+ | < | ||
+ | *.* @192.168.11.252 | ||
+ | </ | ||
+ | 這樣就會將 log 送到 192.168.11.252 Log Server 內了.. | ||
+ | </ | ||
+ | |||
+ | ===== 參考網址 ===== | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | |||
+ | {{tag> |