Rsyslog+loganalyzer+mysql IP Add and Chinese garbled solution

Source: Internet
Author: User
Tags syslog rsyslog

Because see many friends also met me this situation, so take out for everyone to refer to, I use the Loganalyzer version is installed version:3.6.5


Here first put: 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6C/0F/wKioL1U_Hp_SHww0AAcCKK_kkXc867.jpg "title=" QQ picture 20150428133945.png "style=" Float:none; "alt=" wkiol1u_hp_shww0aacckk_kkxc867.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/13/wKiom1U_HTDQ7cq5AAGqhcDf6Rc334.jpg "style=" float: none; "title=" QQ picture 20150428133755.png "alt=" Wkiom1u_htdq7cq5aagqhcdf6rc334.jpg "/>

Add an IP field

1.php File Add Field

Vim./include/constants_logstream.php +354 Modify this php file

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/15/wKiom1U_LuCBQtauAAQiya5-_ps033.jpg "title=" QQ picture 20150428135952.png "style=" Float:none; "alt=" wkiom1u_lucbqtauaaqiya5-_ps033.jpg "/>

2. View Add Field

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6C/10/wKioL1U_MEuBlr3VAATEgLuhTig369.jpg "title=" QQ picture 20150428141546.png "style=" Float:none; "alt=" wkiol1u_meublr3vaategluhtig369.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/11/wKioL1U_MM3CofwAAAE7UAH1FgE872.jpg "title=" QQ picture 20150428134647.png "alt=" wkiol1u_mm3cofwaaae7uah1fge872.jpg "/>650) this.width=650;" src= "/HTTP/ S3.51cto.com/wyfs02/m00/6c/10/wkiol1u_meetuv4xaafqvnevsis527.jpg "title=" qq picture 20150428134716.png "style=" float: none; "alt=" wkiol1u_meetuv4xaafqvnevsis527.jpg "/>650) this.width=650; src=" http://s3.51cto.com/wyfs02/M02/6C/ 10/wkiol1u_mexy5_syaaj_tkyfc9e304.jpg "style=" Float:none; "title=" QQ picture 20150428134744.png "alt=" wkiol1u_mexy5_ Syaaj_tkyfc9e304.jpg "/>

3. Adding a field to a database

Modify the/etc/rsyslog.conf file to add 2 lines.

$template Insertpl, "insert into SystemEvents (Message, Facility, Fromhost, fromip,priority, Devicereportedtime, Receivedat, Infounitid, Syslogtag) VALUES ('%msg% ',%syslogfacility%, '%hostname% ', '%fromhost-ip% ',%syslogpriority%, '%timereported:::d ate-mysql% ', '%timegenerated:::d ate-mysql% ',%iut%, '%syslogtag% ') ', SQL *. *: Ommysql:localhost, syslog,logger,123456;insertplmysql> use Syslog; mysql> ALTER TABLE SystemEvents ADD fromip VARCHAR () DEFAULT NULL after Fromhost;
It is important to look at the mapping relationship of database mapping databases. If the mapping is not correct, the IP column will not appear. Rsyslog configuration has been modified, so do remember to restart the Rsyslog service. In this case, the IP problem can be solved basically. Rsyslog Record templated IP field--mysql Write field--loganalyzer front-end display.

Solve the problem of garbled Chinese display:


1. source file encoding changed to UTF8

Edit the include/functions_common.php file in the Web site to find the line containing the return htmlentities field; return Htmlentities ($myStr, Ent_noquotes, $ content[' headerdefaultencoding ');//"UTF-8"), modified to: Return Htmlentities ($myStr, Ent_noquotes, $content [' Headerdefaultencoding '], "UTF-8"); Notice that the small registration has been removed, the semicolon is changed to a comma.

2. Change the view preference to UTF8

Admin Center-->preference-->global Options only sets the default character to Utf-8

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/10/wKioL1U_LP7yUp2mAAIQECySOKQ095.jpg "title=" QQ picture 20150428144041.png "alt=" Wkiol1u_lp7yup2maaiqecysokq095.jpg "/>

3. Check if MySQL is encoded as UTF8

mysql> statuserror 2006  (HY000): mysql server has gone awayno  Connection. trying to reconnect ... Connection id:    3771current database: syslog--------------mysql   Ver 14.14 Distrib 5.5.21, for Linux  (x86_64)  using   editline wrapperconnection id:           3771current database:       syslogcurrent user:            [email protected]SSL:                     Not in  Usecurrent pager:          stdoutusing outfile:            ' USING DELIMITER:   &NBsp;    ; server version:         5.5.21-log source  distributionprotocol version:       10connection:              localhost via unix socketserver  characterset:    utf8Db     characterset:     utf8Client characterset:    latin1Conn.  characterset:     latin1unix socket:            / tmp/mysql.sockuptime:                  1 hour 38 min 30 secThreads: 29  Questions:  257366  slow queries: 3726  opens: 669  flush tables: 1   open tables: 179  queries per second avg: 43.547 

But here the client character is latin1, changed to UTF8, see systemevents found the inserted data is all garbled.

Server Version:5.5.21-log Source distributionprotocol version:10connection:localhost via UNIX  Socketserver characterset:utf8db characterset:utf8client Characterset:utf8conn. Characterset:utf8

It is found that the encoding used for rsyslog insertion into MySQL is latin1.

5. Client insert and data initialized to UTF8 encoding

So in the MY.CNF set to

init_connect= ' SET NAMES UTF8 '

Forced connection used to encode the UTF8 after restarting MySQL solved the problem of garbled

This article is from the "tireless learning ..." Blog, be sure to keep this source http://jonyisme.blog.51cto.com/3690784/1639746

Rsyslog+loganalyzer+mysql IP Add and Chinese garbled solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.