簡介
本文檔介紹如何配置CSPC以將系統日誌轉發到系統日誌伺服器。
問題
雖然BCS和NP支援系統日誌分析,但有些人已經有了另一個解決方案,並且喜歡使用Splunk等系統日誌伺服器。但是在這種情況下,您要求CSPC將系統日誌從CSPC轉發到系統日誌伺服器。
解決方案
確定需要使用的協定(TCP/UDP)和IP/埠。預設埠為514。
使用rsyslog
1.備份/etc/rsyslog.conf。
cp /etc/rsyslog.conf /etc/rsyslog.confbkup<date>
2.新增轉發規則。
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$WorkDirectory /var/lib/rsyslog # where to place spool files
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
Add here
# ### end of the forwarding rule ###
2.1.TCP範例:
*.* @@138.25.253.132:514
2.2. UDP示例:
*.* @138.25.253.132:514
3.重新啟動rsyslog。
service rsyslog restart
附註:如果配置了錯誤的協定,則會顯示一條錯誤消息rsyslogd:無法連線到::連線被拒絕…….如果發生此錯誤,請修改(轉到步驟2.1和2.2)。
我們可以生成用於測試目的的系統日誌:
logger "Your message for testing here"
4.確認是否收到系統日誌。