mmtop 0.9.10 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/mmtop CHANGED
@@ -10,7 +10,6 @@ spec = <<-EOL
10
10
  -c, --config <FILE> Where to find mmtop_config
11
11
  -p, --password <pass> The password used to connect to all DBs
12
12
  -u, --user <user> The user used to connect to all DBs
13
- -o, --ops David's funky ops mode
14
13
  -q, --quick Display the stats once and exist.
15
14
  EOL
16
15
 
@@ -37,7 +37,7 @@ module MMTop
37
37
  puts "nothing, ok."
38
38
  else
39
39
  indexes = parse_kill_selection(line)
40
- indexes.each { |i|
40
+ indexes && indexes.each { |i|
41
41
  if i == "*"
42
42
  queries.each(&:kill!)
43
43
  elsif queries[i]
@@ -15,7 +15,13 @@ module MMTop
15
15
  @display_name = @name
16
16
  @comment = options['comment']
17
17
  @last_queries = nil
18
+ puts options
19
+ @hide_if_empty = options['hide_if_empty']
18
20
 
21
+ initialize_mysql2_cx(m2opts)
22
+ end
23
+
24
+ def initialize_mysql2_cx(m2opts)
19
25
  begin
20
26
  @mysql = Mysql2::Client.new(m2opts)
21
27
  rescue Mysql2::Error => e
@@ -27,12 +33,14 @@ module MMTop
27
33
  sleep(1)
28
34
  end
29
35
  end
30
-
31
- # rescue connection errors or sumpin
32
36
  end
33
37
 
34
38
  attr_accessor :display_name, :name, :comment, :options, :ip
35
39
 
40
+ def hide_if_empty?
41
+ !!@hide_if_empty
42
+ end
43
+
36
44
  def query(q)
37
45
  return [] if dead?
38
46
 
@@ -103,16 +111,15 @@ module MMTop
103
111
  class HostInfo
104
112
  def initialize(host, processlist, slave_status, stats)
105
113
  @host = host
106
- @processlist = processlist
107
114
  @connections = processlist.clone
108
115
  @slave_status = slave_status
109
116
  @stats = stats
117
+ @processlist = processlist
110
118
  end
111
119
 
112
- attr_reader :host, :processlist, :slave_status, :stats
113
-
114
- def connections
115
- @connections
120
+ def processlist
121
+ @processlist.select { |p| !p.status.nil? && !p.status.empty? }
116
122
  end
123
+ attr_reader :host, :slave_status, :stats, :connections
117
124
  end
118
125
  end
@@ -9,14 +9,13 @@ module MMTop
9
9
  raise "Please configure the 'hosts' section of mmtop_config"
10
10
  end
11
11
 
12
- user = cmdline['-u']
13
- pass = cmdline['-p']
12
+ cmdline_user = cmdline['-u']
13
+ cmdline_pass = cmdline['-p']
14
14
  @hosts = config['hosts'].map do |h|
15
15
  h = {'host' => h} if h.is_a?(String)
16
16
 
17
- h['user'] ||= (user || config['user'])
18
- h['password'] ||= (pass || config['password'])
19
- h['wedge_monitor'] ||= config['wedge_monitor']
17
+ defaults = {'user' => (cmdline_user || config['user']), 'password' => (cmdline_pass || config['password'])}
18
+ h = defaults.merge(h)
20
19
 
21
20
  Host.new(h['host'], h['user'], h['password'], h)
22
21
  end.compact.uniq { |h| h.name }
@@ -129,7 +129,6 @@ module MMTop
129
129
  end
130
130
 
131
131
  def print_process(p)
132
- return if p.status.nil? || p.status.empty?
133
132
  str = pipe + " " + column_value(0, p.client, ' ', :right)
134
133
  str += info_sep + column_value(1, p.id ? p.id.to_s : '')
135
134
  str += info_sep + column_value(2, format_time(p.time))
@@ -140,6 +139,8 @@ module MMTop
140
139
  end
141
140
 
142
141
  def print_host(info)
142
+ return if info.processlist.empty? && info.host.hide_if_empty?
143
+
143
144
  display_name = info.host.display_name
144
145
  display_name = (display_name + "!").red if info.host.dead?
145
146
  str = pipe + " " + column_value(0, display_name + " ", "-".dark_gray)
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmtop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
5
- prerelease:
4
+ version: 1.0.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Osheroff
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-16 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mysql2
@@ -116,8 +116,7 @@ files:
116
116
  - lib/mmtop/term_input.rb
117
117
  - lib/mmtop/term_printer.rb
118
118
  - lib/mmtop.rb
119
- - !binary |-
120
- YmluL21tdG9w
119
+ - bin/mmtop
121
120
  homepage: http://github.com/osheroff/mmtop
122
121
  licenses: []
123
122
  post_install_message:
@@ -130,18 +129,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
129
  - - ! '>='
131
130
  - !ruby/object:Gem::Version
132
131
  version: '0'
133
- segments:
134
- - 0
135
- hash: -870775084710735139
136
132
  required_rubygems_version: !ruby/object:Gem::Requirement
137
133
  none: false
138
134
  requirements:
139
- - - ! '>='
135
+ - - ! '>'
140
136
  - !ruby/object:Gem::Version
141
- version: '0'
142
- segments:
143
- - 0
144
- hash: -870775084710735139
137
+ version: 1.3.1
145
138
  requirements: []
146
139
  rubyforge_project:
147
140
  rubygems_version: 1.8.24