sys-proctable 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,209 @@
1
+ == 0.8.0 - ???
2
+ * Added preliminary support for Darwin (OS X). Thanks go to David Felstead
3
+ for the code contribution.
4
+ * Added inline rdoc to the source code.
5
+ * Added a gemspec.
6
+ * Fixed some potential 64 bit issues (struct declarations).
7
+
8
+ == 0.7.3 - 27-Oct-2005
9
+ * Fix for 1.8.3 and later (rb_pid_t). This should have only affected
10
+ Solaris.
11
+
12
+ == 0.7.2 - 15-May-2005
13
+ * Bug fix for the FreeBSD version that reads from /proc.
14
+ * Eliminated the test bug on Linux (inexplicably caused by File.copy). The
15
+ test suite should now run without segfaulting.
16
+ * Include bsd.c in tarball (oops).
17
+ * Minor test updates for FreeBSD.
18
+ * The 'pct_cpu' member for the BSD/kvm version has been changed to 'pctcpu'
19
+ consistency with other platforms.
20
+
21
+ == 0.7.1 - 8-May-2005
22
+ * Bug fixed for the cmdline info on Linux. Thanks go to Arash Abedinzadeh
23
+ for the spot.
24
+ * Added an example program.
25
+ * Minor setup fix for Win32 in tc_all.rb.
26
+
27
+ == 0.7.0 - 25-Apr-2005
28
+ * Scrapped the C implementation for Windows in favor of an OLE + WMI pure Ruby
29
+ approach. See documentation for details.
30
+ * Added an optional lkvm implementation for BSD users. This is automatically
31
+ used if the /proc filesystem isn't found.
32
+ * Added prusage info for the Solaris version.
33
+ * Added name, eid, euid, gid and guid information for Linux. Thanks go to
34
+ James Hranicky for the patch.
35
+ * Fixed some potential bugs in the Linux version. Thanks go to James
36
+ Hranicky for the spot.
37
+ * Added the 'sys/top' package.
38
+ * ProcTable.fields no longer supports a block form.
39
+ * The BTIME (boot time) information has been removed from the Linux version.
40
+ If you want that information, use sys-uptime instead.
41
+ * The .html and .rd files have been removed. You can generate html on your
42
+ own with rdoc if you like.
43
+ * Some code cleanup on the C side of the house.
44
+ * Most documents made rdoc friendly.
45
+ * Renamed 'install_pure_ruby.rb' to just 'install.rb'.
46
+ * Removed the 'INSTALL' file. Installation instructions are in the README.
47
+ * Some test suite cleanup and reorganization.
48
+ * Moved project to RubyForge.
49
+
50
+ == 0.6.4 - 31-Mar-2004
51
+ * Fixed a bug in the pure Ruby version for Win32. Thanks go to Mark Hudson
52
+ for the spot.
53
+ * Fixed a bug in the C implementation for Win32 where the cmdline and path
54
+ values were sometimes wrong for running processes. Thanks go to Park Heesob
55
+ for the fix.
56
+ * Updated the VERSION constant and removed the VERSION class method in the
57
+ pure Ruby version for Win32.
58
+ * Updated install_pure_ruby.rb and test.rb scripts.
59
+ * Updated warranty information.
60
+ * The extconf.rb script has been revamped. See the INSTALL and README files
61
+ for important changes since the last release.
62
+ * The start ProcInfo struct member on Solaris, HP-UX and FreeBSD is now a
63
+ Time object, not a Fixnum/Bignum.
64
+ * Modified linux.c yet again to make gcc happy when it comes to multi-line
65
+ string literals.
66
+ * Minor change to way process state is handled on HP-UX.
67
+ * Documentation additions and updates, including warranty information.
68
+
69
+ == 0.6.3 - 24-Feb-2004
70
+ * Fixed a bug in the Solaris version where the cmd_args array did not
71
+ necessarily contain data on 2.7 and later. The current patch still
72
+ does not quite fix the problem for 2.6 and earlier but can be easily
73
+ derived manually by parsing the cmdline string.
74
+
75
+ == 0.6.2 - 20-Jan-2004
76
+ * Fixed a small memory leak in the solaris version.
77
+
78
+ == 0.6.1 - 31-Dec-2003
79
+ * Fixed a minor bug in the cmdline field on Linux where a blank character
80
+ was being appended to the end of the field.
81
+ * Fixed a minor annoyance where the windows.rb file was being copied into
82
+ the Ruby lib directory on install.
83
+ * Added a test_memleak.rb file. Currently only supported on Linux and
84
+ only does a file descriptor count check. I plan to expand this to
85
+ other platforms in the future.
86
+ * Minor test suite changes
87
+ * MANIFEST correction and update.
88
+
89
+ == 0.6.0 - 22-Oct-2003
90
+ * Significant API change (and thus, a version jump) - only a
91
+ single argument is now accepted to the ps() method, and only a PID
92
+ (Fixnum) is regarded as a valid argument.
93
+ * Calling ps() with a pid returns a single ProcTable struct (or nil
94
+ if the pid is not found), instead of a one element array.
95
+ * Argument to ps() now works properly on HP-UX and Win32.
96
+ * Removed the '#include <sys/types32.h>' in sunos.h. It wasn't needed
97
+ and you're not supposed to include it directly.
98
+ * Fixed 2.6 compatibility issue with regards to cmdline on Solaris.
99
+ * Removed the ProcStatException completely on Linux. There was no reason
100
+ to fail on a directory read for /proc/xxx/stat. If the read fails
101
+ (meaning the process died in the middle of collecting info for it), it
102
+ is simply ignored.
103
+ * The ttynum bug on HPUX has been fixed. In addition, the return value for
104
+ this field is now a string rather than an int and the field name has
105
+ been changed to "ttydev".
106
+ * The ttynum field has been changed to ttydev on Solaris and HPUX. On
107
+ Solaris, the ttydev is now reported as -1 if there is no associated tty.
108
+ In a future release, Solaris and the other *nix platforms will be changed
109
+ so that ttydev is always a device name (i.e String).
110
+ * Added plain text documentation for all platforms.
111
+ * Some test suite cleanup.
112
+ * Changed .rd2 extension to just '.rd'.
113
+
114
+ == 0.5.2 - 18-Jul-2003
115
+ * Modified cmdline to extend past the traditional 80 character limit on
116
+ Solaris, where possible (Solaris 2.6+ only).
117
+ * Added the cmdline_args and num_args fields on Solaris, which returns
118
+ an array of cmdline arguments and the number of cmdline arguments,
119
+ respectively.
120
+ * Minor modification to fields() method, in addition to warning cleanup
121
+ for Solaris.
122
+ * Changed "defunct" state string to "zombie" for Solaris.
123
+ * Should cleanly compile with -Wall -W now (gcc) on Solaris.
124
+ * Added solaris.txt to doc directory.
125
+ * MANIFEST corrections.
126
+
127
+ == 0.5.1 - 16-Jul-2003
128
+ * Fixed a nasty file descriptor bug in the Linux code, where file descriptors
129
+ were continuously being used up.
130
+ * Added the BTIME (boot time) constant for Linux.
131
+ * Fixed up the test/test.rb file a bit.
132
+ * Added BTIME tests to tc_linux.rb.
133
+
134
+ == 0.5.0 - 11-Jul-200
135
+ * Added HP-UX support!
136
+ * Note that passing PID's or strings as arguments to ps() is not supported
137
+ in the HP-UX version. This functionality will be stripped out of the
138
+ other versions in a future release. See the README file for more details.
139
+ * Removed the VERSION() class method. Use the constant instead.
140
+ * Separated the rd docs from their respective source files. Now in the doc
141
+ directory.
142
+ * Got rid of the interactive html generation in extconf.rb.
143
+ * Changed License to Artistic.
144
+
145
+ == 0.4.3 - 30-May-2003
146
+ * Added a version.h file to store the version number. Modified all of the
147
+ C source files to use that instead of hard coding the version everywhere.
148
+ * Added a generic test.rb script for those without TestUnit installed, or
149
+ just futzing in general. Modified the extconf.rb script to copy this
150
+ instead of writing an inline HERE document.
151
+ * Modified extconf.rb so that it builds with mingw or cygwin. Thanks go to
152
+ Peter Fischer for the spot and patch.
153
+ * Modified test suite to work with TestUnit 0.1.6 or 0.1.8.
154
+
155
+ == 0.4.2 - 14-Apr-2003
156
+ * Added pure Ruby version for Win32 - thanks Park Heesob.
157
+ * Modified extconf.rb file to handle pure Ruby versions.
158
+ * Added install_pure_ruby.rb file, an alternate installation
159
+ script for pure Ruby versions.
160
+
161
+ == 0.4.1 - 31-Mar-2003
162
+ * Added support for Solaris 2.5.x.
163
+ * All exceptions are now a direct subclass of StandardError.
164
+ * Value returned for wchan now more meaningful (2.5.x only for now).
165
+ * Fixed the start, utime and ctime for FreeBSD.
166
+ * Minor fix to FreeBSD test suite.
167
+ * Some changes to extconf.rb.
168
+ * Minor doc changes.
169
+ * Added License and Copyright info.
170
+
171
+ == 0.4.0 - 10-Mar-2003
172
+ * Added MS Windows support (non-cygwin).
173
+ * Added environment information for Linux version.
174
+ * Added real exceptions (type depends on platform).
175
+ * Added a test suite (for those with testunit installed).
176
+ * Removed the sys-uname requirement.
177
+ * Heavily modified the extconf.rb script.
178
+ * Changed "Changelog" to "CHANGES" and "Manifest" to "MANIFEST".
179
+ * Added a VERSION constant and class method.
180
+ * Minor internal directory layout change (put 'os' under 'lib').
181
+ * Changed package name to lower case.
182
+ * Doc changes, including license information.
183
+
184
+ == 0.3.1 - 16-Aug-2002
185
+ * Added a "comm" field to the sunos version. I am going to try to make this a
186
+ common field for all platforms to help reduce RUBY_PLATFORM checking.
187
+ * Fixed the release date for 0.3.0 (was accidentally marked *July*).
188
+ * Added an INSTALL file.
189
+ * Minor documentation change to the sunos.c source file.
190
+
191
+ == 0.3.0 - 11-Aug-2002
192
+ * Added FreeBSD support!
193
+ * Struct name changed to just "ProcTableStruct" to be compliant with future
194
+ versions of Ruby.
195
+ * The ps() function now returns an array of ProcTableStruct's in lvalue context.
196
+ * Fixed the ability to search by process name in Linux.
197
+ * Modified Linux "comm" field to strip parenthesis.
198
+ * Some doc changes/additions.
199
+ * Added Sean Chittenden to the "Acknowledgements" section. Sean provided me
200
+ with access to a FreeBSD box, which is how I was able to provide FreeBSD
201
+ support. Thanks Sean!
202
+
203
+ == 0.2.0 - 19-Jul-2002
204
+ * Added the ability to search by process name.
205
+ * test.rb modified to be cross-platform.
206
+ * Solaris - fixed bug with fname (was accidentally called "name").
207
+
208
+ == 0.1.0 - 2-Jul-2002
209
+ - Initial release.
data/README ADDED
@@ -0,0 +1,68 @@
1
+ == Prerequisites
2
+ Unix: Ruby 1.8.0 or later.
3
+ Win32: Ruby 1.8.2 or later.
4
+
5
+ == Supported Platforms
6
+ * Windows NT family (NT, 2000, XP, etc)
7
+ * Linux
8
+ * FreeBSD (/proc or kvm)
9
+ * Solaris
10
+ * NetBSD (kvm only)
11
+ * HP-UX
12
+
13
+ == Installation
14
+ Unix:
15
+ ruby extconf.rb
16
+ make
17
+ ruby test.rb (optional)
18
+ make site-install
19
+
20
+ Windows:
21
+ ruby test/tc_windows.rb (optional)
22
+ ruby install.rb
23
+
24
+ == Notes
25
+ Windows users may pass a host name as a second argument to get process
26
+ information from a different host. This relies on the WMI service running.
27
+
28
+ If you're building C source code, the test.rb file is autogenerated for you.
29
+
30
+ == BSD Issues
31
+ If you're building on FreeBSD, a standard /proc filesystem read approach is
32
+ used if mounted. Otherwise, a kvm interface is used. There are more fields
33
+ available with the kvm interface, but keep in mind that you need to be a
34
+ member of the kvm group (or root) to use this. You can tweak the
35
+ extconf.rb file manually if you want to force the issue.
36
+
37
+ Not all fields are available on FreeBSD 5.x (yet). OpenBSD and NetBSD are
38
+ not yet supported.
39
+
40
+ Research has indicated that the kvm approach is less favored than a sysctl
41
+ approach. I will try to add this interface in the 0.8.0 release.
42
+
43
+ == Solaris Issues
44
+ The cmdline member on solaris is limited to 80 characters unless you (or
45
+ your program) own the process. This is a Solaris design flaw, er, feature.
46
+
47
+ == Other Issues
48
+ If you build your library as a C extension (mandatory on all platforms
49
+ except MS Windows at the moment), then the windows.rb file under 'lib/os/'
50
+ is renamed to 'windows.orig'. This is to prevent mkmf from auto-installing
51
+ it during the 'make site-install' phase.
52
+
53
+ == Thread Safety
54
+ I am not currently using a thread-safe version of readdir(). I am not especially
55
+ concerned about it either. If you are trying to read information out of /proc
56
+ from different threads at the same time there is something seriously wrong with
57
+ your code logic. Using readdir_r() still won't solve all potential thread safety
58
+ issues anyway.
59
+
60
+ == Future Plans
61
+ I think I'm going to replace the version for Linux with a pure Ruby version.
62
+
63
+ == Help Wanted
64
+ I do not have access to all platforms. There are a few other major platforms
65
+ out there, namely OS X, AIX, OpenBSD, and IRIX, among others, that I would
66
+ like to see ports for. There are two ways you can help - either submit code
67
+ for your particular platform or give me an account on your platform so I can
68
+ develop on it.
data/doc/freebsd.txt ADDED
@@ -0,0 +1,101 @@
1
+ == Description
2
+ sys-proctable
3
+
4
+ A Ruby interface to the 'ps' command. This is a C extension, not parsed
5
+ output. For FreeBSD, data is read directly out of the /proc filesystem.
6
+
7
+ == Synopsis
8
+ require 'sys/proctable'
9
+ include Sys
10
+
11
+ # Everything
12
+ ProcTable.ps{ |p|
13
+ puts p.pid.to_s
14
+ puts p.comm
15
+ ...
16
+ }
17
+
18
+ or
19
+
20
+ # Just one process
21
+ p = ProcTable.ps(2123)
22
+ puts p.pid.to_s
23
+ puts p.comm
24
+ ...
25
+
26
+ or
27
+
28
+ # Return the results as an array of ProcTableStructs
29
+ a = ProcTable.ps()
30
+ a.each do |p|
31
+ puts a.pid
32
+ ...
33
+ end
34
+
35
+ == Constants
36
+ VERSION
37
+ Returns the current version number for this package (as a string).
38
+
39
+ == Class Methods
40
+ ProcTable.fields
41
+ Returns a list of fields available on the current OS. Also takes a block.
42
+
43
+ ProcTable.ps(pid = nil)
44
+ ProcTable.ps{ |s| ... }
45
+ If no pid's or processes are included as arguments, in block form it
46
+ returns a struct of type ProcTableStruct for every process in the proc
47
+ table. Otherwise it returns an array of ProcTableStruct's.
48
+
49
+ If a pid argument is provided, a single ProcTable struct is returned, or
50
+ nil if the pid is not found.
51
+
52
+ == Exception Classes
53
+ ProcTableError < StandardError
54
+ Raised if the /proc field is unreadable and/or unmounted.
55
+
56
+ == Supported fields
57
+ You can view the supported fields with the "fields()" class method.
58
+
59
+ == Future Plans
60
+ Add a pure-ruby version as an alternative
61
+ Add support for other *BSD flavors
62
+ Add ttydev info
63
+ Add a sysctl version
64
+
65
+ == Known Bugs
66
+ The kvm version for FreeBSD 5.x does not support all of the fields that
67
+ the 4.x version supports.
68
+
69
+ If you find any other bugs please log them on the project
70
+ page at http://www.rubyforge.org/projects/sysutils
71
+
72
+ == License
73
+ Ruby's
74
+
75
+ == Copyright
76
+ (C) 2003-2005 Daniel J. Berger
77
+ All Rights Reserved
78
+
79
+ == Warranty
80
+ This package is provided "as is" and without any express or
81
+ implied warranties, including, without limitation, the implied
82
+ warranties of merchantability and fitness for a particular purpose
83
+
84
+ == Author
85
+ Daniel J. Berger
86
+ djberg96 at yahoo dot com
87
+ imperator/rubyhacker1 on IRC (Freenode)
88
+
89
+ == Credits
90
+ This module is largely based on the Perl module Proc::ProcessTable by
91
+ Dan Urist. Many ideas, as well as large chunks of code, were taken
92
+ from his work. So, a big THANK YOU goes out to Dan Urist.
93
+
94
+ A big thanks also goes out to Mike Hall who was very helpful with ideas,
95
+ logic and testing.
96
+
97
+ Thanks also go to Sean Chittenden for providing an account on one of his
98
+ FreeBSD machines. This is how the FreeBSD support was (originally) added.
99
+
100
+ == See Also
101
+ ps, proc
data/doc/hpux.txt ADDED
@@ -0,0 +1,90 @@
1
+ == Description
2
+ sys-proctable
3
+
4
+ A Ruby version of the 'ps' command. This is a C extension, not parsed
5
+ output. For HP-UX, proc structs are grabbed via the pstat_getproc() call.
6
+
7
+ == Synopsis
8
+ require 'sys/proctable'
9
+ include Sys
10
+
11
+ # Everything
12
+ ProcTable.ps{ |p|
13
+ puts p.pid.to_s
14
+ puts p.comm
15
+ ...
16
+ }
17
+
18
+ or
19
+
20
+ # Return the results as an array of ProcTableStructs
21
+ a = ProcTable.ps()
22
+ a.each do |p|
23
+ puts a.pid
24
+ ...
25
+ end
26
+
27
+ == Constants
28
+ VERSION
29
+ Returns the current version number for this package (as a string).
30
+
31
+ == Class Methods
32
+ ProcTable.fields
33
+ Returns a list of fields available on the current OS. May also take
34
+ a block.
35
+
36
+ ProcTable.ps(pid=nil)
37
+ ProcTable.ps{ |s| ... }
38
+ Returns a struct of type ProcTableStruct for every process in the proc
39
+ table in block form. Otherwise it returns an array of ProcTableStruct's.
40
+
41
+ If a pid is provided then a single ProcTable struct is returned, or nil
42
+ if the pid is not found.
43
+
44
+ == Supported fields
45
+
46
+ You can view the supported fields with the "fields()" class method.
47
+
48
+ == Future Plans
49
+ Have the flags field return a meaningful value.
50
+
51
+ == Notes
52
+ The "comm" field isn't really part of the psinfo struct. It is just a copy
53
+ (i.e. is identical to) the "fname" field. I added it to provide a degree
54
+ of consistency between all of the platforms. I will also make a point
55
+ of adding it to any future platform releases.
56
+
57
+ == Known Bugs
58
+ None that I'm aware of. Please log any bugs on the project page at
59
+ http://www.rubyforge.org/projects/sysutils
60
+
61
+ == License
62
+ Ruby's
63
+
64
+ == Copyright
65
+ (C) 2003-2005 Daniel J. Berger
66
+ All Rights Reserved.
67
+
68
+ == Warranty
69
+ This package is provided "as is" and without any express or
70
+ implied warranties, including, without limitation, the implied
71
+ warranties of merchantability and fitness for a particular purpose.
72
+
73
+ == Author
74
+ Daniel J. Berger
75
+ djberg96 at yahoo dot com
76
+ imperator/rubyhacker1 on IRC (Freenode)
77
+
78
+ == Credits
79
+ This module is largely based on the Perl module Proc::ProcessTable by
80
+ Dan Urist. Many ideas, as well as large chunks of code, were taken
81
+ from his work. So, a big THANK YOU goes out to Dan Urist.
82
+
83
+ A big thanks also goes out to Mike Hall who was very helpful with ideas,
84
+ logic and testing.
85
+
86
+ Thanks also go to Sean Chittenden for providing an account on one of his
87
+ FreeBSD machines. This is how the FreeBSD support was (initially) added.
88
+
89
+ == See Also
90
+ ps, proc