T R A C K 2 S Q L ----------------------------- a server log analysis tool TRACK2SQL IS PROVIDED "AS IS", WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Description Track2sql takes a VTRACK log file (server version 2005.2 or greater) as input, and produces an SQL file as output. It requires a PHP command-line interpreter and an SQL database. It has been tested with PHP version 5, but might be compatible with earlier versions. It has been tested with MySQL version 5 but should be compatible with other SQL databases. Usage php track2sql.php [ logFile | - [ sqlFile | - ] ] [ -d dbName ] Options: logFile name of input file or '-' for stdin sqlFile name of output file or '-' for stdout -d name of database to create Examples: $ track2sql.php log track.sql -d track $ cat log | track2sql.php | mysql $ tail -F log | track2sql.php | mysql Application The power of SQL allows us to analyze the server log data in many different ways. In particular, track2sql is an effective tool for identifying performance problems. If you are experiencing poor performance, try the following steps to illuminate the culprits. 1. Convert your log file to sql. track2sql.php logFile -d dbName | mysql 2. Launch your SQL client mysql dbName 3. Identify commands with long compute-phases. mysql> SELECT process.processKey,user,cmd, MAX(readHeld+writeHeld)-MAX(readWait+writeWait) AS compute FROM tableUse JOIN process USING (processKey) GROUP BY tableUse.processKey ORDER BY compute DESC LIMIT 25; This will produce a list of 25 processes that held locks on one or more database tables for an extended period of time. During these periods of time, it is possible that the offending processes blocked other processes, thereby degrading performance. +------------+------+-----------+---------+ | processKey | user | cmd | compute | +------------+------+-----------+---------+ | 12345 | jdoe | user-sync | 98765 | | ... | ... | ... | ... | +------------+------+-----------+---------+ FOR EACH OFFENSIVE PROCESS: a. Get process information. mysql> SELECT * FROM process WHERE processKey=12345; b. Get table usage information. mysql> SELECT * FROM tableUse WHERE processKey=12345; c. Identify bottlenecks and take action. This last step can be difficult. Keep in mind that in general, performance can be improved three ways: -> By improving hardware (memory, disks, cpu) -> By upgrading software (perforce server/clients, OS) -> By adjusting usage (reducing scope of commands) Schema +------------+------------------------+------+-----+ | P R O C E S S | +------------+------------------------+------+-----+ | Field | Type | Null | Key | +------------+------------------------+------+-----+ | processKey | int(10) unsigned | NO | PRI | | time | int(10) unsigned | NO | | | pid | int(10) unsigned | NO | | | user | varchar(255) | NO | | | client | varchar(255) | NO | | | ip | varchar(255) | NO | | | app | varchar(255) | NO | | | cmd | varchar(255) | NO | | | args | text | YES | | | lapse | decimal(10,3) unsigned | YES | | | uCpu | int(10) unsigned | YES | | | sCpu | int(10) unsigned | YES | | | diskIn | int(10) unsigned | YES | | | diskOut | int(10) unsigned | YES | | | ipcIn | int(10) unsigned | YES | | | ipcOut | int(10) unsigned | YES | | | maxRss | int(10) unsigned | YES | | | pageFaults | int(10) unsigned | YES | | | rpcMsgsIn | int(10) unsigned | YES | | | rpcMsgsOut | int(10) unsigned | YES | | | rpcSizeIn | int(10) unsigned | YES | | | rpcSizeOut | int(10) unsigned | YES | | +------------+------------------------+------+-----+ +-------------+------------------+------+-----+ | T A B L E U S E | +-------------+------------------+------+-----+ | Field | Type | Null | Key | +-------------+------------------+------+-----+ | processKey | int(10) unsigned | NO | PRI | | tableName | varchar(255) | NO | PRI | | pagesIn | int(10) unsigned | YES | | | pagesOut | int(10) unsigned | YES | | | pagesCached | int(10) unsigned | YES | | | readLocks | int(10) unsigned | YES | | | writeLocks | int(10) unsigned | YES | | | getRows | int(10) unsigned | YES | | | posRows | int(10) unsigned | YES | | | scanRows | int(10) unsigned | YES | | | putRows | int(10) unsigned | YES | | | delRows | int(10) unsigned | YES | | | readWait | int(10) unsigned | YES | | | readHeld | int(10) unsigned | YES | | | writeWait | int(10) unsigned | YES | | | writeHeld | int(10) unsigned | YES | | +-------------+------------------+------+-----+