4 月 302014
 

架构

logger  + rsyslog +  loganalyzer

其中最主要的是rsyslog 服务器

tail -n 1000 $rizhi2 |  grep “$date_3\|$date_1” | grep “$date_2\|$date_4″ | logger -t $jklog -p local6.err

通过 logger  定向报告给rsyslog  的 local6.err  (指定类型 local6 的err 其他类型可以自己定义)

其中要使rsyslog记录到数据库,要安装

rsyslog-mysql

然后修改 /etc/rsyslog.conf

添加

$ModLoad ommysql.so
$template insertpl,”insert into SystemEvents (Message, Facility, FromHost, FromIP, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (‘%msg%’, %syslogfacility%, ‘%HOSTNAME%’, ‘%fromhost-ip%’, %syslogpriority%, ‘%timereported:::date-mysql%’, ‘%timegenerated:::date-mysql%’, %iut%, ‘%syslogtag%’)”,SQL

因为我这里添加了 hostname 可能跟网上写的不是一样

具体loganalyzer  添加hostname的方法,大家可以网上查下。

参考:http://gm100861.blog.51cto.com/1930562/1187180

我当时操作时好像没那么麻烦,好像在view下添加个host就可以了,新建了Database Field Mappings 类型

image

image

image

image

然后就是安装loganalyzer,这方面网上文档很多,大家可以自行查找。

其实我这只是定向通过logger写入,也可以通过log4j 和 syslog 自动写入。

配置添加rsyslog.conf

*.* @172.21.27.1  (172.21.27.1日志服务器的ip)

重启即可。

PS 再导入数据库的时候中文可能乱码

[client]
default-character-set=utf8

请将client制定字符编码

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny