解决rsyslog+loganalyzer不能同时显示IP和主机名

来源:互联网 发布:幼儿园大班手指算法 编辑:程序博客网 时间:2024/06/11 08:40
看到标题,可能有些人会不屑,答案无非是新建view,建立DBMappings。我很负责任的告诉你,不是。我这里是修改PHP源码的方法,来实现的。费话不多说,直接开搞

最近在搞rsyslog+loganalyzer来实现集中型日志管理,但是在安装完之后,发现只显示了主机名,没有IP,网上找了一些文章参考,要么可以只显示IP,要么只显示主机名,还有就是两者同时显示需要添加view,我在添加view的时候,发现不能搞多个字段。于是乎想到了修改数据库,修改完数据库发现还是不对。

添加第一个字段还算正常

\

添加第二个字段的时候,我惊讶的发现,FUCK,这泥玛什么情况

\

第一个字段为啥变成Array了呢?泥玛,叫雅咩碟也不管用啊。再继续添加,就一个一个的覆盖,我了个去。搞毛线?

本来是想修正这个BUG的,再怎么说咱也看了几天的PHP,以为以老夫的本事,能搞定。结果发现,实在是头大,学习的时候MVC没学好,直接修改view.php看来要流产。但也不能这么就放弃。结果就想修改它本身自带的view,发现以下

\

 

黑呀,真黑呀。黑的就代表不让改。妹的,view.php的源码我看不懂也就不必了,难度这个也会一样的悲剧么?于是就找这个在哪里改,发现页面还是view.php,发现里面没有这些view,它本身又include了一堆的php,泥玛,看的蛋疼,越是蛋疼的时候越要蛋定。直接在linux下面使用grep找 www.it165.net


view sourceprint?
1.[root@centos100 log]# grep 'Syslog Fields' ./ -r
2../include/functions_config.php:                                                                 'DisplayName' =>"Syslog Fields",

找到后编译它

\

添加红色框里的内容。

完了之后,发现还是不行,因为点到DBMappings里面的时候,发现根本就没这个字段,要以还要改一个文件来实现关连。


view sourceprint?
01.[root@centos100 log]# grep 'MonitorWare' ./ -r
02../classes/msgparsers/msgparser.eventlog.class.php:      public $_ClassDescription = 'This is a parserfor a special formatwhich can be created with Adiscon Eventreporter or MonitorWare Agent.';
03../include/constants_logstream.php:$dbmapping['monitorware']['DisplayName'] ="MonitorWare";
04../include/functions_config.php:                         $mysource['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare!
05../include/constants_general.php:// --- MonitorWare InfoUnit Defines | Messagetypes
06../doc/install.html:     MonitorWare Line of products.</P>
07../doc/install.html:     MonitorWare Line of products.</P>
08../doc/install.html:LogAnalyzer supports Adiscon's MonitorWare database schema. The schema
09../doc/manual.html:<a href="http://www.mwagent.com">MonitorWare Agent</a>.
10../doc/windowsevent.html:<a href="http://www.mwagent.com">MonitorWare Agent</a> software. These Agents are
11../doc/basics.html:For the database, tabelsin either MonitorWare format or the formatused by
12../doc/basics.html:youset up something new, be sure the use MonitorWare schema. If you use
13../doc/basics.html:that rsyslog uses MonitorWare schema by default, too. So you probably need not to
14../doc/basics.html:<a href="http://www.msagent.com/">MonitorWare Agent</a>
15../doc/basics.html:<a href="http://kb.monitorware.com">MonitorWare Knowledge Base</a> to aid you

结果就一个一个的看,一个一个的找,html的肯定不是,结果就被我找到了./include/constants_logstream.php

进去就发现,又是一个数组,结果新增一个即可

\

 

添加352行的内容。

\

 发现IP和主机名都有显示了。

当然了,做以上操作之前,肯定在要数据库里插入这个字段,这样才能显示得出来。www.it165.net


view sourceprint?
1.mysql> USE Syslog;
2.mysql> ALTER TABLE SystemEvents ADD FromIP VARCHAR(60) DEFAULT NULL AFTER FromHost;

修改日志的配置文件

 

view sourceprint?
1.# vi /etc/rsyslog.conf
2.$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
完成后不要忘记重启rsyslog的服务
0 0
原创粉丝点击