mmtop 1.1.0 → 1.2.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: 7c77d53f05e5d2b75090ab37c8a5008ec9f8d31e
4
- data.tar.gz: aa11864d9175f6bad1b189329889b1dffbcb8b18
3
+ metadata.gz: e09aabaa1c7521869f8c71ebcdf377ccef19aafd
4
+ data.tar.gz: c22ad8441828e01e33666721b19f925329344926
5
5
  SHA512:
6
- metadata.gz: 62610dc63a6b3b9c292c90624aa31b5823ed8055fe22cc36c692bd0c267c59c3e829dbe6f0686a87bf5027aa54d95ab486820cbaee98a50683b3f066a7187e78
7
- data.tar.gz: 920420531c2b71f30f2def59baf9f735cf0fa47c105624af20d3419ce9397b4abcbe10a3ffe07822800a31f5a1e519e9c5e6c98fa2c20111068f85a1616d83fb
6
+ metadata.gz: a6ce83931dc20eeeec853c65eaba81af6454f9095eb5346947cf4316171e8d3766d8d1db7f843819ce11fc43eac60644ca19f4c8dbeb70f88d25712ad8be32a0
7
+ data.tar.gz: aa329db7374794f7e2f2d586da596728bd8324b072e340d6a0507d5ab3cd1ac663979e1776b3afe520925facef293b5f9a5441ee73b9a6195021ab5848d2adc3
@@ -137,3 +137,31 @@ MMTop::Command.register do |c|
137
137
  system("mysql --user='#{opt['user']}' --host='#{opt['host']}' --password='#{opt['password']}'")
138
138
  end
139
139
  end
140
+
141
+ MMTop::Command.register do |c|
142
+ c.regexp /^narrow (.*)/
143
+ c.usage "narrow HOST|off"
144
+ c.explain "only display queries on the cluster that contains HOST"
145
+
146
+
147
+ c.command do |cmd, config|
148
+ cmd =~ c.regexp
149
+ narrow_host = $1
150
+
151
+ MMTop::Topology.discover(config) # force discovery even if not configured
152
+
153
+ clusters = [[]]
154
+ config.hosts.each do |h|
155
+ if h.display_name =~ /^\s+\\/ # slave, starts with '\'. i know, i know.
156
+ clusters.last << h
157
+ else
158
+ clusters << [h]
159
+ end
160
+ end
161
+
162
+ clusters.each do |cluster|
163
+ matches = cluster.any? { |c| c.name == narrow_host || narrow_host.downcase == "off" }
164
+ cluster.each { |c| c.hide = !matches }
165
+ end
166
+ end
167
+ end
@@ -4,6 +4,14 @@ require 'socket'
4
4
 
5
5
  module MMTop
6
6
  class Topology
7
+ def self.discover(config)
8
+ if !config.options['topology.discovered']
9
+ config.options['topology.discovered'] = true
10
+ config.hosts = MMTop::Topology.new(config).new_hostlist
11
+ end
12
+ config
13
+ end
14
+
7
15
  def initialize(config)
8
16
  @config = config
9
17
  end
@@ -113,10 +121,7 @@ module MMTop
113
121
  end
114
122
 
115
123
  Filter.add_filter("discover_topology") do |queries, hostinfo, config|
116
- if config.options['discover_topology'] && !config.options['topology.discovered']
117
- config.options['topology.discovered'] = true
118
- config.hosts = MMTop::Topology.new(config).new_hostlist
119
- end
124
+ MMTop::Topology.discover(config) if config.options['discover_topology']
120
125
  end
121
126
 
122
127
  MMTop::Command.register do |c|
@@ -17,6 +17,7 @@ module MMTop
17
17
  @last_queries = nil
18
18
  @port = options['port'] || 3306
19
19
  @hide_if_empty = options['hide_if_empty']
20
+ @hide = false
20
21
 
21
22
  initialize_mysql2_cx(m2opts)
22
23
  end
@@ -35,7 +36,7 @@ module MMTop
35
36
  end
36
37
  end
37
38
 
38
- attr_accessor :display_name, :name, :comment, :options, :ip
39
+ attr_accessor :display_name, :name, :comment, :options, :ip, :hide
39
40
  attr_reader :port
40
41
 
41
42
  def hide_if_empty?
@@ -143,7 +143,7 @@ module MMTop
143
143
  end
144
144
 
145
145
  def print_host(info)
146
- return if info.processlist.empty? && info.host.hide_if_empty?
146
+ return if (info.processlist.empty? && info.host.hide_if_empty?) || info.host.hide
147
147
 
148
148
  display_name = info.host.display_name
149
149
  if info.host.dead?
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.1.0
4
+ version: 1.2.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-08-12 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: debugger
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -139,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
125
  version: '0'
140
126
  requirements: []
141
127
  rubyforge_project:
142
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.2.3
143
129
  signing_key:
144
130
  specification_version: 4
145
131
  summary: A mytop-ish variant that can watch many mysql servers