sys-proctable 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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +9 -0
- data/README.md +158 -0
- data/lib/darwin/sys/proctable.rb +66 -34
- data/lib/sys/proctable/version.rb +1 -1
- data/spec/sys_proctable_all_spec.rb +1 -1
- data/sys-proctable.gemspec +12 -3
- metadata +33 -27
- metadata.gz.sig +0 -0
- data/README +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb96b1cfb746706244c26f2ce85f54740163cb9f9174237fd06767849ca62cb8
|
4
|
+
data.tar.gz: f8b0b6d47efb86e64a630331a3408deb5baf2a6c8b1256bf55a0bad76f9c17c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72bf0ffb98c4362deeb9506c6d2f50147c327fe0862575b06f5de1d342e6c9b3a7d5a0fd9a51d69e15cd2f1f68f8d8a9d67ceba12b8a8350f123498b759c4ac0
|
7
|
+
data.tar.gz: 9acdc748cffeee40be36cff671b9f8057ec7fd9f416609f326882c28dfa5b9dd4fddba07a56ed9d64fe9d27b2743c242a3a9b04f902a2f9c3b442ab4ca38a2e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
+
== 1.2.1 - 8-Jun-2018
|
2
|
+
* The code for OSX is now more efficient when a pid argument is provided.
|
3
|
+
Thanks go to Nick LaMuro for his efforts.
|
4
|
+
* Added metadata to the gemspec.
|
5
|
+
* Switched the README (now README.md) to markdown format. Thanks go to
|
6
|
+
Tim Meusel for the update.
|
7
|
+
* Updated the cert. Should be good for ten years now.
|
8
|
+
|
1
9
|
== 1.2.0 - 20-Feb-2018
|
2
10
|
* There has been an API change. The ProcTable.ps method now uses keyword
|
3
11
|
arguments. The 'pid' option is universal, the rest depend on the platform.
|
12
|
+
As part of this change, support for Ruby < 2.0 has been dropped.
|
4
13
|
* Support for HP-UX has been dropped, both because it was the last remaining
|
5
14
|
platform that still used C code, and because it's basically a dead platform.
|
6
15
|
* There are no more platform-specific gems. There is now a single gem that
|
data/README.md
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
# sys-proctable
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
A Ruby interface for gathering process information.
|
6
|
+
|
7
|
+
## Prerequisites
|
8
|
+
|
9
|
+
* RSpec 3.x (development only)
|
10
|
+
|
11
|
+
## Supported Platforms
|
12
|
+
|
13
|
+
* Windows 2000 or later
|
14
|
+
* Linux 2.6+
|
15
|
+
* FreeBSD
|
16
|
+
* Solaris 8+
|
17
|
+
* OS X 10.7+
|
18
|
+
* AIX 5.3+
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
```sh
|
23
|
+
gem install sys-proctable
|
24
|
+
```
|
25
|
+
|
26
|
+
For version 1.1.5 or earlier, you may need to specify a platform in some cases. For example:
|
27
|
+
|
28
|
+
```sh
|
29
|
+
gem install sys-proctable --platform mswin32 # Windows
|
30
|
+
gem install sys-proctable --platform sunos # Solaris
|
31
|
+
gem install sys-proctable --platform linux # Linux
|
32
|
+
gem install sys-proctable --platform freebsd # FreeBSD
|
33
|
+
gem install sys-proctable --platform darwin # OS X
|
34
|
+
```
|
35
|
+
|
36
|
+
## Synopsis
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'sys/proctable'
|
40
|
+
include Sys
|
41
|
+
|
42
|
+
# Everything
|
43
|
+
ProcTable.ps{ |p|
|
44
|
+
puts p.pid.to_s
|
45
|
+
puts p.comm
|
46
|
+
# ...
|
47
|
+
}
|
48
|
+
|
49
|
+
# Just one process
|
50
|
+
s = ProcTable.ps(pid: 2123)
|
51
|
+
puts s.pid.to_s
|
52
|
+
puts s.comm
|
53
|
+
# ...
|
54
|
+
|
55
|
+
# Return the results as an array of ProcTableStructs
|
56
|
+
a = ProcTable.ps
|
57
|
+
a.each do |p|
|
58
|
+
puts p.pid
|
59
|
+
# ...
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
## Notes
|
64
|
+
|
65
|
+
Various platforms support different options. Mostly this is to let you
|
66
|
+
skip the collection of certain bits of information in order to improve
|
67
|
+
speed and/or reduce memory. For example on Linux you can do this to
|
68
|
+
skip the collection of smaps information:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
Sys::ProcTable.ps(smaps: false)
|
72
|
+
```
|
73
|
+
|
74
|
+
Windows users may send a host name to get process information from a
|
75
|
+
different host. This relies on the WMI service running.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Sys::ProcTable.ps(host: some_host)
|
79
|
+
```
|
80
|
+
|
81
|
+
## Known Issues
|
82
|
+
|
83
|
+
### FreeBSD
|
84
|
+
|
85
|
+
A kvm interface is used. That means the owner of the process using the
|
86
|
+
sys-proctable library needs to be a member of the kvm group (or root).
|
87
|
+
|
88
|
+
### Bundler
|
89
|
+
|
90
|
+
For version 1.1.5 or earlier, Bundler seems to have trouble installing the
|
91
|
+
proper gem because of the platform specific gem names. To deal with that,
|
92
|
+
run this command first:
|
93
|
+
|
94
|
+
```sh
|
95
|
+
bundle config specific_platform true
|
96
|
+
```
|
97
|
+
|
98
|
+
You should not have to do this for version 1.2.0 or later.
|
99
|
+
|
100
|
+
### Solaris
|
101
|
+
|
102
|
+
The cmdline member on Solaris is limited to 80 characters unless you (or
|
103
|
+
your program) own the process. This is a Solaris design flaw/feature.
|
104
|
+
|
105
|
+
### OS X
|
106
|
+
|
107
|
+
The libproc interface is used. That means you will only get list of
|
108
|
+
processes that you have access to. To get a full listing, run as root.
|
109
|
+
|
110
|
+
## Future Plans
|
111
|
+
|
112
|
+
Support for Solaris will probably be dropped in the next major release.
|
113
|
+
|
114
|
+
## Acknowledgements
|
115
|
+
|
116
|
+
This library was originally based on the Perl module Proc::ProcessTable
|
117
|
+
by Dan Urist. Many ideas, as well as large chunks of code, were taken
|
118
|
+
from his work. So, a big THANK YOU goes out to Dan Urist.
|
119
|
+
|
120
|
+
A big thanks also goes out to Mike Hall who was very helpful with ideas,
|
121
|
+
logic and testing.
|
122
|
+
|
123
|
+
Thanks also go to Sean Chittenden for providing an account on one of his
|
124
|
+
FreeBSD machines. This is how the FreeBSD support was (initially) added.
|
125
|
+
|
126
|
+
Thanks go to James Hranicky for providing a patch that grabs name, eid,
|
127
|
+
euid, gid and guid info in the Linux version, along with some general
|
128
|
+
debugging help.
|
129
|
+
|
130
|
+
Thanks go to David Felstead for the original OS X code. Thanks also go
|
131
|
+
to Matthias Zirnstein for adding the original cmdline support for OS X.
|
132
|
+
|
133
|
+
Finally I'd like to thank all the folks who have submitted bug reports
|
134
|
+
and/or patches.
|
135
|
+
|
136
|
+
## Help Wanted
|
137
|
+
|
138
|
+
I do not have access to all platforms. If your platform is not supported
|
139
|
+
then you will need to either submit a patch or give me a remote account
|
140
|
+
on a box with a compiler so that I can write the code.
|
141
|
+
|
142
|
+
## More documentation
|
143
|
+
|
144
|
+
See the documentation under the 'doc' directory for more information,
|
145
|
+
including platform specific notes and issues.
|
146
|
+
|
147
|
+
## License
|
148
|
+
|
149
|
+
Apache 2.0
|
150
|
+
|
151
|
+
## Copyright
|
152
|
+
|
153
|
+
(C) 2003-2018 Daniel J. Berger
|
154
|
+
All Rights Reserved.
|
155
|
+
|
156
|
+
## Author
|
157
|
+
|
158
|
+
Daniel J. Berger
|
data/lib/darwin/sys/proctable.rb
CHANGED
@@ -174,66 +174,98 @@ module Sys
|
|
174
174
|
#
|
175
175
|
def self.ps(**kwargs)
|
176
176
|
pid = kwargs[:pid]
|
177
|
-
|
177
|
+
thread_info = kwargs[:thread_info]
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
num = proc_listallpids(ptr, ptr.size)
|
182
|
-
|
183
|
-
raise SystemCallError.new('proc_listallpids', FFI.errno) if num == 0
|
184
|
-
|
185
|
-
pids = ptr.get_array_of_int32(0, num).sort
|
186
|
-
array = block_given? ? nil : []
|
187
|
-
|
188
|
-
pids.each do |lpid|
|
189
|
-
next unless pid == lpid if pid
|
179
|
+
if pid
|
180
|
+
raise TypeError unless pid.is_a?(Numeric)
|
190
181
|
info = ProcTaskAllInfo.new
|
191
182
|
|
192
|
-
nb = proc_pidinfo(
|
183
|
+
nb = proc_pidinfo(pid, PROC_PIDTASKALLINFO, 0, info, info.size)
|
193
184
|
|
194
185
|
if nb <= 0
|
195
186
|
if [Errno::EPERM::Errno, Errno::ESRCH::Errno].include?(FFI.errno)
|
196
|
-
|
187
|
+
return # Either we don't have permission, or the pid no longer exists
|
197
188
|
else
|
198
189
|
raise SystemCallError.new('proc_pidinfo', FFI.errno)
|
199
190
|
end
|
200
191
|
end
|
201
192
|
|
202
|
-
|
203
|
-
next if nb != info.size
|
193
|
+
return nil if nb != info.size # Invalid data
|
204
194
|
|
205
195
|
struct = ProcTableStruct.new
|
206
196
|
|
207
197
|
# Pass by reference
|
208
|
-
get_cmd_args_and_env(
|
209
|
-
get_thread_info(
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
198
|
+
get_cmd_args_and_env(pid, struct)
|
199
|
+
get_thread_info(pid, struct, info[:ptinfo]) unless thread_info == false
|
200
|
+
apply_info_to_struct(info, struct)
|
201
|
+
|
202
|
+
struct.freeze
|
203
|
+
yield struct if block_given?
|
204
|
+
struct
|
205
|
+
else
|
206
|
+
num = proc_listallpids(nil, 0)
|
207
|
+
ptr = FFI::MemoryPointer.new(:pid_t, num)
|
208
|
+
num = proc_listallpids(ptr, ptr.size)
|
209
|
+
|
210
|
+
raise SystemCallError.new('proc_listallpids', FFI.errno) if num == 0
|
211
|
+
|
212
|
+
pids = ptr.get_array_of_int32(0, num).sort
|
213
|
+
array = block_given? ? nil : []
|
214
|
+
|
215
|
+
pids.each do |lpid|
|
216
|
+
next unless pid == lpid if pid
|
217
|
+
info = ProcTaskAllInfo.new
|
218
|
+
|
219
|
+
nb = proc_pidinfo(lpid, PROC_PIDTASKALLINFO, 0, info, info.size)
|
220
|
+
|
221
|
+
if nb <= 0
|
222
|
+
if [Errno::EPERM::Errno, Errno::ESRCH::Errno].include?(FFI.errno)
|
223
|
+
next # Either we don't have permission, or the pid no longer exists
|
216
224
|
else
|
217
|
-
|
225
|
+
raise SystemCallError.new('proc_pidinfo', FFI.errno)
|
218
226
|
end
|
219
227
|
end
|
220
|
-
end
|
221
228
|
|
222
|
-
|
229
|
+
# Avoid potentially invalid data
|
230
|
+
next if nb != info.size
|
223
231
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
232
|
+
struct = ProcTableStruct.new
|
233
|
+
|
234
|
+
# Pass by reference
|
235
|
+
get_cmd_args_and_env(lpid, struct)
|
236
|
+
get_thread_info(lpid, struct, info[:ptinfo]) unless thread_info == false
|
237
|
+
apply_info_to_struct(info, struct)
|
238
|
+
|
239
|
+
struct.freeze
|
240
|
+
|
241
|
+
if block_given?
|
242
|
+
yield struct
|
243
|
+
else
|
244
|
+
array << struct
|
245
|
+
end
|
228
246
|
end
|
229
|
-
end
|
230
247
|
|
231
|
-
|
232
|
-
|
248
|
+
array
|
249
|
+
end
|
233
250
|
end
|
234
251
|
|
235
252
|
private
|
236
253
|
|
254
|
+
# Pass by reference method that updates the Ruby struct based on the FFI struct.
|
255
|
+
#
|
256
|
+
def self.apply_info_to_struct(info, struct)
|
257
|
+
# Chop the leading xx_ from the FFI struct members for our ruby struct.
|
258
|
+
info.members.each do |nested|
|
259
|
+
info[nested].members.each do |member|
|
260
|
+
if info[nested][member].is_a?(FFI::StructLayout::CharArray)
|
261
|
+
struct[PROC_STRUCT_FIELD_MAP[member]] = info[nested][member].to_s
|
262
|
+
else
|
263
|
+
struct[PROC_STRUCT_FIELD_MAP[member]] = info[nested][member]
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
237
269
|
# Returns an array of ThreadInfo objects for the given pid.
|
238
270
|
#
|
239
271
|
def self.get_thread_info(pid, struct, ptinfo)
|
data/sys-proctable.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-proctable'
|
5
|
-
spec.version = '1.2.
|
5
|
+
spec.version = '1.2.1'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Apache 2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
@@ -18,16 +18,25 @@ Gem::Specification.new do |spec|
|
|
18
18
|
'CHANGES',
|
19
19
|
'MANIFEST',
|
20
20
|
'Rakefile',
|
21
|
-
'README',
|
21
|
+
'README.md',
|
22
22
|
'sys-proctable.gemspec'
|
23
23
|
]
|
24
24
|
|
25
|
-
spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
|
25
|
+
spec.extra_rdoc_files = ['CHANGES', 'README.md', 'MANIFEST', 'doc/top.txt']
|
26
26
|
|
27
27
|
spec.add_dependency('ffi')
|
28
28
|
spec.add_development_dependency('rspec')
|
29
29
|
spec.add_development_dependency('rake')
|
30
30
|
|
31
|
+
spec.metadata = {
|
32
|
+
'homepage_uri' => 'https://github.com/djberg96/sys-proctable',
|
33
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/sys-proctable/issues',
|
34
|
+
'changelog_uri' => 'https://github.com/djberg96/sys-proctable/blob/master/CHANGES',
|
35
|
+
'documentation_uri' => 'https://github.com/djberg96/sys-proctable/wiki',
|
36
|
+
'source_code_uri' => 'https://github.com/djberg96/sys-proctable',
|
37
|
+
'wiki_uri' => 'https://github.com/djberg96/sys-proctable/wiki'
|
38
|
+
}
|
39
|
+
|
31
40
|
spec.description = <<-EOF
|
32
41
|
The sys-proctable library provides an interface for gathering information
|
33
42
|
about processes on your system, i.e. the process table. Most major
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-proctable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -12,30 +12,30 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
|
14
14
|
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
-
|
15
|
+
MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
|
16
16
|
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
|
18
|
+
A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
|
19
|
+
u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
|
20
|
+
75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
|
21
|
+
6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
|
22
|
+
iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
|
23
|
+
ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
|
24
|
+
74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
|
25
|
+
058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
|
26
|
+
HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
|
27
|
+
AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
|
28
|
+
YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
|
29
|
+
/3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
|
30
|
+
h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
|
31
|
+
6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
|
32
|
+
ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
|
33
|
+
1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
|
34
|
+
DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
|
35
|
+
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
|
+
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2018-
|
38
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: ffi
|
@@ -90,7 +90,7 @@ executables: []
|
|
90
90
|
extensions: []
|
91
91
|
extra_rdoc_files:
|
92
92
|
- CHANGES
|
93
|
-
- README
|
93
|
+
- README.md
|
94
94
|
- MANIFEST
|
95
95
|
- doc/top.txt
|
96
96
|
files:
|
@@ -112,12 +112,18 @@ files:
|
|
112
112
|
- CHANGES
|
113
113
|
- MANIFEST
|
114
114
|
- Rakefile
|
115
|
-
- README
|
115
|
+
- README.md
|
116
116
|
- sys-proctable.gemspec
|
117
117
|
homepage: http://github.com/djberg96/sys-proctable
|
118
118
|
licenses:
|
119
119
|
- Apache 2.0
|
120
|
-
metadata:
|
120
|
+
metadata:
|
121
|
+
homepage_uri: https://github.com/djberg96/sys-proctable
|
122
|
+
bug_tracker_uri: https://github.com/djberg96/sys-proctable/issues
|
123
|
+
changelog_uri: https://github.com/djberg96/sys-proctable/blob/master/CHANGES
|
124
|
+
documentation_uri: https://github.com/djberg96/sys-proctable/wiki
|
125
|
+
source_code_uri: https://github.com/djberg96/sys-proctable
|
126
|
+
wiki_uri: https://github.com/djberg96/sys-proctable/wiki
|
121
127
|
post_install_message:
|
122
128
|
rdoc_options: []
|
123
129
|
require_paths:
|
@@ -134,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
140
|
version: '0'
|
135
141
|
requirements: []
|
136
142
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.6
|
143
|
+
rubygems_version: 2.7.6
|
138
144
|
signing_key:
|
139
145
|
specification_version: 4
|
140
146
|
summary: An interface for providing process table information
|
metadata.gz.sig
CHANGED
Binary file
|
data/README
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
== Description
|
2
|
-
A Ruby interface for gathering process information.
|
3
|
-
|
4
|
-
== Prerequisites
|
5
|
-
* Test::Unit 2.x (development only)
|
6
|
-
|
7
|
-
== Supported Platforms
|
8
|
-
* Windows 2000 or later
|
9
|
-
* Linux 2.6+
|
10
|
-
* FreeBSD
|
11
|
-
* Solaris 8+
|
12
|
-
* HP-UX 10+
|
13
|
-
* OS X 10.7+
|
14
|
-
* AIX 5.3+
|
15
|
-
|
16
|
-
== Installation
|
17
|
-
gem install sys-proctable
|
18
|
-
|
19
|
-
You may need to specify a platform in some cases. For example:
|
20
|
-
|
21
|
-
gem install sys-proctable --platform mswin32 # Windows
|
22
|
-
gem install sys-proctable --platform sunos # Solaris
|
23
|
-
gem install sys-proctable --platform linux # Linux
|
24
|
-
gem install sys-proctable --platform freebsd # FreeBSD
|
25
|
-
gem install sys-proctable --platform darwin # OS X
|
26
|
-
|
27
|
-
== Synopsis
|
28
|
-
require 'sys/proctable'
|
29
|
-
include Sys
|
30
|
-
|
31
|
-
# Everything
|
32
|
-
ProcTable.ps{ |p|
|
33
|
-
puts p.pid.to_s
|
34
|
-
puts p.comm
|
35
|
-
# ...
|
36
|
-
}
|
37
|
-
|
38
|
-
# Just one process
|
39
|
-
s = ProcTable.ps(2123)
|
40
|
-
puts s.pid.to_s
|
41
|
-
puts s.comm
|
42
|
-
# ...
|
43
|
-
|
44
|
-
# Return the results as an array of ProcTableStructs
|
45
|
-
a = ProcTable.ps
|
46
|
-
a.each do |p|
|
47
|
-
puts p.pid
|
48
|
-
# ...
|
49
|
-
end
|
50
|
-
|
51
|
-
== Notes
|
52
|
-
Windows users may pass a host name as a second argument to get process
|
53
|
-
information from a different host. This relies on the WMI service running.
|
54
|
-
|
55
|
-
== Known Issues
|
56
|
-
=== FreeBSD
|
57
|
-
A kvm interface is used. That means the owner of the process using the
|
58
|
-
sys-proctable library needs to be a member of the kvm group (or root).
|
59
|
-
|
60
|
-
=== Bundler
|
61
|
-
Bundler seems to have trouble installing the proper gem because of the
|
62
|
-
platform specific gem names. To deal with that, run this command first:
|
63
|
-
|
64
|
-
bundle config specific_platform true
|
65
|
-
|
66
|
-
You can follow the issue at:
|
67
|
-
|
68
|
-
https://github.com/bundler/bundler/issues/5536
|
69
|
-
|
70
|
-
=== Solaris
|
71
|
-
The cmdline member on Solaris is limited to 80 characters unless you (or
|
72
|
-
your program) own the process. This is a Solaris design flaw/feature.
|
73
|
-
|
74
|
-
=== OS X
|
75
|
-
The libproc interface is used. That means you will only get list of
|
76
|
-
processes that you have access to. To get a full listing, run as root.
|
77
|
-
|
78
|
-
== Future Plans
|
79
|
-
Add support for NetBSD and OpenBSD.
|
80
|
-
Convert remaining C code (just HP-UX at this point) to FFI.
|
81
|
-
|
82
|
-
== Acknowledgements
|
83
|
-
This library was originally based on the Perl module Proc::ProcessTable
|
84
|
-
by Dan Urist. Many ideas, as well as large chunks of code, were taken
|
85
|
-
from his work. So, a big THANK YOU goes out to Dan Urist.
|
86
|
-
|
87
|
-
A big thanks also goes out to Mike Hall who was very helpful with ideas,
|
88
|
-
logic and testing.
|
89
|
-
|
90
|
-
Thanks also go to Sean Chittenden for providing an account on one of his
|
91
|
-
FreeBSD machines. This is how the FreeBSD support was (initially) added.
|
92
|
-
|
93
|
-
Thanks go to James Hranicky for providing a patch that grabs name, eid,
|
94
|
-
euid, gid and guid info in the Linux version, along with some general
|
95
|
-
debugging help.
|
96
|
-
|
97
|
-
Thanks go to David Felstead for the original OS X code. Thanks also go
|
98
|
-
to Matthias Zirnstein for adding the original cmdline support for OS X.
|
99
|
-
|
100
|
-
Finally I'd like to thank all the folks who have submitted bug reports
|
101
|
-
and/or patches.
|
102
|
-
|
103
|
-
== Help Wanted
|
104
|
-
I do not have access to all platforms. If your platform is not supported
|
105
|
-
then you will need to either submit a patch or give me a remote account
|
106
|
-
on a box with a compiler so that I can write the code.
|
107
|
-
|
108
|
-
== More documentation
|
109
|
-
See the documentation under the 'doc' directory for more information,
|
110
|
-
including platform specific notes and issues.
|
111
|
-
|
112
|
-
== License
|
113
|
-
Apache 2.0
|
114
|
-
|
115
|
-
== Copyright
|
116
|
-
(C) 2003-2016 Daniel J. Berger
|
117
|
-
All Rights Reserved.
|
118
|
-
|
119
|
-
== Author
|
120
|
-
Daniel J. Berger
|