sys-proctable 0.8.0-x86-linux
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.
- data/CHANGES +260 -0
- data/MANIFEST +38 -0
- data/README +137 -0
- data/doc/linux.txt +83 -0
- data/doc/top.txt +50 -0
- data/lib/sys/proctable.rb +237 -0
- data/lib/sys/top.rb +35 -0
- data/test/test_sys_proctable_all.rb +80 -0
- data/test/test_sys_proctable_linux.rb +288 -0
- metadata +74 -0
data/CHANGES
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
== 0.8.0 - 26-Jan-2009
|
2
|
+
* The Linux and Solaris versions of this library are now pure Ruby. Be warned,
|
3
|
+
however, that only Solaris 8 and later are now supported. This may change
|
4
|
+
in a future release if there's demand to support 2.6 and 2.7.
|
5
|
+
* Some Struct::ProcTableStruct members have changed. As a general rule they
|
6
|
+
now more closely match the C struct member name. See individual platforms
|
7
|
+
for more details.
|
8
|
+
* Bug fix for the cmd_args struct member on Solaris.
|
9
|
+
* Bug fixes for OS X. Added a VERSION constant, fixed struct name, and changed
|
10
|
+
pct_cpu to pctcpu.
|
11
|
+
* The .new method is now explicitly illegal.
|
12
|
+
* The Struct::ProcTableStruct instances are now frozen. This is read-only data.
|
13
|
+
* Added the peak_page_file_usage and status members on MS Windows. The status
|
14
|
+
member is always nil, but was added for completeness.
|
15
|
+
* Fixed the quota_peak_paged_pool_usage member on MS Windows.
|
16
|
+
* ProcTableError is now ProcTable::Error.
|
17
|
+
* Minor test case fix for kvm/bsd based versions.
|
18
|
+
* Added the 'time' library as a require for Windows (to parse MS date/time
|
19
|
+
format strings).
|
20
|
+
* The kvm (bsd.c) implementation now works for FreeBSD 7.
|
21
|
+
* Added many more tests.
|
22
|
+
* Added some benchmarking code in the 'benchmarks' directory.
|
23
|
+
* Added a 'bench' Rake task.
|
24
|
+
* Renamed the test_ps.rb file to example_ps.rb in order to avoid any possible
|
25
|
+
confusion with actual test files.
|
26
|
+
* Added an 'example' rake task to run the example file.
|
27
|
+
|
28
|
+
== 0.7.6 - 11-Jul-2007
|
29
|
+
* Fixed the starttime for Linux. Thanks go to Yaroslav Dmitriev for the spot.
|
30
|
+
* Fixed a bug in the MS Windows version within a private method that parsed
|
31
|
+
an MS specific date format. This was caused by a backwards incompatible
|
32
|
+
change in the Time.parse method in Ruby 1.8.6. See ruby-core: 11245 ff.
|
33
|
+
* Fixed the gemspec (I hope). Please let me know if you have problems.
|
34
|
+
* Added a Rakefile. Building, testing and installing should now be handled via
|
35
|
+
Rake tasks. The install.rb file has been removed - that code is now
|
36
|
+
integrated in the Rakefile.
|
37
|
+
* Minor directory layout changes and cleanup (mostly for the extconf.rb file).
|
38
|
+
* Side note - it seems that the code for OS X *does* work, at least on 10.4.10.
|
39
|
+
I can only conclude that previous reports about it failing were related to
|
40
|
+
bugs in OS X or were really just build issues. Apologies (and thanks, again)
|
41
|
+
to David Felstead for the code. However, see the README for more information
|
42
|
+
specific to OS X, as there are shortcomings.
|
43
|
+
|
44
|
+
== 0.7.5 - 23-Nov-2006
|
45
|
+
* Fixed int/long issues for Linux. Thanks go to Matt Lightner for the spot.
|
46
|
+
* Minor documentation fixes and changes to the extconf.rb file.
|
47
|
+
|
48
|
+
== 0.7.4 - 20-Nov-2006
|
49
|
+
* Added a patch that deals with the large file compilation issue on Solaris.
|
50
|
+
You no longer need to build Ruby with --disable-largefile, or build a
|
51
|
+
64 bit Ruby, in order for this package to work. Thanks go to Steven Jenkins
|
52
|
+
for the information that led to the patch.
|
53
|
+
* Added inline rdoc to the source code.
|
54
|
+
* Added a gemspec.
|
55
|
+
* Fixed some potential 64 bit issues (struct declarations).
|
56
|
+
* Added preliminary support for Darwin (OS X). The code was provided by
|
57
|
+
David Felstead, but does not appear to compile successfully. Help wanted.
|
58
|
+
|
59
|
+
== 0.7.3 - 27-Oct-2005
|
60
|
+
* Fix for 1.8.3 and later (rb_pid_t). This should have only affected
|
61
|
+
Solaris.
|
62
|
+
|
63
|
+
== 0.7.2 - 15-May-2005
|
64
|
+
* Bug fix for the FreeBSD version that reads from /proc.
|
65
|
+
* Eliminated the test bug on Linux (inexplicably caused by File.copy). The
|
66
|
+
test suite should now run without segfaulting.
|
67
|
+
* Include bsd.c in tarball (oops).
|
68
|
+
* Minor test updates for FreeBSD.
|
69
|
+
* The 'pct_cpu' member for the BSD/kvm version has been changed to 'pctcpu'
|
70
|
+
for consistency with other platforms.
|
71
|
+
|
72
|
+
== 0.7.1 - 8-May-2005
|
73
|
+
* Bug fixed for the cmdline info on Linux. Thanks go to Arash Abedinzadeh
|
74
|
+
for the spot.
|
75
|
+
* Added an example program.
|
76
|
+
* Minor setup fix for Win32 in tc_all.rb.
|
77
|
+
|
78
|
+
== 0.7.0 - 25-Apr-2005
|
79
|
+
* Scrapped the C implementation for Windows in favor of an OLE + WMI pure Ruby
|
80
|
+
approach. See documentation for details.
|
81
|
+
* Added an optional lkvm implementation for BSD users. This is automatically
|
82
|
+
used if the /proc filesystem isn't found.
|
83
|
+
* Added prusage info for the Solaris version.
|
84
|
+
* Added name, eid, euid, gid and guid information for Linux. Thanks go to
|
85
|
+
James Hranicky for the patch.
|
86
|
+
* Fixed some potential bugs in the Linux version. Thanks go to James
|
87
|
+
Hranicky for the spot.
|
88
|
+
* Added the 'sys/top' package.
|
89
|
+
* ProcTable.fields no longer supports a block form.
|
90
|
+
* The BTIME (boot time) information has been removed from the Linux version.
|
91
|
+
If you want that information, use sys-uptime instead.
|
92
|
+
* The .html and .rd files have been removed. You can generate html on your
|
93
|
+
own with rdoc if you like.
|
94
|
+
* Some code cleanup on the C side of the house.
|
95
|
+
* Most documents made rdoc friendly.
|
96
|
+
* Renamed 'install_pure_ruby.rb' to just 'install.rb'.
|
97
|
+
* Removed the 'INSTALL' file. Installation instructions are in the README.
|
98
|
+
* Some test suite cleanup and reorganization.
|
99
|
+
* Moved project to RubyForge.
|
100
|
+
|
101
|
+
== 0.6.4 - 31-Mar-2004
|
102
|
+
* Fixed a bug in the pure Ruby version for Win32. Thanks go to Mark Hudson
|
103
|
+
for the spot.
|
104
|
+
* Fixed a bug in the C implementation for Win32 where the cmdline and path
|
105
|
+
values were sometimes wrong for running processes. Thanks go to Park Heesob
|
106
|
+
for the fix.
|
107
|
+
* Updated the VERSION constant and removed the VERSION class method in the
|
108
|
+
pure Ruby version for Win32.
|
109
|
+
* Updated install_pure_ruby.rb and test.rb scripts.
|
110
|
+
* Updated warranty information.
|
111
|
+
* The extconf.rb script has been revamped. See the INSTALL and README files
|
112
|
+
for important changes since the last release.
|
113
|
+
* The start ProcInfo struct member on Solaris, HP-UX and FreeBSD is now a
|
114
|
+
Time object, not a Fixnum/Bignum.
|
115
|
+
* Modified linux.c yet again to make gcc happy when it comes to multi-line
|
116
|
+
string literals.
|
117
|
+
* Minor change to way process state is handled on HP-UX.
|
118
|
+
* Documentation additions and updates, including warranty information.
|
119
|
+
|
120
|
+
== 0.6.3 - 24-Feb-2004
|
121
|
+
* Fixed a bug in the Solaris version where the cmd_args array did not
|
122
|
+
necessarily contain data on 2.7 and later. The current patch still
|
123
|
+
does not quite fix the problem for 2.6 and earlier but can be easily
|
124
|
+
derived manually by parsing the cmdline string.
|
125
|
+
|
126
|
+
== 0.6.2 - 20-Jan-2004
|
127
|
+
* Fixed a small memory leak in the solaris version.
|
128
|
+
|
129
|
+
== 0.6.1 - 31-Dec-2003
|
130
|
+
* Fixed a minor bug in the cmdline field on Linux where a blank character
|
131
|
+
was being appended to the end of the field.
|
132
|
+
* Fixed a minor annoyance where the windows.rb file was being copied into
|
133
|
+
the Ruby lib directory on install.
|
134
|
+
* Added a test_memleak.rb file. Currently only supported on Linux and
|
135
|
+
only does a file descriptor count check. I plan to expand this to
|
136
|
+
other platforms in the future.
|
137
|
+
* Minor test suite changes
|
138
|
+
* MANIFEST correction and update.
|
139
|
+
|
140
|
+
== 0.6.0 - 22-Oct-2003
|
141
|
+
* Significant API change (and thus, a version jump) - only a
|
142
|
+
single argument is now accepted to the ps() method, and only a PID
|
143
|
+
(Fixnum) is regarded as a valid argument.
|
144
|
+
* Calling ps() with a pid returns a single ProcTable struct (or nil
|
145
|
+
if the pid is not found), instead of a one element array.
|
146
|
+
* Argument to ps() now works properly on HP-UX and Win32.
|
147
|
+
* Removed the '#include <sys/types32.h>' in sunos.h. It wasn't needed
|
148
|
+
and you're not supposed to include it directly.
|
149
|
+
* Fixed 2.6 compatibility issue with regards to cmdline on Solaris.
|
150
|
+
* Removed the ProcStatException completely on Linux. There was no reason
|
151
|
+
to fail on a directory read for /proc/xxx/stat. If the read fails
|
152
|
+
(meaning the process died in the middle of collecting info for it), it
|
153
|
+
is simply ignored.
|
154
|
+
* The ttynum bug on HPUX has been fixed. In addition, the return value for
|
155
|
+
this field is now a string rather than an int and the field name has
|
156
|
+
been changed to "ttydev".
|
157
|
+
* The ttynum field has been changed to ttydev on Solaris and HPUX. On
|
158
|
+
Solaris, the ttydev is now reported as -1 if there is no associated tty.
|
159
|
+
In a future release, Solaris and the other *nix platforms will be changed
|
160
|
+
so that ttydev is always a device name (i.e String).
|
161
|
+
* Added plain text documentation for all platforms.
|
162
|
+
* Some test suite cleanup.
|
163
|
+
* Changed .rd2 extension to just '.rd'.
|
164
|
+
|
165
|
+
== 0.5.2 - 18-Jul-2003
|
166
|
+
* Modified cmdline to extend past the traditional 80 character limit on
|
167
|
+
Solaris, where possible (Solaris 2.6+ only).
|
168
|
+
* Added the cmdline_args and num_args fields on Solaris, which returns
|
169
|
+
an array of cmdline arguments and the number of cmdline arguments,
|
170
|
+
respectively.
|
171
|
+
* Minor modification to fields() method, in addition to warning cleanup
|
172
|
+
for Solaris.
|
173
|
+
* Changed "defunct" state string to "zombie" for Solaris.
|
174
|
+
* Should cleanly compile with -Wall -W now (gcc) on Solaris.
|
175
|
+
* Added solaris.txt to doc directory.
|
176
|
+
* MANIFEST corrections.
|
177
|
+
|
178
|
+
== 0.5.1 - 16-Jul-2003
|
179
|
+
* Fixed a nasty file descriptor bug in the Linux code, where file descriptors
|
180
|
+
were continuously being used up.
|
181
|
+
* Added the BTIME (boot time) constant for Linux.
|
182
|
+
* Fixed up the test/test.rb file a bit.
|
183
|
+
* Added BTIME tests to tc_linux.rb.
|
184
|
+
|
185
|
+
== 0.5.0 - 11-Jul-200
|
186
|
+
* Added HP-UX support!
|
187
|
+
* Note that passing PID's or strings as arguments to ps() is not supported
|
188
|
+
in the HP-UX version. This functionality will be stripped out of the
|
189
|
+
other versions in a future release. See the README file for more details.
|
190
|
+
* Removed the VERSION() class method. Use the constant instead.
|
191
|
+
* Separated the rd docs from their respective source files. Now in the doc
|
192
|
+
directory.
|
193
|
+
* Got rid of the interactive html generation in extconf.rb.
|
194
|
+
* Changed License to Artistic.
|
195
|
+
|
196
|
+
== 0.4.3 - 30-May-2003
|
197
|
+
* Added a version.h file to store the version number. Modified all of the
|
198
|
+
C source files to use that instead of hard coding the version everywhere.
|
199
|
+
* Added a generic test.rb script for those without TestUnit installed, or
|
200
|
+
just futzing in general. Modified the extconf.rb script to copy this
|
201
|
+
instead of writing an inline HERE document.
|
202
|
+
* Modified extconf.rb so that it builds with mingw or cygwin. Thanks go to
|
203
|
+
Peter Fischer for the spot and patch.
|
204
|
+
* Modified test suite to work with TestUnit 0.1.6 or 0.1.8.
|
205
|
+
|
206
|
+
== 0.4.2 - 14-Apr-2003
|
207
|
+
* Added pure Ruby version for Win32 - thanks Park Heesob.
|
208
|
+
* Modified extconf.rb file to handle pure Ruby versions.
|
209
|
+
* Added install_pure_ruby.rb file, an alternate installation
|
210
|
+
script for pure Ruby versions.
|
211
|
+
|
212
|
+
== 0.4.1 - 31-Mar-2003
|
213
|
+
* Added support for Solaris 2.5.x.
|
214
|
+
* All exceptions are now a direct subclass of StandardError.
|
215
|
+
* Value returned for wchan now more meaningful (2.5.x only for now).
|
216
|
+
* Fixed the start, utime and ctime for FreeBSD.
|
217
|
+
* Minor fix to FreeBSD test suite.
|
218
|
+
* Some changes to extconf.rb.
|
219
|
+
* Minor doc changes.
|
220
|
+
* Added License and Copyright info.
|
221
|
+
|
222
|
+
== 0.4.0 - 10-Mar-2003
|
223
|
+
* Added MS Windows support (non-cygwin).
|
224
|
+
* Added environment information for Linux version.
|
225
|
+
* Added real exceptions (type depends on platform).
|
226
|
+
* Added a test suite (for those with testunit installed).
|
227
|
+
* Removed the sys-uname requirement.
|
228
|
+
* Heavily modified the extconf.rb script.
|
229
|
+
* Changed "Changelog" to "CHANGES" and "Manifest" to "MANIFEST".
|
230
|
+
* Added a VERSION constant and class method.
|
231
|
+
* Minor internal directory layout change (put 'os' under 'lib').
|
232
|
+
* Changed package name to lower case.
|
233
|
+
* Doc changes, including license information.
|
234
|
+
|
235
|
+
== 0.3.1 - 16-Aug-2002
|
236
|
+
* Added a "comm" field to the sunos version. I am going to try to make this a
|
237
|
+
common field for all platforms to help reduce RUBY_PLATFORM checking.
|
238
|
+
* Fixed the release date for 0.3.0 (was accidentally marked *July*).
|
239
|
+
* Added an INSTALL file.
|
240
|
+
* Minor documentation change to the sunos.c source file.
|
241
|
+
|
242
|
+
== 0.3.0 - 11-Aug-2002
|
243
|
+
* Added FreeBSD support!
|
244
|
+
* Struct name changed to just "ProcTableStruct" to be compliant with future
|
245
|
+
versions of Ruby.
|
246
|
+
* The ps() function now returns an array of ProcTableStruct's in lvalue context.
|
247
|
+
* Fixed the ability to search by process name in Linux.
|
248
|
+
* Modified Linux "comm" field to strip parenthesis.
|
249
|
+
* Some doc changes/additions.
|
250
|
+
* Added Sean Chittenden to the "Acknowledgements" section. Sean provided me
|
251
|
+
with access to a FreeBSD box, which is how I was able to provide FreeBSD
|
252
|
+
support. Thanks Sean!
|
253
|
+
|
254
|
+
== 0.2.0 - 19-Jul-2002
|
255
|
+
* Added the ability to search by process name.
|
256
|
+
* test.rb modified to be cross-platform.
|
257
|
+
* Solaris - fixed bug with fname (was accidentally called "name").
|
258
|
+
|
259
|
+
== 0.1.0 - 2-Jul-2002
|
260
|
+
- Initial release.
|
data/MANIFEST
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
CHANGES
|
2
|
+
INSTALL
|
3
|
+
MANIFEST
|
4
|
+
Rakefile
|
5
|
+
sys-proctable.gemspec
|
6
|
+
|
7
|
+
doc/freebsd.txt
|
8
|
+
doc/hpux.txt
|
9
|
+
doc/linux.txt
|
10
|
+
doc/solaris.txt
|
11
|
+
doc/top.txt
|
12
|
+
doc/windows.txt
|
13
|
+
|
14
|
+
example/example_ps.rb
|
15
|
+
|
16
|
+
ext/extconf.rb
|
17
|
+
ext/bsd/bsd.c
|
18
|
+
ext/darwin/darwin.c
|
19
|
+
ext/freebsd/freebsd.c
|
20
|
+
ext/freebsd/freebsd.h
|
21
|
+
ext/hpux/hpux.c
|
22
|
+
ext/hpux/hpux.h
|
23
|
+
ext/version.h
|
24
|
+
|
25
|
+
lib/sys/top.rb
|
26
|
+
lib/sys/linux.rb
|
27
|
+
lib/sys/sunos.rb
|
28
|
+
lib/sys/windows.rb
|
29
|
+
|
30
|
+
test/test_sys_proctable_all.rb
|
31
|
+
test/test_sys_proctable_darwin.rb
|
32
|
+
test/test_sys_proctable_freebsd.rb
|
33
|
+
test/test_sys_proctable_hpux.rb
|
34
|
+
test/test_sys_proctable_kvm.rb
|
35
|
+
test/test_sys_proctable_linux.rb
|
36
|
+
test/test_sys_proctable_sunos.rb
|
37
|
+
test/test_sys_proctable_windows.rb
|
38
|
+
test/test_sys_top.rb
|
data/README
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
= Description
|
2
|
+
A Ruby interface for gathering process information.
|
3
|
+
|
4
|
+
= Prerequisites
|
5
|
+
* Ruby 1.8.2 or later
|
6
|
+
* Test::Unit 2.x
|
7
|
+
|
8
|
+
= Supported Platforms
|
9
|
+
* Windows NT family (NT, 2000, XP, etc)
|
10
|
+
* Linux
|
11
|
+
* FreeBSD
|
12
|
+
* Solaris 2.8+
|
13
|
+
* HP-UX
|
14
|
+
* OS X
|
15
|
+
|
16
|
+
= Installation
|
17
|
+
* rake test (optional)
|
18
|
+
* rake install
|
19
|
+
|
20
|
+
= Synopsis
|
21
|
+
require 'sys/proctable'
|
22
|
+
include Sys
|
23
|
+
|
24
|
+
# Everything
|
25
|
+
ProcTable.ps{ |p|
|
26
|
+
puts p.pid.to_s
|
27
|
+
puts p.comm
|
28
|
+
...
|
29
|
+
}
|
30
|
+
|
31
|
+
or
|
32
|
+
|
33
|
+
# Just one process
|
34
|
+
s = ProcTable.ps(2123)
|
35
|
+
puts s.pid.to_s
|
36
|
+
puts s.comm
|
37
|
+
...
|
38
|
+
|
39
|
+
# Return the results as an array of ProcTableStructs
|
40
|
+
a = ProcTable.ps
|
41
|
+
a.each do |p|
|
42
|
+
puts a.pid
|
43
|
+
...
|
44
|
+
end
|
45
|
+
|
46
|
+
= Notes
|
47
|
+
Windows users may pass a host name as a second argument to get process
|
48
|
+
information from a different host. This relies on the WMI service running.
|
49
|
+
|
50
|
+
If you're building C source code, the ts_all.rb file is autogenerated for
|
51
|
+
you.
|
52
|
+
|
53
|
+
= Known Issues
|
54
|
+
=== FreeBSD
|
55
|
+
If you're building on FreeBSD, a standard /proc filesystem read approach is
|
56
|
+
used if mounted. Otherwise, a kvm interface is used. There are more fields
|
57
|
+
available with the kvm interface, but keep in mind that you need to be a
|
58
|
+
member of the kvm group (or root) to use this. You can tweak the extconf.rb
|
59
|
+
file manually if you want to force the issue.
|
60
|
+
|
61
|
+
=== OpenBSD, NetBSD
|
62
|
+
This library will attempt to use the kvm interface. It is untested,
|
63
|
+
however.
|
64
|
+
|
65
|
+
=== Solaris
|
66
|
+
The cmdline member on Solaris is limited to 80 characters unless you (or
|
67
|
+
your program) own the process. This is a Solaris design flaw/feature.
|
68
|
+
|
69
|
+
=== OS X
|
70
|
+
At the moment you do not get the full command line string. The code required
|
71
|
+
to get this information is obnoxious and I don't have any compelling desire
|
72
|
+
to add it. However, if you're willing to submit a patch I'll accept it.
|
73
|
+
|
74
|
+
You can find a good starting point with the OS X code found in Dan Urist's
|
75
|
+
Proc::ProcessTable module. You can find that module on CPAN. Point your
|
76
|
+
browser at http://search.cpan.org.
|
77
|
+
|
78
|
+
=== Misc
|
79
|
+
If you build your library as a C extension (which is what will happen if
|
80
|
+
you run the 'build', 'test', or 'install' Rake tasks), then the .rb files
|
81
|
+
file under 'lib/sys/' are renamed to '.orig', except top.rb. This is
|
82
|
+
necessary to prevent mkmf from installing them during a 'make install'.
|
83
|
+
|
84
|
+
The 'clean' Rake task will rename them back to '.rb'.
|
85
|
+
|
86
|
+
=== Thread Safety
|
87
|
+
I am not currently using a thread-safe version of readdir(). I am not
|
88
|
+
especially concerned about it either. If you are trying to read information
|
89
|
+
out of /proc from different threads at the same time there is something
|
90
|
+
seriously wrong with your code logic. Using readdir_r() still won't solve
|
91
|
+
all potential thread safety issues anyway.
|
92
|
+
|
93
|
+
= Future Plans
|
94
|
+
Research has indicated that the kvm approach is less favored than a sysctl
|
95
|
+
approach on BSD variants. I will try to add this interface in a future
|
96
|
+
release.
|
97
|
+
|
98
|
+
= Acknowledgements
|
99
|
+
This library is largely based on the Perl module Proc::ProcessTable by
|
100
|
+
Dan Urist. Many ideas, as well as large chunks of code, were taken
|
101
|
+
from his work. So, a big THANK YOU goes out to Dan Urist.
|
102
|
+
|
103
|
+
A big thanks also goes out to Mike Hall who was very helpful with ideas,
|
104
|
+
logic and testing.
|
105
|
+
|
106
|
+
Thanks also go to Sean Chittenden for providing an account on one of his
|
107
|
+
FreeBSD machines. This is how the FreeBSD support was (initially) added.
|
108
|
+
|
109
|
+
Thanks go to James Hranicky for providing a patch that grabs name, eid,
|
110
|
+
euid, gid and guid info in the Linux version, along with some general
|
111
|
+
debugging help.
|
112
|
+
|
113
|
+
Finally I'd like to thank all the folks who have submitted bug reports
|
114
|
+
and/or patches.
|
115
|
+
|
116
|
+
= Help Wanted
|
117
|
+
I do not have access to all platforms. There are a few other major platforms
|
118
|
+
out there, namely AIX, OpenBSD, and IRIX, among others, that I would
|
119
|
+
like to see ports for. There are two ways you can help - either submit code
|
120
|
+
for your particular platform or give me an account on your platform so I can
|
121
|
+
develop on it.
|
122
|
+
|
123
|
+
= More documentation
|
124
|
+
See the documentation under the 'doc' directory for more information,
|
125
|
+
including platform specific notes and issues.
|
126
|
+
|
127
|
+
= License
|
128
|
+
Ruby's
|
129
|
+
|
130
|
+
= Copyright
|
131
|
+
(C) 2003-2009 Daniel J. Berger
|
132
|
+
All Rights Reserved.
|
133
|
+
|
134
|
+
= Author
|
135
|
+
Daniel J. Berger
|
136
|
+
djberg96 at nospam at gmail dot com
|
137
|
+
imperator on IRC (Freenode)
|
data/doc/linux.txt
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
= Description
|
2
|
+
A Ruby interface for gathering process table information. This is a pure
|
3
|
+
Ruby implementation that reads data out of your /proc filesystem.
|
4
|
+
|
5
|
+
= Synopsis
|
6
|
+
require 'sys/proctable'
|
7
|
+
include Sys
|
8
|
+
|
9
|
+
# Everything
|
10
|
+
ProcTable.ps{ |p|
|
11
|
+
puts p.pid.to_s
|
12
|
+
puts p.comm
|
13
|
+
...
|
14
|
+
}
|
15
|
+
|
16
|
+
or
|
17
|
+
|
18
|
+
# Just one process
|
19
|
+
p = ProcTable.ps(2123)
|
20
|
+
puts p.pid.to_s
|
21
|
+
puts p.comm
|
22
|
+
...
|
23
|
+
|
24
|
+
or
|
25
|
+
|
26
|
+
# Return the results as an array of ProcTableStructs
|
27
|
+
a = ProcTable.ps()
|
28
|
+
a.each do |p|
|
29
|
+
puts a.pid
|
30
|
+
...
|
31
|
+
end
|
32
|
+
|
33
|
+
= Constants
|
34
|
+
VERSION
|
35
|
+
Returns the current version number for this package (as a string).
|
36
|
+
|
37
|
+
= Class Methods
|
38
|
+
ProcTable.fields
|
39
|
+
Returns an array of fields available on the current OS.
|
40
|
+
|
41
|
+
ProcTable.ps(pid=nil)
|
42
|
+
ProcTable.ps{ |s| ... }
|
43
|
+
If no pid's or processes are included as arguments, in block form it
|
44
|
+
returns a struct of type ProcTableStruct for every process in the proc
|
45
|
+
table. Otherwise it returns an array of ProcTableStruct's.
|
46
|
+
|
47
|
+
If a process id is provided, a single ProcTable struct is returned, or
|
48
|
+
nil if the pid is not found.
|
49
|
+
|
50
|
+
= Exception Classes
|
51
|
+
ProcTable::Error < StandardError
|
52
|
+
Raised if the /proc field is unreadable and/or unmounted.
|
53
|
+
|
54
|
+
= Supported fields
|
55
|
+
You can view the supported fields with the "fields()" class method.
|
56
|
+
|
57
|
+
= Future Plans
|
58
|
+
None at this time. Please post any feature requests on the project page
|
59
|
+
at http://www.rubyforge.org/projects/sysutils.
|
60
|
+
|
61
|
+
= Known Bugs
|
62
|
+
None known. Please log any bugs on the project page at
|
63
|
+
http://www.rubyforge.org/projects/sysutils
|
64
|
+
|
65
|
+
= License
|
66
|
+
Ruby's
|
67
|
+
|
68
|
+
= Copyright
|
69
|
+
(C) 2003-2009 Daniel J. Berger
|
70
|
+
All Rights Reserved
|
71
|
+
|
72
|
+
= Warranty
|
73
|
+
This package is provided "as is" and without any express or
|
74
|
+
implied warranties, including, without limitation, the implied
|
75
|
+
warranties of merchantability and fitness for a particular purpose.
|
76
|
+
|
77
|
+
= Author
|
78
|
+
Daniel J. Berger
|
79
|
+
djberg96 at nospam at gmail dot com
|
80
|
+
imperator on IRC (Freenode)
|
81
|
+
|
82
|
+
= See Also
|
83
|
+
ps, proc(5)
|
data/doc/top.txt
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= Description
|
2
|
+
A simple 'top' interface for Ruby
|
3
|
+
|
4
|
+
= Prerequisites
|
5
|
+
Requires the "sys/proctable" package (which should be installed along
|
6
|
+
with this package).
|
7
|
+
|
8
|
+
= Synopsis
|
9
|
+
require "sys/top"
|
10
|
+
include Sys
|
11
|
+
|
12
|
+
Top.top(5).each{ |ps|
|
13
|
+
p ps
|
14
|
+
}
|
15
|
+
|
16
|
+
= Constants
|
17
|
+
VERSION
|
18
|
+
Returns the version number of this package as a String.
|
19
|
+
|
20
|
+
= Class Methods
|
21
|
+
Top.top(number=10, field="pctcpu")
|
22
|
+
Returns an array of ProcTableStruct's. The size of the array (i.e. the
|
23
|
+
number of processes) that it returns is based on +number+, and sorted by
|
24
|
+
+pctcpu+. By default, the size and field values are 10 and "pctcpu",
|
25
|
+
respectively.
|
26
|
+
|
27
|
+
= Notes
|
28
|
+
Not all fields are available on all platforms. Please check your
|
29
|
+
platform specific documentation for which fields are available.
|
30
|
+
|
31
|
+
= Bugs
|
32
|
+
None that I'm aware of. Please log bug reports on the project page at
|
33
|
+
http://www.rubyforge.org/projects/sysutils
|
34
|
+
|
35
|
+
= License
|
36
|
+
Ruby's
|
37
|
+
|
38
|
+
= Copyright
|
39
|
+
(C) 2004-2009 Daniel J. Berger
|
40
|
+
All Rights Reserved.
|
41
|
+
|
42
|
+
= Warranty
|
43
|
+
This package is provided "as is" and without any express or
|
44
|
+
implied warranties, including, without limitation, the implied
|
45
|
+
warranties of merchantability and fitness for a particular purpose.
|
46
|
+
|
47
|
+
= Author
|
48
|
+
Daniel J. Berger
|
49
|
+
djberg96 at nospam at gmail dot com
|
50
|
+
imperator on IRC (Freenode)
|
@@ -0,0 +1,237 @@
|
|
1
|
+
# The Sys module serves as a namespace only.
|
2
|
+
module Sys
|
3
|
+
|
4
|
+
# The ProcTable class encapsulates process table information.
|
5
|
+
class ProcTable
|
6
|
+
|
7
|
+
# There is no constructor
|
8
|
+
private_class_method :new
|
9
|
+
|
10
|
+
# The version of the sys-proctable library
|
11
|
+
VERSION = '0.8.0'
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
@fields = [
|
16
|
+
'cmdline', # Complete command line
|
17
|
+
'cwd', # Current working directory
|
18
|
+
'environ', # Environment
|
19
|
+
'exe', # Actual pathname of the executed command
|
20
|
+
'fd', # File descriptors open by process
|
21
|
+
'root', # Root directory of process
|
22
|
+
'pid', # Process ID
|
23
|
+
'comm', # Filename of executable
|
24
|
+
'state', # Single character state abbreviation
|
25
|
+
'ppid', # Parent process ID
|
26
|
+
'pgrp', # Process group
|
27
|
+
'session', # Session ID
|
28
|
+
'tty_nr', # TTY (terminal) associated with the process
|
29
|
+
'tpgid', # Group ID of the TTY
|
30
|
+
'flags', # Kernel flags
|
31
|
+
'minflt', # Number of minor faults
|
32
|
+
'cminflt', # Number of minor faults of waited-for children
|
33
|
+
'majflt', # Number of major faults
|
34
|
+
'cmajflt', # Number of major faults of waited-for children
|
35
|
+
'utime', # Number of user mode jiffies
|
36
|
+
'stime', # Number of kernel mode jiffies
|
37
|
+
'cutime', # Number of children's user mode jiffies
|
38
|
+
'cstime', # Number of children's kernel mode jiffies
|
39
|
+
'priority', # Nice value plus 15
|
40
|
+
'nice', # Nice value
|
41
|
+
'itrealvalue', # Time in jiffies before next SIGALRM
|
42
|
+
'starttime', # Time in jiffies since system boot
|
43
|
+
'vsize', # Virtual memory size in bytes
|
44
|
+
'rss', # Resident set size
|
45
|
+
'rlim', # Current limit on the rss in bytes
|
46
|
+
'startcode', # Address above which program text can run
|
47
|
+
'endcode', # Address below which program text can run
|
48
|
+
'startstack', # Address of the startstack
|
49
|
+
'kstkesp', # Kernel stack page address
|
50
|
+
'kstkeip', # Kernel instruction pointer
|
51
|
+
'signal', # Bitmap of pending signals
|
52
|
+
'blocked', # Bitmap of blocked signals
|
53
|
+
'sigignore', # Bitmap of ignored signals
|
54
|
+
'sigcatch', # Bitmap of caught signals
|
55
|
+
'wchan', # Channel in which the process is waiting
|
56
|
+
'nswap', # Number of pages swapped
|
57
|
+
'cnswap', # Cumulative nswap for child processes
|
58
|
+
'exit_signal', # Signal to be sent to parent when process dies
|
59
|
+
'processor', # CPU number last executed on
|
60
|
+
'rt_priority', # Real time scheduling priority
|
61
|
+
'policy', # Scheduling policy
|
62
|
+
'name', # Process name
|
63
|
+
'uid', # Real user ID
|
64
|
+
'euid', # Effective user ID
|
65
|
+
'gid', # Real group ID
|
66
|
+
'egid' # Effective group ID
|
67
|
+
]
|
68
|
+
|
69
|
+
public
|
70
|
+
|
71
|
+
ProcTableStruct = Struct.new('ProcTableStruct', *@fields)
|
72
|
+
|
73
|
+
# In block form, yields a ProcTableStruct for each process entry that you
|
74
|
+
# have rights to. This method returns an array of ProcTableStruct's in
|
75
|
+
# non-block form.
|
76
|
+
#
|
77
|
+
# If a +pid+ is provided, then only a single ProcTableStruct is yielded or
|
78
|
+
# returned, or nil if no process information is found for that +pid+.
|
79
|
+
#
|
80
|
+
# Example:
|
81
|
+
#
|
82
|
+
# # Iterate over all processes
|
83
|
+
# ProcTable.ps do |proc_info|
|
84
|
+
# p proc_info
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# # Print process table information for only pid 1001
|
88
|
+
# p ProcTable.ps(1001)
|
89
|
+
#
|
90
|
+
def self.ps(pid=nil)
|
91
|
+
array = block_given? ? nil : []
|
92
|
+
struct = nil
|
93
|
+
|
94
|
+
raise TypeError unless pid.is_a?(Fixnum) if pid
|
95
|
+
|
96
|
+
Dir.foreach("/proc"){ |file|
|
97
|
+
next if file =~ /\D/ # Skip non-numeric directories
|
98
|
+
next unless file.to_i == pid if pid
|
99
|
+
|
100
|
+
struct = ProcTableStruct.new
|
101
|
+
|
102
|
+
# Get /proc/<pid>/cmdline information
|
103
|
+
struct.cmdline = IO.read("/proc/#{file}/cmdline")
|
104
|
+
|
105
|
+
# Get /proc/<pid>/cwd information
|
106
|
+
struct.cwd = File.readlink("/proc/#{file}/cwd") rescue nil
|
107
|
+
|
108
|
+
# Get /proc/<pid>/environ information. Environment information
|
109
|
+
# is represented as a Hash, with the environment variable as the
|
110
|
+
# key and its value as the hash value.
|
111
|
+
struct.environ = {}
|
112
|
+
|
113
|
+
begin
|
114
|
+
IO.read("/proc/#{file}/environ").split("\0").each{ |str|
|
115
|
+
key, value = str.split('=')
|
116
|
+
struct.environ[key] = value
|
117
|
+
}
|
118
|
+
rescue Errno::EACCES
|
119
|
+
# Ignore and move on.
|
120
|
+
end
|
121
|
+
|
122
|
+
# Get /proc/<pid>/exe information
|
123
|
+
struct.exe = File.readlink("/proc/#{file}/exe") rescue nil
|
124
|
+
|
125
|
+
# Get /proc/<pid>/fd information. File descriptor information
|
126
|
+
# is represented as a Hash, with the fd as the key, and its
|
127
|
+
# symlink as the value.
|
128
|
+
struct.fd = {}
|
129
|
+
|
130
|
+
begin
|
131
|
+
Dir["/proc/#{file}/fd/*"].each do |fd|
|
132
|
+
struct.fd[File.basename(fd)] = File.readlink(fd) rescue nil
|
133
|
+
end
|
134
|
+
rescue
|
135
|
+
# Ignore and move on
|
136
|
+
end
|
137
|
+
|
138
|
+
# Get /proc/<pid>/root information
|
139
|
+
struct.root = File.readlink("/proc/#{file}/root") rescue nil
|
140
|
+
|
141
|
+
# Get /proc/<pid>/stat information
|
142
|
+
stat = IO.read("/proc/#{file}/stat")
|
143
|
+
|
144
|
+
# Deal with spaces in comm name. Courtesy of Ara Howard.
|
145
|
+
re = %r/\([^\)]+\)/
|
146
|
+
comm = stat[re]
|
147
|
+
comm.tr!(' ', '-')
|
148
|
+
stat[re] = comm
|
149
|
+
|
150
|
+
stat = stat.split
|
151
|
+
|
152
|
+
struct.pid = stat[0].to_i
|
153
|
+
struct.comm = stat[1].tr('()','') # Remove parens
|
154
|
+
struct.state = stat[2]
|
155
|
+
struct.ppid = stat[3].to_i
|
156
|
+
struct.pgrp = stat[4].to_i
|
157
|
+
struct.session = stat[5].to_i
|
158
|
+
struct.tty_nr = stat[6].to_i
|
159
|
+
struct.tpgid = stat[7].to_i
|
160
|
+
struct.flags = stat[8].to_i
|
161
|
+
struct.minflt = stat[9].to_i
|
162
|
+
struct.cminflt = stat[10].to_i
|
163
|
+
struct.majflt = stat[11].to_i
|
164
|
+
struct.cmajflt = stat[12].to_i
|
165
|
+
struct.utime = stat[13].to_i
|
166
|
+
struct.stime = stat[14].to_i
|
167
|
+
struct.cutime = stat[15].to_i
|
168
|
+
struct.cstime = stat[16].to_i
|
169
|
+
struct.priority = stat[17].to_i
|
170
|
+
struct.nice = stat[18].to_i
|
171
|
+
# Skip 19
|
172
|
+
struct.itrealvalue = stat[20].to_i
|
173
|
+
struct.starttime = stat[21].to_i
|
174
|
+
struct.vsize = stat[22].to_i
|
175
|
+
struct.rss = stat[23].to_i
|
176
|
+
struct.rlim = stat[24].to_i
|
177
|
+
struct.startcode = stat[25].to_i
|
178
|
+
struct.endcode = stat[26].to_i
|
179
|
+
struct.startstack = stat[27].to_i
|
180
|
+
struct.kstkesp = stat[28].to_i
|
181
|
+
struct.kstkeip = stat[29].to_i
|
182
|
+
struct.signal = stat[30].to_i
|
183
|
+
struct.blocked = stat[31].to_i
|
184
|
+
struct.sigignore = stat[32].to_i
|
185
|
+
struct.sigcatch = stat[33].to_i
|
186
|
+
struct.wchan = stat[34].to_i
|
187
|
+
struct.nswap = stat[35].to_i
|
188
|
+
struct.cnswap = stat[36].to_i
|
189
|
+
struct.exit_signal = stat[37].to_i
|
190
|
+
struct.processor = stat[38].to_i
|
191
|
+
struct.rt_priority = stat[39].to_i
|
192
|
+
struct.policy = stat[40].to_i
|
193
|
+
|
194
|
+
# Get /proc/<pid>/status information (name, uid, euid, gid, egid)
|
195
|
+
IO.foreach("/proc/#{file}/status") do |line|
|
196
|
+
case line
|
197
|
+
when /Name:\s*?(\w+)/
|
198
|
+
struct.name = $1
|
199
|
+
when /Uid:\s*?(\d+)\s*?(\d+)/
|
200
|
+
struct.uid = $1.to_i
|
201
|
+
struct.euid = $2.to_i
|
202
|
+
when /Gid:\s*?(\d+)\s*?(\d+)/
|
203
|
+
struct.gid = $1.to_i
|
204
|
+
struct.egid = $2.to_i
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# If cmdline is empty use comm instead
|
209
|
+
struct.cmdline = struct.comm if struct.cmdline.empty?
|
210
|
+
|
211
|
+
struct.freeze # This is read-only data
|
212
|
+
|
213
|
+
if block_given?
|
214
|
+
yield struct
|
215
|
+
else
|
216
|
+
array << struct
|
217
|
+
end
|
218
|
+
}
|
219
|
+
|
220
|
+
pid ? struct : array
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns an array of fields that each ProcTableStruct will contain. This
|
224
|
+
# may be useful if you want to know in advance what fields are available
|
225
|
+
# without having to perform at least one read of the /proc table.
|
226
|
+
#
|
227
|
+
# Example:
|
228
|
+
#
|
229
|
+
# Sys::ProcTable.fields.each{ |field|
|
230
|
+
# puts "Field: #{field}"
|
231
|
+
# }
|
232
|
+
#
|
233
|
+
def self.fields
|
234
|
+
@fields
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
data/lib/sys/top.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'sys/proctable'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
# The Sys module serves as a namespace only
|
5
|
+
module Sys
|
6
|
+
|
7
|
+
# The Top class serves as a toplevel name for the 'top' method.
|
8
|
+
class Top
|
9
|
+
|
10
|
+
# The version of the sys-top library
|
11
|
+
VERSION = '1.0.2'
|
12
|
+
|
13
|
+
# Returns an array of Struct::ProcTableStruct elements containing up
|
14
|
+
# to +num+ elements, sorted by +field+. The default number of elements
|
15
|
+
# is 10, while the default field is 'pctcpu'.
|
16
|
+
#
|
17
|
+
# Exception: the default sort field is 'pid' on Linux and Windows.
|
18
|
+
#
|
19
|
+
def self.top(num=10, field='pctcpu')
|
20
|
+
field = field.to_s if field.is_a?(Symbol)
|
21
|
+
|
22
|
+
# Sort by pid on Windows by default
|
23
|
+
if Config::CONFIG['host_os'].match('mswin') && field == 'pctcpu'
|
24
|
+
field = 'pid'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Linux does not have a pctcpu field yet
|
28
|
+
if Config::CONFIG['host_os'].match('linux') && field == 'pctcpu'
|
29
|
+
field = 'pid'
|
30
|
+
end
|
31
|
+
|
32
|
+
Sys::ProcTable.ps.sort_by{ |obj| obj.send(field) || '' }[0..num-1]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# test_sys_proctable_all.rb
|
3
|
+
#
|
4
|
+
# Test suite for methods common to all platforms. Generally speaking
|
5
|
+
# you should run this test case using the 'rake test' task.
|
6
|
+
#######################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'test-unit'
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require 'sys/proctable'
|
12
|
+
require 'rbconfig'
|
13
|
+
require 'test/test_sys_top'
|
14
|
+
include Sys
|
15
|
+
|
16
|
+
class TC_ProcTable_All < Test::Unit::TestCase
|
17
|
+
def self.startup
|
18
|
+
@@windows = Config::CONFIG['host_os'].match('mswin')
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
@pid = @@windows ? 0 : 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_version
|
26
|
+
assert_equal('0.8.0', ProcTable::VERSION)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_fields
|
30
|
+
assert_respond_to(ProcTable, :fields)
|
31
|
+
assert_nothing_raised{ ProcTable.fields }
|
32
|
+
assert_kind_of(Array, ProcTable.fields)
|
33
|
+
assert_kind_of(String, ProcTable.fields.first)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_ps
|
37
|
+
assert_respond_to(ProcTable, :ps)
|
38
|
+
assert_nothing_raised{ ProcTable.ps }
|
39
|
+
assert_nothing_raised{ ProcTable.ps{} }
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_ps_with_pid
|
43
|
+
assert_nothing_raised{ ProcTable.ps(0) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_ps_with_explicit_nil
|
47
|
+
assert_nothing_raised{ ProcTable.ps(nil) }
|
48
|
+
assert_kind_of(Array, ProcTable.ps(nil))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_ps_return_value
|
52
|
+
assert_kind_of(Array, ProcTable.ps)
|
53
|
+
assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
|
54
|
+
assert_equal(nil, ProcTable.ps(999999999))
|
55
|
+
assert_equal(nil, ProcTable.ps(999999999){})
|
56
|
+
assert_equal(nil, ProcTable.ps{})
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_ps_returned_struct_is_frozen
|
60
|
+
assert_true(ProcTable.ps.first.frozen?)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_ps_expected_errors
|
64
|
+
assert_raises(TypeError){ ProcTable.ps('vim') }
|
65
|
+
omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
|
66
|
+
assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_new_not_allowed
|
70
|
+
assert_raise(NoMethodError){ Sys::ProcTable.new }
|
71
|
+
end
|
72
|
+
|
73
|
+
def teardown
|
74
|
+
@pid = nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.teardown
|
78
|
+
@@windows = nil
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# test_sys_proctable_linux.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Linux version of the sys-proctable library. You
|
5
|
+
# should run these tests via the 'rake test' task.
|
6
|
+
#######################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'test-unit'
|
9
|
+
|
10
|
+
require 'sys/proctable'
|
11
|
+
require 'test/test_sys_proctable_all'
|
12
|
+
include Sys
|
13
|
+
|
14
|
+
class TC_ProcTable_Linux < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def self.startup
|
17
|
+
@@fields = %w/
|
18
|
+
cmdline cwd exe pid name uid euid gid egid comm state ppid pgrp
|
19
|
+
session tty_num tpgid flags minflt cminflt majflt cmajflt utime
|
20
|
+
stime cutime cstime priority nice itrealvalue starttime vsize
|
21
|
+
rss rlim startcode endcode startstack kstkesp kstkeip signal blocked
|
22
|
+
sigignore sigcatch wchan nswap cnswap exit_signal processor environ
|
23
|
+
/
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup
|
27
|
+
@ptable = ProcTable.ps.last
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_cmdline
|
31
|
+
assert_respond_to(@ptable, :cmdline)
|
32
|
+
assert_kind_of(String, @ptable.cmdline)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_cwd
|
36
|
+
assert_respond_to(@ptable, :cwd)
|
37
|
+
assert_true([NilClass, String].include?(@ptable.cwd.class))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_environ
|
41
|
+
assert_respond_to(@ptable, :environ)
|
42
|
+
assert_kind_of(Hash, @ptable.environ)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_exe
|
46
|
+
assert_respond_to(@ptable, :exe)
|
47
|
+
assert_kind_of(String, @ptable.exe)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_fd
|
51
|
+
assert_respond_to(@ptable, :fd)
|
52
|
+
assert_kind_of(Hash, @ptable.fd)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_root
|
56
|
+
assert_respond_to(@ptable, :root)
|
57
|
+
assert_kind_of(String, @ptable.root)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_pid
|
61
|
+
assert_respond_to(@ptable, :pid)
|
62
|
+
assert_kind_of(Fixnum, @ptable.pid)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_comm
|
66
|
+
assert_respond_to(@ptable, :comm)
|
67
|
+
assert_kind_of(String, @ptable.comm)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_state
|
71
|
+
assert_respond_to(@ptable, :state)
|
72
|
+
assert_kind_of(String, @ptable.state)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_ppid
|
76
|
+
assert_respond_to(@ptable, :ppid)
|
77
|
+
assert_kind_of(Fixnum, @ptable.ppid)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_pgrp
|
81
|
+
assert_respond_to(@ptable, :pgrp)
|
82
|
+
assert_kind_of(Fixnum, @ptable.pgrp)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_session
|
86
|
+
assert_respond_to(@ptable, :session)
|
87
|
+
assert_kind_of(Fixnum, @ptable.session)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_tty_nr
|
91
|
+
assert_respond_to(@ptable, :tty_nr)
|
92
|
+
assert_kind_of(Fixnum, @ptable.tty_nr)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_tpgid
|
96
|
+
assert_respond_to(@ptable, :tpgid)
|
97
|
+
assert_kind_of(Fixnum, @ptable.tpgid)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_flags
|
101
|
+
assert_respond_to(@ptable, :flags)
|
102
|
+
assert_kind_of(Fixnum, @ptable.flags)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_minflt
|
106
|
+
assert_respond_to(@ptable, :minflt)
|
107
|
+
assert_kind_of(Fixnum, @ptable.minflt)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_cminflt
|
111
|
+
assert_respond_to(@ptable, :cminflt)
|
112
|
+
assert_kind_of(Fixnum, @ptable.cminflt)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_majflt
|
116
|
+
assert_respond_to(@ptable, :majflt)
|
117
|
+
assert_kind_of(Fixnum, @ptable.majflt)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_cmajflt
|
121
|
+
assert_respond_to(@ptable, :cmajflt)
|
122
|
+
assert_kind_of(Fixnum, @ptable.cmajflt)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_utime
|
126
|
+
assert_respond_to(@ptable, :utime)
|
127
|
+
assert_kind_of(Fixnum, @ptable.utime)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_stime
|
131
|
+
assert_respond_to(@ptable, :stime)
|
132
|
+
assert_kind_of(Fixnum, @ptable.stime)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_cutime
|
136
|
+
assert_respond_to(@ptable, :cutime)
|
137
|
+
assert_kind_of(Fixnum, @ptable.cutime)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_cstime
|
141
|
+
assert_respond_to(@ptable, :cstime)
|
142
|
+
assert_kind_of(Fixnum, @ptable.cstime)
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_priority
|
146
|
+
assert_respond_to(@ptable, :priority)
|
147
|
+
assert_kind_of(Fixnum, @ptable.priority)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_nice
|
151
|
+
assert_respond_to(@ptable, :nice)
|
152
|
+
assert_kind_of(Fixnum, @ptable.nice)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_itrealvalue
|
156
|
+
assert_respond_to(@ptable, :itrealvalue)
|
157
|
+
assert_kind_of(Fixnum, @ptable.itrealvalue)
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_starttime
|
161
|
+
assert_respond_to(@ptable, :starttime)
|
162
|
+
assert_kind_of(Fixnum, @ptable.starttime)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_vsize
|
166
|
+
assert_respond_to(@ptable, :vsize)
|
167
|
+
assert_kind_of(Fixnum, @ptable.vsize)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_rss
|
171
|
+
assert_respond_to(@ptable, :rss)
|
172
|
+
assert_kind_of(Fixnum, @ptable.rss)
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_rlim
|
176
|
+
assert_respond_to(@ptable, :rlim)
|
177
|
+
assert_kind_of(Integer, @ptable.rlim)
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_startcode
|
181
|
+
assert_respond_to(@ptable, :startcode)
|
182
|
+
assert_kind_of(Fixnum, @ptable.startcode)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_endcode
|
186
|
+
assert_respond_to(@ptable, :endcode)
|
187
|
+
assert_kind_of(Fixnum, @ptable.endcode)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_startstack
|
191
|
+
assert_respond_to(@ptable, :startstack)
|
192
|
+
assert_kind_of(Integer, @ptable.startstack)
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_kstkesp
|
196
|
+
assert_respond_to(@ptable, :kstkesp)
|
197
|
+
assert_kind_of(Integer, @ptable.kstkesp)
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_kstkeip
|
201
|
+
assert_respond_to(@ptable, :kstkeip)
|
202
|
+
assert_kind_of(Integer, @ptable.kstkeip)
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_signal
|
206
|
+
assert_respond_to(@ptable, :signal)
|
207
|
+
assert_kind_of(Integer, @ptable.signal)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_blocked
|
211
|
+
assert_respond_to(@ptable, :blocked)
|
212
|
+
assert_kind_of(Fixnum, @ptable.blocked)
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_sigignore
|
216
|
+
assert_respond_to(@ptable, :sigignore)
|
217
|
+
assert_kind_of(Fixnum, @ptable.sigignore)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_sigcatch
|
221
|
+
assert_respond_to(@ptable, :sigcatch)
|
222
|
+
assert_kind_of(Fixnum, @ptable.sigcatch)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_wchan
|
226
|
+
assert_respond_to(@ptable, :wchan)
|
227
|
+
assert_kind_of(Fixnum, @ptable.wchan)
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_nswap
|
231
|
+
assert_respond_to(@ptable, :nswap)
|
232
|
+
assert_kind_of(Fixnum, @ptable.nswap)
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_cnswap
|
236
|
+
assert_respond_to(@ptable, :cnswap)
|
237
|
+
assert_kind_of(Fixnum, @ptable.cnswap)
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_exit_signal
|
241
|
+
assert_respond_to(@ptable, :exit_signal)
|
242
|
+
assert_kind_of(Fixnum, @ptable.exit_signal)
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_processor
|
246
|
+
assert_respond_to(@ptable, :processor)
|
247
|
+
assert_kind_of(Fixnum, @ptable.processor)
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_rt_priority
|
251
|
+
assert_respond_to(@ptable, :rt_priority)
|
252
|
+
assert_kind_of(Fixnum, @ptable.rt_priority)
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_policy
|
256
|
+
assert_respond_to(@ptable, :policy)
|
257
|
+
assert_kind_of(Fixnum, @ptable.policy)
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_name
|
261
|
+
assert_respond_to(@ptable, :name)
|
262
|
+
assert_kind_of(String, @ptable.name)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_uid
|
266
|
+
assert_respond_to(@ptable, :uid)
|
267
|
+
assert_kind_of(Fixnum, @ptable.uid)
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_euid
|
271
|
+
assert_respond_to(@ptable, :euid)
|
272
|
+
assert_kind_of(Fixnum, @ptable.euid)
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_gid
|
276
|
+
assert_respond_to(@ptable, :gid)
|
277
|
+
assert_kind_of(Fixnum, @ptable.gid)
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_egid
|
281
|
+
assert_respond_to(@ptable, :egid)
|
282
|
+
assert_kind_of(Fixnum, @ptable.egid)
|
283
|
+
end
|
284
|
+
|
285
|
+
def teardown
|
286
|
+
@ptable = nil
|
287
|
+
end
|
288
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sys-proctable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0
|
5
|
+
platform: x86-linux
|
6
|
+
authors:
|
7
|
+
- Daniel J. Berger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-26 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: test-unit
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.2
|
24
|
+
version:
|
25
|
+
description: An interface for providing process table information
|
26
|
+
email: djberg96@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- CHANGES
|
33
|
+
- README
|
34
|
+
- MANIFEST
|
35
|
+
- doc/top.txt
|
36
|
+
- doc/linux.txt
|
37
|
+
files:
|
38
|
+
- lib/sys/top.rb
|
39
|
+
- test/test_sys_proctable_all.rb
|
40
|
+
- CHANGES
|
41
|
+
- README
|
42
|
+
- MANIFEST
|
43
|
+
- doc/top.txt
|
44
|
+
- lib/sys/proctable.rb
|
45
|
+
- doc/linux.txt
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://www.rubyforge.org/projects/sysutils
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.8.2
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: sysutils
|
68
|
+
rubygems_version: 1.3.1
|
69
|
+
signing_key:
|
70
|
+
specification_version: 2
|
71
|
+
summary: An interface for providing process table information
|
72
|
+
test_files:
|
73
|
+
- test/test_sys_proctable_all.rb
|
74
|
+
- test/test_sys_proctable_linux.rb
|