process-metrics 0.7.0 → 0.8.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/process/metrics/general.rb +31 -18
- data/lib/process/metrics/memory/linux.rb +4 -4
- data/lib/process/metrics/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b288419449c98ce2b53cc2ecb8d3d2660a473c17677b66e6f18015b803db1482
|
|
4
|
+
data.tar.gz: 67b4d639f7744814e47e61aac54ef7c588557a94ca8454926594d742f9cf88ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a1686b0609d8009a2d5a26b659876c29c5378d89b35b39777b5d55d53413b2a10558470075ce0303959f77213ceef101cad19547dc95743440d0243af2746e1
|
|
7
|
+
data.tar.gz: 13a3e9bbc06eb5412a6b37c499f531eebf58317c1944d0e679dd68d8b87abc4450e62b7166c435334745555d26bb873b9ddc47d65324bdf17832b27865f60a2c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -137,25 +137,40 @@ module Process
|
|
|
137
137
|
#
|
|
138
138
|
# @parameter pid [Integer] The process ID to capture.
|
|
139
139
|
# @parameter ppid [Integer] The parent process ID to capture.
|
|
140
|
-
def self.capture(pid: nil, ppid: nil,
|
|
141
|
-
|
|
140
|
+
def self.capture(pid: nil, ppid: nil, memory: Memory.supported?)
|
|
141
|
+
ps_pid = nil
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
# Extract the information from the `ps` command:
|
|
144
|
+
header, *lines = IO.pipe do |input, output|
|
|
145
|
+
arguments = [PS]
|
|
146
|
+
|
|
147
|
+
if pid && ppid.nil?
|
|
148
|
+
arguments.push("-p", Array(pid).join(","))
|
|
149
|
+
else
|
|
150
|
+
arguments.push("ax")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
arguments.push("-o", FIELDS.keys.join(","))
|
|
154
|
+
|
|
155
|
+
ps_pid = Process.spawn(*arguments, out: output)
|
|
156
|
+
output.close
|
|
157
|
+
|
|
158
|
+
input.readlines.map(&:strip)
|
|
159
|
+
ensure
|
|
160
|
+
input.close
|
|
161
|
+
|
|
162
|
+
if ps_pid
|
|
163
|
+
begin
|
|
164
|
+
# Make sure to kill the ps process if it's still running:
|
|
165
|
+
Process.kill(:KILL, ps_pid)
|
|
166
|
+
# Reap the process:
|
|
167
|
+
Process.wait(ps_pid)
|
|
168
|
+
rescue => error
|
|
169
|
+
warn "Failed to cleanup ps process #{ps_pid}:\n#{error.full_message}"
|
|
170
|
+
end
|
|
171
|
+
end
|
|
149
172
|
end
|
|
150
173
|
|
|
151
|
-
arguments.push("-o", FIELDS.keys.join(","))
|
|
152
|
-
|
|
153
|
-
ps_pid = Process.spawn(*arguments, out: output, pgroup: true)
|
|
154
|
-
|
|
155
|
-
output.close
|
|
156
|
-
|
|
157
|
-
header, *lines = input.readlines.map(&:strip)
|
|
158
|
-
|
|
159
174
|
processes = {}
|
|
160
175
|
|
|
161
176
|
lines.map do |line|
|
|
@@ -187,8 +202,6 @@ module Process
|
|
|
187
202
|
end
|
|
188
203
|
|
|
189
204
|
return processes
|
|
190
|
-
ensure
|
|
191
|
-
Process.wait(ps_pid) if ps_pid
|
|
192
205
|
end
|
|
193
206
|
end
|
|
194
207
|
end
|
|
@@ -71,8 +71,8 @@ module Process
|
|
|
71
71
|
|
|
72
72
|
return usage
|
|
73
73
|
end
|
|
74
|
-
rescue Errno::ENOENT, Errno::ESRCH
|
|
75
|
-
# Process doesn't exist.
|
|
74
|
+
rescue Errno::ENOENT, Errno::ESRCH, Errno::EACCES
|
|
75
|
+
# Process doesn't exist or we can't access it.
|
|
76
76
|
return nil
|
|
77
77
|
end
|
|
78
78
|
elsif File.readable?("/proc/self/smaps")
|
|
@@ -105,8 +105,8 @@ module Process
|
|
|
105
105
|
|
|
106
106
|
return usage
|
|
107
107
|
end
|
|
108
|
-
rescue Errno::ENOENT, Errno::ESRCH
|
|
109
|
-
# Process doesn't exist.
|
|
108
|
+
rescue Errno::ENOENT, Errno::ESRCH, Errno::EACCES
|
|
109
|
+
# Process doesn't exist or we can't access it.
|
|
110
110
|
return nil
|
|
111
111
|
end
|
|
112
112
|
else
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|