解決rsyslog+loganalyzer不能同時顯示IP和主機名稱(原創)

來源:互聯網
上載者:User

 環境:

*********************

 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的時候,發現不能搞多個欄位。於是乎想到了修改資料庫,修改完資料庫發現還是不對。

添加第一個欄位還算正常

650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1TZ12451-0.jpg" />

添加第二個欄位的時候,我驚訝的發現,FUCK,這泥瑪什麼情況

650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1TZ11245-1.jpg" />

第一個欄位為啥變成Array了呢?泥瑪,叫雅咩碟也不管用啊。再繼續添加,就一個一個的覆蓋,我了個去。搞毛線?

本來是想修正這個BUG的,再怎麼說咱也看了幾天的PHP,以為以老夫的本事,能搞定。結果發現,實在是頭大,學習的時候MVC沒學好,直接修改view.php看來要流產。但也不能這麼就放棄。結果就想修改它本身內建的view,發現以下

650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1TZ15G5-2.jpg" />

 

黑呀,真黑呀。黑的就代表不讓改。妹的,view.php的源碼我看不懂也就不必了,難度這個也會一樣的悲劇嗎?於是就找這個在哪裡改,發現頁面還是view.php,發現裡面沒有這些view,它本身又include了一堆的php,泥瑪,看的蛋疼,越是蛋疼的時候越要蛋定。直接在linux下面使用grep找

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

找到後編譯它

650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1TZ135T-3.jpg" />

添加紅色框裡的內容。

完了之後,發現還是不行,因為點到DBMappings裡面的時候,發現根本就沒這個欄位,要以還要改一個檔案來實現關連。

 
  1. [root@centos100 log]# grep 'MonitorWare' ./ -r 
  2. ./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.'; 
  3. ./include/constants_logstream.php:$dbmapping['monitorware']['DisplayName'] = "MonitorWare"; 
  4. ./include/functions_config.php:                         $mysource['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare! 
  5. ./include/constants_general.php:// --- MonitorWare InfoUnit Defines | Messagetypes 
  6. ./doc/install.html:     MonitorWare Line of products.</P> 
  7. ./doc/install.html:     MonitorWare Line of products.</P> 
  8. ./doc/install.html:LogAnalyzer supports Adiscon's MonitorWare database schema. The schema 
  9. ./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, tabels in either MonitorWare format or the format used by 
  12. ./doc/basics.html:you set 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

進去就發現,又是一個數組,結果新增一個即可

650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1TZ14017-4.jpg" />

 

添加352行的內容。

650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1TZ139D-5.jpg" />

 發現IP和主機名稱都有顯示了。

當然了,做以上操作之前,肯定在要資料庫裡插入這個欄位,這樣才能顯示得出來。

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

 修改日誌的設定檔

 
  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 

改完以上之後,還要添加FromIP到現有的欄位裡面

650) this.width=650;" src="http://www.bkjia.com/uploads/allimg/131227/1TZ11505-6.png" border="0" alt="" />

 

完成後不要忘記重啟rsyslog的服務

 

 說明:

Adiscon LogAnalyzer Version 3.6.3已經修複添加view的時候,不能添加多個欄位的BUG,本人新測可用。

3.6.3如果想同時顯示IP和主機名稱,要把修改的不太一樣。 

 

 

本文出自 “吖吖個呸” 部落格,請務必保留此出處http://gm100861.blog.51cto.com/1930562/1187180

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.