環境:
*********************
Adiscon LogAnalyzer Version 3.4.3
[root@centos100 ~]# cat /etc/issue
CentOS release 5.6 (Final)
*********************
看到標題,可能有些人會不屑,答案無非是新建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找
- [root@centos100 log]# grep 'Syslog Fields' ./ -r
- ./include/functions_config.php: 'DisplayName' =>"Syslog Fields",
找到後編譯它
添加紅色框裏的內容。
完了之後,發現還是不行,因爲點到DBMappings裏面的時候,發現根本就沒這個字段,要以還要改一個文件來實現關連。
- [root@centos100 log]# grep 'MonitorWare' ./ -r
- ./classes/msgparsers/msgparser.eventlog.class.php: public $_ClassDescription = 'This is a parser for a special format which can be created with Adiscon Eventreporter or MonitorWare Agent.';
- ./include/constants_logstream.php:$dbmapping['monitorware']['DisplayName'] = "MonitorWare";
- ./include/functions_config.php: $mysource['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare!
- ./include/constants_general.php:// --- MonitorWare InfoUnit Defines | Messagetypes
- ./doc/install.html: MonitorWare Line of products.</P>
- ./doc/install.html: MonitorWare Line of products.</P>
- ./doc/install.html:LogAnalyzer supports Adiscon's MonitorWare database schema. The schema
- ./doc/manual.html:<a href="http://www.mwagent.com">MonitorWare Agent</a>.
- ./doc/windowsevent.html:<a href="http://www.mwagent.com">MonitorWare Agent</a> software. These Agents are
- ./doc/basics.html:For the database, tabels in either MonitorWare format or the format used by
- ./doc/basics.html:you set up something new, be sure the use MonitorWare schema. If you use
- ./doc/basics.html:that rsyslog uses MonitorWare schema by default, too. So you probably need not to
- ./doc/basics.html:<a href="http://www.msagent.com/">MonitorWare Agent</a>
- ./doc/basics.html:<a href="http://kb.monitorware.com">MonitorWare Knowledge Base</a> to aid you
結果就一個一個的看,一個一個的找,html的肯定不是,結果就被我找到了./include/constants_logstream.php
進去就發現,又是一個數組,結果新增一個即可
添加352行的內容。
發現IP和主機名都有顯示了。
當然了,做以上操作之前,肯定在要數據庫裏插入這個字段,這樣才能顯示得出來。
- mysql> USE Syslog;
- mysql> ALTER TABLE SystemEvents ADD FromIP VARCHAR(60) DEFAULT NULL AFTER FromHost;
修改日誌的配置文件
- # vi /etc/rsyslog.conf
- $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
改完以上之後,還要添加FromIP到現有的字段裏面
完成後不要忘記重啓rsyslog的服務
說明:
Adiscon LogAnalyzer Version 3.6.3已經修復添加view的時候,不能添加多個字段的BUG,本人新測可用。
3.6.3如果想同時顯示IP和主機名,要把修改的不太一樣。