process-metrics 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 408d8c161d78bec40dbec084cbfa7d145a9fb9cddde7ee0eb6bf8b6c0cb407a8
4
- data.tar.gz: 81a6c24105ef52d4c486e0e54c7bca0714eb1c0fb012b4bef8009ce1f18e5c56
3
+ metadata.gz: f6eef8073c3bde206609e197c710ff0a3a7b5bb100b9e7e3081ceb1a3cafad4d
4
+ data.tar.gz: 8861bf2052c3cd39bc0e1d75682538efdce0c6bc6bbb444a44a4a12a8bbc23bd
5
5
  SHA512:
6
- metadata.gz: ff31a9c60ecb9dc2f06520b3aa043a481be9a6b0529e93343ea6a580167b6dff8eeae68d45ea3604c4db48dc393bc2cebe6b499e1c7926fafcb4d175bac82293
7
- data.tar.gz: ce6f3420c752a642d9da9b18ffeb6691f1172406595b5c051e32590b6f1b64d772785041464b42084549ab1ee41117599168a480cce5ee6b429d60f578c3c9a0
6
+ metadata.gz: 48118f047e6b37cae47ab65b5486c63009efc60379eeaf984bb0076e0a2890ff3be3e4ee6ded12d32dc3e18b805bb04564c590ad6233bef666b8238e88de76d4
7
+ data.tar.gz: 21c7a27dc3494df5a7ae7fa830af1bfe8d7989b388534e0b7b6bac1bd4416168a927e7efcfe13faba5abb369ec6ae51181d039f294b614166096a46ad88797b0
data/.gitignore CHANGED
@@ -7,6 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ Gemfile.lock
11
+
10
12
  # rspec failure tracking
11
13
  .rspec_status
12
14
  .covered.db
data/README.md CHANGED
@@ -14,7 +14,9 @@ To add it to your current project:
14
14
 
15
15
  Memory is measured in kilobytes and time is measured in seconds.
16
16
 
17
- ### Capturing for specific PID
17
+ ### Capturing for Specific Process
18
+
19
+ You can capture the metrics for a single process:
18
20
 
19
21
  ```ruby
20
22
  #!/usr/bin/env ruby
@@ -23,6 +25,43 @@ require 'process/metrics'
23
25
 
24
26
  metrics = Process::Metrics.capture(pid: Process.pid)
25
27
 
28
+ pp metrics
29
+ # [{:pid=>282195,
30
+ # :ppid=>230572,
31
+ # :pgid=>282195,
32
+ # :pcpu=>0.0,
33
+ # :time=>0,
34
+ # :vsz=>78800,
35
+ # :rss=>14360,
36
+ # :etime=>0,
37
+ # :command=>"ruby /tmp/6b35f421-4595-45d6-b444-754a50636daf",
38
+ # :memory=>
39
+ # {:total=>78804,
40
+ # :rss=>14600,
41
+ # :pss=>9208,
42
+ # :shared_clean=>5728,
43
+ # :shared_dirty=>0,
44
+ # :private_clean=>16,
45
+ # :private_dirty=>8856,
46
+ # :referenced=>14600,
47
+ # :anonymous=>8856,
48
+ # :swap=>0,
49
+ # :swap_pss=>0,
50
+ # :maps=>150}}]
51
+ ```
52
+
53
+ ### Capturing for Process Hierarchy
54
+
55
+ You can capture the metrics for a process and all it's children:
56
+
57
+ ```ruby
58
+ #!/usr/bin/env ruby
59
+
60
+ require 'process/metrics'
61
+
62
+ ppid = ENV["PPID"].to_i
63
+ metrics = Process::Metrics.capture(pid: ppid, ppid: ppid)
64
+
26
65
  pp metrics
27
66
  # [{:pid=>68536,
28
67
  # :ppid=>46295,
@@ -87,7 +87,7 @@ module Process
87
87
 
88
88
  arguments.push("-o", fields.keys.join(','))
89
89
 
90
- child_pid = Process.spawn(*arguments, out: output, pgroup: true)
90
+ ps_pid = Process.spawn(*arguments, out: output, pgroup: true)
91
91
 
92
92
  output.close
93
93
 
@@ -105,7 +105,9 @@ module Process
105
105
  hierarchy = Hash.new{|h,k| h[k] = []}
106
106
 
107
107
  processes.each do |process|
108
- hierarchy[process[:ppid]] << process[:pid]
108
+ unless process[:pid] == ps_pid
109
+ hierarchy[process[:ppid]] << process[:pid]
110
+ end
109
111
  end
110
112
 
111
113
  self.expand_children(Array(pid), hierarchy, pids)
@@ -126,7 +128,7 @@ module Process
126
128
 
127
129
  return processes
128
130
  ensure
129
- Process.wait(child_pid) if child_pid
131
+ Process.wait(ps_pid) if ps_pid
130
132
  end
131
133
  end
132
134
  end
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Process
24
24
  module Metrics
25
- VERSION = "0.1.0"
25
+ VERSION = "0.1.1"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -79,7 +79,6 @@ files:
79
79
  - ".rspec"
80
80
  - ".travis.yml"
81
81
  - Gemfile
82
- - Gemfile.lock
83
82
  - README.md
84
83
  - Rakefile
85
84
  - bin/console
@@ -109,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  requirements: []
112
- rubygems_version: 3.1.2
111
+ rubygems_version: 3.0.6
113
112
  signing_key:
114
113
  specification_version: 4
115
114
  summary: Provide detailed OS-specific process metrics.
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- process-metrics (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.0)
10
- async (1.24.1)
11
- console (~> 1.0)
12
- nio4r (~> 2.3)
13
- timers (~> 4.1)
14
- async-http (0.50.0)
15
- async (~> 1.23)
16
- async-io (~> 1.27.0)
17
- async-pool (~> 0.2)
18
- protocol-http (~> 0.13.0)
19
- protocol-http1 (~> 0.10.0)
20
- protocol-http2 (~> 0.10.0)
21
- async-io (1.27.1)
22
- async (~> 1.14)
23
- async-pool (0.2.0)
24
- async (~> 1.8)
25
- async-rest (0.12.1)
26
- async-http (~> 0.42)
27
- protocol-http (~> 0.7)
28
- console (1.7.0)
29
- covered (0.13.1)
30
- async-rest
31
- console (~> 1.0)
32
- msgpack
33
- parser
34
- diff-lcs (1.3)
35
- msgpack (1.3.1)
36
- nio4r (2.5.2)
37
- parser (2.7.0.0)
38
- ast (~> 2.4.0)
39
- protocol-hpack (1.4.1)
40
- protocol-http (0.13.0)
41
- protocol-http1 (0.10.0)
42
- protocol-http (~> 0.13)
43
- protocol-http2 (0.10.4)
44
- protocol-hpack (~> 1.4)
45
- protocol-http (~> 0.2)
46
- rake (12.3.3)
47
- rspec (3.9.0)
48
- rspec-core (~> 3.9.0)
49
- rspec-expectations (~> 3.9.0)
50
- rspec-mocks (~> 3.9.0)
51
- rspec-core (3.9.1)
52
- rspec-support (~> 3.9.1)
53
- rspec-expectations (3.9.0)
54
- diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.9.0)
56
- rspec-mocks (3.9.0)
57
- diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.9.0)
59
- rspec-support (3.9.1)
60
- timers (4.3.0)
61
-
62
- PLATFORMS
63
- ruby
64
-
65
- DEPENDENCIES
66
- bundler
67
- covered
68
- process-metrics!
69
- rake (~> 12.0)
70
- rspec (~> 3.8)
71
-
72
- BUNDLED WITH
73
- 2.1.2