puma-status 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/core.rb +4 -4
  3. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ded7bd0b4bca01b8b07ca16c7380453cf96f49d0c00667d024a6317d7307cea0
4
- data.tar.gz: a391f836ca1c5d1a40acbab75178fd4c569d25005fac3c83bfd981051e1a7d66
3
+ metadata.gz: 22bea1d3a501185590a81878994456d75a4c5375794221bdeb51b3283d65cceb
4
+ data.tar.gz: a2670a54fdd6c4dae1040c59882f969ba1aff3487076d75962e2fa105da32b59
5
5
  SHA512:
6
- metadata.gz: c3968446849e0078c9cb557c721a1f5a2226a5ca1533016b319d15ec4c2e769a88062c8f354de28451fad533ba6502707a79660bf9a0469c677482f270ab1c65
7
- data.tar.gz: e186aefc643f0ce7bfaf9515d5a36fc71558c0a871d792914e55e5867d5d0d9e4e32d04a71f27429ab1ae19f43054d06ae00c47911f209bcf423c197e4c586b6
6
+ metadata.gz: '09d1cfd981ee0c5092e9bda66009e2a4b517f3bfe3987559cfb571a9a4aa0c880e6ca45061cbd0a0c8bbc5016d2a11ba3410facc67b9924ab7643512110b2711'
7
+ data.tar.gz: 023b10377d8567d59c3b75028c4cd54c2f3db12d686bcf41d5a6fcd69aabf45c6e5a89b3c956afa8e98d7ec696c5ef85801fd6a8625adf6b9d42a1aea9a584fc
data/lib/core.rb CHANGED
@@ -3,6 +3,7 @@ require 'json'
3
3
  require 'net_x/http_unix'
4
4
  require 'openssl'
5
5
  require 'time'
6
+ require 'open3'
6
7
  require_relative 'stats'
7
8
 
8
9
  def get_stats(state_file_path)
@@ -33,8 +34,6 @@ def get_stats(state_file_path)
33
34
  end
34
35
 
35
36
  def get_memory_from_top(raw_memory)
36
- raw_memory.tr!(',', '.') # because of LC_NUMERIC separator can be ,
37
-
38
37
  case raw_memory[-1].downcase
39
38
  when 'g'
40
39
  (raw_memory[0...-1].to_f*1024).to_i
@@ -48,11 +47,12 @@ end
48
47
  PID_COLUMN = 0
49
48
  MEM_COLUMN = 5
50
49
  CPU_COLUMN = 8
50
+ OPEN3_STDOUT = 1
51
51
 
52
52
  def get_top_stats(pids)
53
53
  pids.each_slice(19).inject({}) do |res, pids19|
54
- top_result = `top -b -n 1 -p #{pids19.join(',')} | tail -n #{pids19.length}`
55
- top_result.split("\n").map { |row| r = row.split(' '); [r[PID_COLUMN].to_i, get_memory_from_top(r[MEM_COLUMN]), r[CPU_COLUMN].to_f] }
54
+ top_result = Open3.popen3({ 'LC_ALL' => 'C' }, "top -b -n 1 -p #{pids19.map(&:to_i).join(',')}")[OPEN3_STDOUT].read
55
+ top_result.split("\n").last(pids19.length).map { |row| r = row.split(' '); [r[PID_COLUMN].to_i, get_memory_from_top(r[MEM_COLUMN]), r[CPU_COLUMN].to_f] }
56
56
  .inject(res) { |hash, row| hash[row[0]] = { mem: row[1], pcpu: row[2] }; hash }
57
57
  res
58
58
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-status
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoann Lecuyer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-07-14 00:00:00.000000000 Z
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.9'
97
- description:
98
- email:
97
+ description:
98
+ email:
99
99
  executables:
100
100
  - puma-status
101
101
  extensions: []
@@ -111,7 +111,7 @@ homepage: https://github.com/ylecuyer/puma-status
111
111
  licenses:
112
112
  - MIT
113
113
  metadata: {}
114
- post_install_message:
114
+ post_install_message:
115
115
  rdoc_options: []
116
116
  require_paths:
117
117
  - lib
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.3.0.dev
130
- signing_key:
129
+ rubygems_version: 3.0.0
130
+ signing_key:
131
131
  specification_version: 4
132
132
  summary: Command-line tool for puma to display information about running request/process
133
133
  test_files: []