Rsyslog

rsyslog && 發送數據到其他主機

  • February 19, 2015

使用CentOS 6.4。

問題是 - 來自kern.*設施的消息不會出現在其他伺服器上。

發送數據:

# logger -p kern.warning -t TEST "Test warning for remote host KERNEL"
# logger -p cron.warning -t TEST "Test warning for remote host CRON"
# logger -p mail.warning -t TEST "Test warning for remote host MAIL"

檢查MySQL數據:

mysql> select ID,Message from SystemEvents order by ID desc limit 3;
+--------+------------------------------------+
| ID     | Message                            |
+--------+------------------------------------+
| 524007 |  Test warning for remote host MAIL |
| 524006 |  Test warning for remote host CRON |
| 524005 |  Test warning for remote host MAIL |
+--------+------------------------------------+
3 rows in set (0.00 sec)

沒有來自kern設施的數據。為什麼?

在主機接收方上配置:

# cat /etc/rsyslog.conf | egrep -v '^[[:space:]]*$|#'
$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
kern.*                                                 /var/log/kern.log
syslog.*                                                /var/log/syslog.log
*.info;mail.none;authpriv.none;cron.none;local0.none                /var/log/messages
authpriv.*                                              /var/log/secure
mail.*                                                  -/var/log/maillog
cron.*                                                  /var/log/cron
*.emerg                                                 *
uucp,news.crit                                          /var/log/spooler
local7.*                                                /var/log/boot.log

收件人的MySQL配置:

# cat /etc/rsyslog.d/hostname.conf
$ModLoad ommysql
:fromhost, isequal, "hostname" :ommysql:localhost,Syslog,rsyslog,megapass

和主機發件人:

# cat /etc/rsyslog.conf | egrep -v '^[[:space:]]*$|#'
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
kern.*                                                  @hostname
syslog.*                                                /var/log/syslog.log
*.info;mail.none;authpriv.none;cron.none                /var/log/messages
authpriv.*                                              /var/log/secure
mail.*                                                  -/var/log/maillog
mail.*                                                  @hostname
cron.*                                                  /var/log/cron
cron.*                                                  @hostname
*.emerg                                                 *
uucp,news.crit                                          /var/log/spooler
local7.*                                                /var/log/boot.log
local4.*                                                /var/log/ldap.log

UPD

另外,我注意到數據甚至沒有發送到本地文件:

kern.*                                                  /var/log/kern.log

和:

# logger -p kern.warning -t TEST "Test warning for local host KERNEL"

和:

# tail /var/log/kern.log | grep "TEST"

什麼都不退。

那麼 - 如果我猜這logger不能“從核心”發送數據,我是否正確?聽起來很合乎邏輯…

從設施名稱的記錄器手冊頁:

kern       cannot be generated from user process

來源:http: //man7.org/linux/man-pages/man1/logger.1.html

引用自:https://unix.stackexchange.com/questions/123569