mmtop 1.2.0 → 1.2.1

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: e09aabaa1c7521869f8c71ebcdf377ccef19aafd
4
- data.tar.gz: c22ad8441828e01e33666721b19f925329344926
3
+ metadata.gz: 726bb7f95a803a865b5f6ecb0090e650853d603d
4
+ data.tar.gz: 0bddbf42784006cd7aa952cb36d26429ad2d793b
5
5
  SHA512:
6
- metadata.gz: a6ce83931dc20eeeec853c65eaba81af6454f9095eb5346947cf4316171e8d3766d8d1db7f843819ce11fc43eac60644ca19f4c8dbeb70f88d25712ad8be32a0
7
- data.tar.gz: aa329db7374794f7e2f2d586da596728bd8324b072e340d6a0507d5ab3cd1ac663979e1776b3afe520925facef293b5f9a5441ee73b9a6195021ab5848d2adc3
6
+ metadata.gz: 877f83c90dcb8ed235a7a79b99ddfc07cf7eebc92690a01235bd0453e1454bbb11baecf0b1f8b4a1a9040b69428617ea3d7cff83813ecaa6b4d6b3120a0f5d58
7
+ data.tar.gz: 860d4f2bfd070d81f87a547c60e8b08343699718d329a60a1c32889b627b5d1a26b73d5b98c5f3f52144cab847b891a44a93c2c6cc2b5b55e107ed9259ba2f38
@@ -1,5 +1,6 @@
1
1
  require 'mysql2'
2
2
  require 'mmtop/mmconfig'
3
+ require 'mmtop/version'
3
4
  require 'mmtop/host'
4
5
  require 'mmtop/process'
5
6
  require 'mmtop/term_printer'
@@ -6,6 +6,8 @@ MMTop::Command.register do |c|
6
6
  MMTop::Command.commands.sort_by(&:usage).each do |c|
7
7
  puts "%-50s %s" % [c.usage, c.explain]
8
8
  end
9
+ puts "%-50s %s" % ["[p]", "pause mmtop (how you got here)"]
10
+ puts "%-50s %s" % ["[enter]", "resume mmtop (how you leave here)"]
9
11
  end
10
12
  end
11
13
 
@@ -1,10 +1,42 @@
1
1
  module MMTop
2
2
  class PID
3
- def self.get
4
- @id += 1
3
+ @iteration = 0
4
+
5
+ def self.pid_array
6
+ @pid_array ||= []
7
+ end
8
+
9
+ def self.pid_hash
10
+ @pid_hash ||= {}
11
+ end
12
+
13
+ def self.get(host, real_id)
14
+ key = [host, real_id]
15
+
16
+ pid = pid_hash[key]
17
+ if !pid
18
+ pid = pid_array.index(nil) || pid_array.size
19
+ end
20
+
21
+ pid_hash[key] = pid
22
+ pid_array[pid] = @iteration
23
+ pid
5
24
  end
25
+
6
26
  def self.reset
7
- @id = 0
27
+ to_delete = pid_hash.map do |k, v|
28
+ # recycle pid after 2 loops
29
+ if pid_array[v] && pid_array[v] < @iteration - 1
30
+ k
31
+ end
32
+ end.compact
33
+
34
+ to_delete.each do |k|
35
+ idx = pid_hash.delete(k)
36
+ pid_array[idx] = nil
37
+ end
38
+
39
+ @iteration += 1
8
40
  end
9
41
  end
10
42
  end
@@ -17,7 +17,7 @@ module MMTop
17
17
  alias :database :db
18
18
 
19
19
  def id
20
- @id ||= MMTop::PID.get
20
+ @id ||= MMTop::PID.get(@host, @real_id)
21
21
  end
22
22
 
23
23
  def kill!
@@ -21,8 +21,10 @@ module MMTop
21
21
  def control_mode(config)
22
22
  raw(false)
23
23
  while true
24
- cmdline = Readline::readline('> ')
24
+ cmdline = Readline::readline('mmtop> ')
25
25
  exit if cmdline.nil?
26
+
27
+ cmdline.strip!
26
28
  Readline::HISTORY.push(cmdline)
27
29
  return if cmdline.empty?
28
30
  c = find_command(cmdline)
@@ -44,7 +44,10 @@ module MMTop
44
44
  end
45
45
 
46
46
  def print_footer
47
- puts corner + edge * (@x - 2) + corner
47
+ footer_banner = (" mmtop version #{MMTop::VERSION} ".dark_gray) + "...".dark_gray + " press \"p\" to pause ".dark_gray
48
+ left_border_size = (@x - 2 - footer_banner.size) / 2
49
+ right_border_size = @x - 2 - footer_banner.size - left_border_size
50
+ puts corner + (edge * left_border_size) + footer_banner + (edge * right_border_size) + corner
48
51
  end
49
52
 
50
53
  def table_header_columns
@@ -0,0 +1,3 @@
1
+ module MMTop
2
+ VERSION="1.2.1"
3
+ end
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -106,6 +106,7 @@ files:
106
106
  - lib/mmtop/string_colorize.rb
107
107
  - lib/mmtop/term_input.rb
108
108
  - lib/mmtop/term_printer.rb
109
+ - lib/mmtop/version.rb
109
110
  homepage: http://github.com/osheroff/mmtop
110
111
  licenses: []
111
112
  metadata: {}