Sei sulla pagina 1di 5

LogMonitor generic utility for monitoring log files

Introduction
I have started writing applications for MySQL quite recently. I then started to miss the richness of the Microsoft SQL Server client tools like Enterprise Manager, Query naly!er and, the most important, the "rofiler. #owever, MySQL $ provides two wonderful graphical interface tools, MySQL dministrator and MySQL Query $rowser. ll is well e%cept that it&s not possi'le to trace the queries in a dynamic manner like the one provided 'y Microsoft&s SQL "rofiler. fter unsuccessful attempts to find a free MySQL profiler(tracer tool on )e', I decided to write a simple one.

How it works
*he LogMonitor application leverages the MySQL logging mechanism. It monitors the general query log file produced 'y the MySQL server on a schedule and displays the latest activity on the screen. Important Note *he application can very easily 'e used to monitor any kind of log file. In other words, you can tell the application to monitor a te%t file whose content changes in time. )hen the content changes, the new lines are displayed on the screen.

MySQL server preparation


s stated a'ove, the LogMonitor application simply leverages the general query log file produced 'y the MySQL server. $y default, this option is off and you have to turn it on. +n a ,ni% server, locate the MySQL daemon startup script and add the --log option to the command line parameters of mysqld.safe. /or more information on how to turn on the MySQL general logging, check this link0 http0((dev.mysql.com(doc(refman(1.2(en(query-log.html

3redits0 silviulita4'luewin.ch

LogMonitor generic utility for monitoring log files

LogMonitor guide
Start the application

,se +ptions6Log file path to enter the path to the log file you want to monitor0

*he file path will 'e retained ne%t time you start the application.

3redits0 silviulita4'luewin.ch

LogMonitor generic utility for monitoring log files *he new MySQL activity will 'e displayed on the screen

,se 8eset 9'utton or menu item- to reset the screen. *his command does not alter the log file: ,se Stop 9'utton or menu item- to stop monitoring the log. ,se +ptions6*imer schedule to change the monitor frequency. $y default the log file is checked every 5 second.

$y default, the LogMonitor application reads the log file in the MySQL 1.2 format. If you want to monitor log files that are not compati'le with this format, uncheck the MySQL structured file option ;the setting will 'e retained ne%t time you start the application<.

3redits0 silviulita4'luewin.ch

LogMonitor generic utility for monitoring log files

3onsequently, the display will 'e unstructured0

,se +ptions6/ilter to define a connection filter string. *his option is only availa'le in MySQL mode. +nce you defined a connection filter, the application will only display the lines whose connection field contains the te%t defined in the filter0

Similarly, ,se +ptions68eset filter to clear previously defined connection filter.

3redits0 silviulita4'luewin.ch

>

LogMonitor generic utility for monitoring log files

Package contents
*he LogMonitor application version 2.7, ?ar file. *he complete @ava source code of the application for those of you who may want to improve the code.

*he code has 'een tested on the following platforms0 Server0 MySQL 1.2 for Linu% 3lient0 Suse Linu%()indows A", @8E 5.1.21

Credits
/or any comment or suggestion please email me at0 Silviulita4'luewin.ch B Silviu Lita, March 722C

3redits0 silviulita4'luewin.ch

Potrebbero piacerti anche