🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

mysql-slowquery-parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-slowquery-parser

0.0.1
Rubygems
Version published
Maintainers
1
Created
Source

MySQLSlowQueryParser Build Status

Slow query log parser for MySQL

Installation

Add this line to your application's Gemfile:

gem 'mysql-slowquery-parser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mysql-slowquery-parser

Usage

slowquery = <<SLOW
/usr/local/Cellar/mysql/5.6.12/bin/mysqld, Version: 5.6.12 (Source distribution). started with:
Tcp port: 3306  Unix socket: /tmp/mysql.sock
Time                 Id Command    Argument
# Time: 140128 13:39:11
# User@Host: [user] @ localhost []  Id:     8
# Query_time: 2.001227  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1390883951;
SELECT
  *
FROM
  mysql.user;
/usr/local/Cellar/mysql/5.6.12/bin/mysqld, Version: 5.6.12 (Source distribution). started with:
Tcp port: 3306  Unix socket: /tmp/mysql.sock
Time                 Id Command    Argument
# Time: 140326  0:36:56
# User@Host: root[root] @ localhost []  Id:    51
# Query_time: 10.001140  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1395761816;
select sleep(10);
# Time: 140326  0:37:11
# User@Host: root[root] @ localhost []  Id:    51
# Query_time: 10.001114  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
use mysql;
SET timestamp=1395761831;
select sleep(10);
SLOW
MySQLSlowQueryParser.parse(slowquery)
[
  {
    datetime: 1390883951,
    user: 'user',
    host: 'localhost',
    query_time: 2.001227,
    lock_time: 0.0,
    rows_sent: 1,
    rows_examined: 0,
    sql: 'SELECT\n  *\nFROM\n  mysql.user'
  },
  {
    datetime: 1395761816,
    user: 'root',
    host: 'localhost',
    query_time: 10.00114,
    lock_time: 0.0,
    rows_sent: 1,
    rows_examined: 0,
    sql: 'select sleep(10)'
  },
  {
    datetime: 1395761831,
    user: 'root',
    host: 'localhost',
    query_time: 10.001114,
    lock_time: 0.0,
    rows_sent: 1,
    rows_examined: 0,
    db: 'mysql',
    sql: 'select sleep(10)'
  }
]

Contributing

  • Fork it ( https://github.com/studio3104/mysql-slowquery-parser/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

FAQs

Package last updated on 08 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts