puma-status 1.1 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/core.rb +19 -2
  3. data/lib/helpers.rb +4 -2
  4. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12ca14da024cebc278c903552c9bfe21afccfabec8baea2972ac4b3e7b241ab1
4
- data.tar.gz: f738a71b63d55124ee43e921f69f9d81295360c9d43925716ed0bb3716751907
3
+ metadata.gz: ec73cc842d7b353e3f3994d554c4fdc6b1b7eab51452c578581d855610af613d
4
+ data.tar.gz: 6d44df05c3a303e3440406146921f4955a85fbded8ae131b29f1fec83f56b8fa
5
5
  SHA512:
6
- metadata.gz: 4b96bb8f8ebd7776dd6a3b023c533e53638bf63da61efe5e5c9abb9111ff0ad05aa615584ffa3a804e00ddc1d7cc8cabbec46be677044139e97b722a60eb7f62
7
- data.tar.gz: e136edb4aed4f52dc06ecda5e48b43b4c92e13b79619277c0d63cc4ac960009855ec4a8d475fe8c23721e0164799b6692f4863b506ac2eb7cf5039551d723af6
6
+ metadata.gz: ab70d17e5b5c35bacce07819392f2818f62020287d7070618af64fa58e1da9f71fe7de126f60d2886a29c2d13d6e31698f071784f6f98c9c5773a7ee934e16b6
7
+ data.tar.gz: 41a1df505a6bb1299973a8972522b700d16b9d40232f567e237b20ce637de89733a72e7eae4944dcd0950c0c7b13a755353fbca601da55dc4d56167b5b2f8a66
@@ -19,7 +19,7 @@ def get_stats(state_file_path)
19
19
  client = NetX::HTTPUnix.new(address, uri.port)
20
20
 
21
21
  if uri.scheme =~ /ssl/i
22
- client.use_ssl = true
22
+ client.use_ssl = true
23
23
  client.verify_mode = OpenSSL::SSL::VERIFY_NONE if ENV['SSL_NO_VERIFY'] == '1'
24
24
  end
25
25
 
@@ -32,10 +32,27 @@ def get_stats(state_file_path)
32
32
  hydrate_stats(stats, puma_state, state_file_path)
33
33
  end
34
34
 
35
+ def get_memory_from_top(raw_memory)
36
+ raw_memory.tr!(',', '.') # because of LC_NUMERIC separator can be ,
37
+
38
+ case raw_memory[-1].downcase
39
+ when 'g'
40
+ (raw_memory[0...-1].to_f*1024).to_i
41
+ when 'm'
42
+ raw_memory[0...-1].to_i
43
+ else
44
+ raw_memory.to_i/1024
45
+ end
46
+ end
47
+
48
+ PID_COLUMN = 0
49
+ MEM_COLUMN = 5
50
+ CPU_COLUMN = 8
51
+
35
52
  def get_top_stats(pids)
36
53
  pids.each_slice(19).inject({}) do |res, pids19|
37
54
  top_result = `top -b -n 1 -p #{pids19.join(',')} | tail -n #{pids19.length}`
38
- top_result.split("\n").map { |row| r = row.split(' '); [r[0].to_i, r[5].to_i/1024, r[8].to_f] }
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] }
39
56
  .inject(res) { |hash, row| hash[row[0]] = { mem: row[1], pcpu: row[2] }; hash }
40
57
  res
41
58
  end
@@ -44,8 +44,10 @@ def seconds_to_human(seconds)
44
44
  #=> 23h59m
45
45
  #=> 1d 0h
46
46
  #=> 24d
47
-
48
- if seconds < 60*60
47
+
48
+ if seconds <= 0
49
+ "--m--s"
50
+ elsif seconds < 60*60
49
51
  "#{(seconds/60).to_s.rjust(2, ' ')}m#{(seconds%60).to_s.rjust(2, ' ')}s"
50
52
  elsif seconds >= 60*60*1 && seconds < 60*60*24
51
53
  "#{(seconds/(60*60*1)).to_s.rjust(2, ' ')}h#{((seconds%(60*60*1))/60).to_s.rjust(2, ' ')}m"
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.1'
4
+ version: '1.2'
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.0.0
130
- signing_key:
129
+ rubygems_version: 3.2.3
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: []