如何在 Rsyslogd 中为 IP 地址设置特定规则并发送到 mysql 服务器
How to set a specific rule in Rsyslogd for an IP address and send to a mysql server
我目前正在使用 rsyslog 将我所有的系统日志发送到 SQL 服务器并且它工作正常。
但是我的一台计算机将它发送为不同的格式。
如何为给定的 IP 地址设置例外?
这是我现在得到的:
$template sysMysql,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg) VALUES('%HOSTNAME%','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg%')", SQL
*.*;authpriv.none;mail.none;cron.none >127.0.0.1,centreon_syslog,centreon_syslog,*****;sysMysql
我想只为一个 IP 地址更改该模板。
好吧,不好意思,我在这里找到了一些东西:answer
但为了完整起见,这里是我必须做的:
$template sysMysqlUcopia,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg) VALUES('portailcaptif','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg%')", SQL
$template sysMysql,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg) VALUES('%HOSTNAME%','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg%')", SQL
:fromhost-ip, isequal, "172.17.97.60" >127.0.0.1,centreon_syslog,centreon_syslog,*****;sysMysqlUcopia
& ~
*.*;authpriv.none;mail.none;cron.none >127.0.0.1,centreon_syslog,centreon_syslog,*****;sysMysql
我目前正在使用 rsyslog 将我所有的系统日志发送到 SQL 服务器并且它工作正常。 但是我的一台计算机将它发送为不同的格式。 如何为给定的 IP 地址设置例外?
这是我现在得到的:
$template sysMysql,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg) VALUES('%HOSTNAME%','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg%')", SQL
*.*;authpriv.none;mail.none;cron.none >127.0.0.1,centreon_syslog,centreon_syslog,*****;sysMysql
我想只为一个 IP 地址更改该模板。
好吧,不好意思,我在这里找到了一些东西:answer 但为了完整起见,这里是我必须做的:
$template sysMysqlUcopia,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg) VALUES('portailcaptif','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg%')", SQL
$template sysMysql,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg) VALUES('%HOSTNAME%','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg%')", SQL
:fromhost-ip, isequal, "172.17.97.60" >127.0.0.1,centreon_syslog,centreon_syslog,*****;sysMysqlUcopia
& ~
*.*;authpriv.none;mail.none;cron.none >127.0.0.1,centreon_syslog,centreon_syslog,*****;sysMysql