mmtop 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7202089cd59af312556434bc4f7f769706210f2b
4
- data.tar.gz: 096c4a0138bf7a1dbcb8b6c046d8b02d2aa0dc8e
3
+ metadata.gz: 7c77d53f05e5d2b75090ab37c8a5008ec9f8d31e
4
+ data.tar.gz: aa11864d9175f6bad1b189329889b1dffbcb8b18
5
5
  SHA512:
6
- metadata.gz: 445308ce09fca660c9d394cbc735f9864b384a435c95364848d3981b8ea027aa9746b3e0bcf5092e8652085c41e66f3dca317e8ebe65bfdbee71b850a303f012
7
- data.tar.gz: 196a5b6afe5ae7081812fe09e21eed141760b89b95ca5b5f7369f7b2e0b7ebaa05dfce3272da3248d52c4d40f984129a33b7a61fddbc8aea51c339245873b77e
6
+ metadata.gz: 62610dc63a6b3b9c292c90624aa31b5823ed8055fe22cc36c692bd0c267c59c3e829dbe6f0686a87bf5027aa54d95ab486820cbaee98a50683b3f066a7187e78
7
+ data.tar.gz: 920420531c2b71f30f2def59baf9f735cf0fa47c105624af20d3419ce9397b4abcbe10a3ffe07822800a31f5a1e519e9c5e6c98fa2c20111068f85a1616d83fb
@@ -18,19 +18,35 @@ MMTop::Command.register do |c|
18
18
  end
19
19
  end
20
20
 
21
-
21
+
22
22
  MMTop::Command.register do |c|
23
23
  c.regexp /^[x|(?:examine)]\s+(\d+)/
24
24
  c.usage "x PID"
25
25
  c.explain "Show full query"
26
+
27
+ cols = ["status", "time", "client", "src_port", "server", "database"]
28
+ print_ps = lambda do |ps|
29
+ h = {}
30
+ headers = ""
31
+ data = ""
32
+ cols.each { |c|
33
+ val = ps.send(c)
34
+ size = [val.size, c.size].max + 2
35
+ headers += "%-#{size}s" % [c]
36
+ data += "%-#{size}s" % [val]
37
+ }
38
+
39
+ puts headers
40
+ puts data
41
+ puts ps.sql
42
+ end
43
+
26
44
  c.command do |cmd, config|
27
45
  cmd =~ c.regexp
28
46
  pid = $1.to_i
29
47
  ps = config.find_pid(pid)
30
48
  if ps
31
- puts "%-20s%-6s%-20s%-20s%-20s" % ["status","time","client", "server", "database"]
32
- puts "%-20s%-6s%-20s%-20s%-20s" % [ps.status, ps.time, ps.client, ps.host.name, ps.db]
33
- puts ps.sql
49
+ print_ps.call(ps)
34
50
  else
35
51
  puts "No such pid #{p}"
36
52
  end
@@ -94,3 +110,30 @@ MMTop::Command.register do |c|
94
110
  config.options['sleep'] = sleep
95
111
  end
96
112
  end
113
+
114
+ MMTop::Command.register do |c|
115
+ c.regexp /^shell (.*)/
116
+ c.usage "shell HOST|PID"
117
+ c.explain "open up a mysql command-line client on HOST or on the database that PID is on"
118
+ c.command do |cmd, config|
119
+ cmd =~ c.regexp
120
+ match = $1
121
+
122
+ if match =~ /^\d+$/
123
+ ps = config.find_pid(match.to_i)
124
+ if !ps
125
+ break puts "No such PID: #{match}"
126
+ end
127
+
128
+ host = ps.host
129
+ else
130
+ server = config.find_server(match)
131
+ if !server
132
+ break puts "No such host: #{server}"
133
+ end
134
+ host = server.host
135
+ end
136
+ opt = host.options
137
+ system("mysql --user='#{opt['user']}' --host='#{opt['host']}' --password='#{opt['password']}'")
138
+ end
139
+ end
@@ -14,6 +14,7 @@ module MMTop
14
14
  end
15
15
 
16
16
  attr_accessor :query, :status, :time, :client, :host, :db
17
+ alias :database :db
17
18
 
18
19
  def id
19
20
  @id ||= MMTop::PID.get
@@ -33,6 +34,13 @@ module MMTop
33
34
  end
34
35
  end
35
36
 
37
+ def server
38
+ @host.name
39
+ end
40
+
41
+ def src_port
42
+ @client_port
43
+ end
36
44
 
37
45
  def sql
38
46
  @query
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmtop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2