sys-proctable 0.7.3 → 0.7.4
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 +7 -3
- data/MANIFEST +41 -0
- data/README +119 -56
- data/doc/freebsd.txt +43 -54
- data/doc/hpux.txt +40 -52
- data/doc/linux.txt +36 -51
- data/doc/solaris.txt +50 -70
- data/doc/top.txt +44 -45
- data/doc/windows.txt +60 -60
- data/ext/extconf.rb +101 -0
- data/ext/sunos/sunos.c +374 -0
- data/ext/sunos/sunos.h +177 -0
- data/{lib → ext}/version.h +1 -1
- data/lib/sys/top.rb +23 -0
- data/test/tc_all.rb +17 -21
- data/test/tc_freebsd.rb +9 -5
- data/test/tc_hpux.rb +10 -7
- data/test/tc_kvm_bsd.rb +10 -5
- data/test/tc_linux.rb +9 -6
- data/test/tc_sunos.rb +9 -5
- data/test/tc_top.rb +14 -15
- data/test/tc_windows.rb +7 -9
- data/test/test_memleak.rb +2 -2
- metadata +23 -18
- data/extconf.rb +0 -104
- data/lib/os/linux.c +0 -315
- data/lib/os/linux.h +0 -138
- data/test/test.rb +0 -70
data/CHANGES
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
== 0.
|
2
|
-
* Added
|
3
|
-
|
1
|
+
== 0.7.4 - 20-Nov-2006
|
2
|
+
* Added a patch that deals with the large file compilation issue on Solaris.
|
3
|
+
You no longer need to build Ruby with --disable-largefile, or build a
|
4
|
+
64 bit Ruby, in order for this package to work. Thanks go to Steven Jenkins
|
5
|
+
for the information that led to the patch.
|
4
6
|
* Added inline rdoc to the source code.
|
5
7
|
* Added a gemspec.
|
6
8
|
* Fixed some potential 64 bit issues (struct declarations).
|
9
|
+
* Added preliminary support for Darwin (OS X). The code was provided by
|
10
|
+
David Felstead, but does not appear to compile successfully. Help wanted.
|
7
11
|
|
8
12
|
== 0.7.3 - 27-Oct-2005
|
9
13
|
* Fix for 1.8.3 and later (rb_pid_t). This should have only affected
|
data/MANIFEST
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
CHANGES
|
2
|
+
INSTALL
|
3
|
+
MANIFEST
|
4
|
+
install.rb
|
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
|
+
ext/extconf.rb
|
15
|
+
ext/bsd/bsd.c
|
16
|
+
ext/darwin/darwin.c
|
17
|
+
ext/freebsd/freebsd.c
|
18
|
+
ext/freebsd/freebsd.h
|
19
|
+
ext/hpux/hpux.c
|
20
|
+
ext/hpux/hpux.h
|
21
|
+
ext/linux/linux.c
|
22
|
+
ext/linux/linux.h
|
23
|
+
ext/sunos/sunos.c
|
24
|
+
ext/sunos/sunos.h
|
25
|
+
ext/version.h
|
26
|
+
|
27
|
+
examples/test_ps.rb
|
28
|
+
|
29
|
+
lib/top.rb
|
30
|
+
|
31
|
+
lib/sys/windows.rb
|
32
|
+
|
33
|
+
test/tc_all.rb
|
34
|
+
test/tc_freebsd.rb
|
35
|
+
test/tc_hpux.rb
|
36
|
+
test/tc_linux.rb
|
37
|
+
test/tc_sunos.rb
|
38
|
+
test/tc_top.rb
|
39
|
+
test/tc_windows.rb
|
40
|
+
test/tc_kvm_bsd.rb
|
41
|
+
test/test_memleak.rb
|
data/README
CHANGED
@@ -1,68 +1,131 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Win32: Ruby 1.8.2 or later.
|
1
|
+
= Description
|
2
|
+
A Ruby interface for gathering process information.
|
4
3
|
|
5
|
-
|
4
|
+
= Prerequisites
|
5
|
+
=== Unix
|
6
|
+
Ruby 1.8.0 or later.
|
7
|
+
=== MS Windows
|
8
|
+
Ruby 1.8.2 or later.
|
9
|
+
|
10
|
+
= Supported Platforms
|
6
11
|
* Windows NT family (NT, 2000, XP, etc)
|
7
12
|
* Linux
|
8
13
|
* FreeBSD (/proc or kvm)
|
9
14
|
* Solaris
|
10
|
-
* NetBSD (kvm only)
|
11
15
|
* HP-UX
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
ruby extconf.rb
|
17
|
+
= Installation
|
18
|
+
=== UNIX
|
19
|
+
cd ext; ruby extconf.rb
|
16
20
|
make
|
17
|
-
ruby test.rb (optional)
|
18
|
-
make
|
21
|
+
cd ..; ruby test/ts_all.rb (optional)
|
22
|
+
make install
|
19
23
|
|
20
|
-
Windows
|
24
|
+
=== MS Windows
|
21
25
|
ruby test/tc_windows.rb (optional)
|
22
26
|
ruby install.rb
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
28
|
+
= Synopsis
|
29
|
+
require 'sys/proctable'
|
30
|
+
include Sys
|
31
|
+
|
32
|
+
# Everything
|
33
|
+
ProcTable.ps{ |p|
|
34
|
+
puts p.pid.to_s
|
35
|
+
puts p.comm
|
36
|
+
...
|
37
|
+
}
|
38
|
+
|
39
|
+
or
|
40
|
+
|
41
|
+
# Just one process
|
42
|
+
s = ProcTable.ps(2123)
|
43
|
+
puts s.pid.to_s
|
44
|
+
puts s.comm
|
45
|
+
...
|
46
|
+
|
47
|
+
# Return the results as an array of ProcTableStructs
|
48
|
+
a = ProcTable.ps
|
49
|
+
a.each do |p|
|
50
|
+
puts a.pid
|
51
|
+
...
|
52
|
+
end
|
53
|
+
|
54
|
+
= Notes
|
55
|
+
Windows users may pass a host name as a second argument to get process
|
56
|
+
information from a different host. This relies on the WMI service running.
|
57
|
+
|
58
|
+
If you're building C source code, the ts_all.rb file is autogenerated for
|
59
|
+
you.
|
60
|
+
|
61
|
+
= Known Issues
|
62
|
+
=== BSD
|
63
|
+
If you're building on FreeBSD, a standard /proc filesystem read approach is
|
64
|
+
used if mounted. Otherwise, a kvm interface is used. There are more fields
|
65
|
+
available with the kvm interface, but keep in mind that you need to be a
|
66
|
+
member of the kvm group (or root) to use this. You can tweak the
|
67
|
+
extconf.rb file manually if you want to force the issue.
|
68
|
+
|
69
|
+
Not all fields are available on FreeBSD 5.x (yet). OpenBSD and NetBSD are
|
70
|
+
not yet supported.
|
71
|
+
|
72
|
+
Research has indicated that the kvm approach is less favored than a sysctl
|
73
|
+
approach. I will try to add this interface in the 0.8.0 release.
|
74
|
+
|
75
|
+
=== Solaris
|
76
|
+
The cmdline member on solaris is limited to 80 characters unless you (or
|
77
|
+
your program) own the process. This is a Solaris design flaw/feature.
|
78
|
+
|
79
|
+
=== Misc
|
80
|
+
If you build your library as a C extension (mandatory on all platforms
|
81
|
+
except MS Windows at the moment), then the windows.rb file under 'lib/sys/'
|
82
|
+
is renamed to 'windows.orig'. This is to prevent mkmf from auto-installing
|
83
|
+
it during the 'make install' phase.
|
84
|
+
|
85
|
+
=== Thread Safety
|
86
|
+
I am not currently using a thread-safe version of readdir(). I am not
|
87
|
+
especially concerned about it either. If you are trying to read information
|
88
|
+
out of /proc from different threads at the same time there is something
|
89
|
+
seriously wrong with your code logic. Using readdir_r() still won't solve
|
90
|
+
all potential thread safety issues anyway.
|
91
|
+
|
92
|
+
= Future Plans
|
93
|
+
I'm considering using a pure Ruby version for Linux.
|
94
|
+
|
95
|
+
= Acknowledgements
|
96
|
+
This package is largely based on the Perl module Proc::ProcessTable by
|
97
|
+
Dan Urist. Many ideas, as well as large chunks of code, were taken
|
98
|
+
from his work. So, a big THANK YOU goes out to Dan Urist.
|
99
|
+
|
100
|
+
A big thanks also goes out to Mike Hall who was very helpful with ideas,
|
101
|
+
logic and testing.
|
102
|
+
|
103
|
+
Thanks also go to Sean Chittenden for providing an account on one of his
|
104
|
+
FreeBSD machines. This is how the FreeBSD support was (initially) added.
|
105
|
+
|
106
|
+
Thanks go to James Hranicky for providing a patch that grabs name, eid,
|
107
|
+
euid, gid and guid info in the Linux version, along with some general
|
108
|
+
debugging help.
|
109
|
+
|
110
|
+
= Help Wanted
|
111
|
+
I do not have access to all platforms. There are a few other major platforms
|
112
|
+
out there, namely OS X, AIX, OpenBSD, and IRIX, among others, that I would
|
113
|
+
like to see ports for. There are two ways you can help - either submit code
|
114
|
+
for your particular platform or give me an account on your platform so I can
|
115
|
+
develop on it.
|
116
|
+
|
117
|
+
= More documentation
|
118
|
+
See the documentation under the 'doc' directory for your platform for more
|
119
|
+
information, including platform specific notes and issues.
|
120
|
+
|
121
|
+
= License
|
122
|
+
Ruby's
|
123
|
+
|
124
|
+
= Copyright
|
125
|
+
(C) 2003-2006 Daniel J. Berger
|
126
|
+
All Rights Reserved.
|
127
|
+
|
128
|
+
= Author
|
129
|
+
Daniel J. Berger
|
130
|
+
djberg96 at nospam at gmail dot com
|
131
|
+
imperator on IRC (Freenode)
|
data/doc/freebsd.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
= Description
|
2
2
|
sys-proctable
|
3
3
|
|
4
4
|
A Ruby interface to the 'ps' command. This is a C extension, not parsed
|
5
5
|
output. For FreeBSD, data is read directly out of the /proc filesystem.
|
6
6
|
|
7
|
-
|
7
|
+
= Synopsis
|
8
8
|
require 'sys/proctable'
|
9
9
|
include Sys
|
10
10
|
|
@@ -32,70 +32,59 @@
|
|
32
32
|
...
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
= Constants
|
36
36
|
VERSION
|
37
|
-
|
37
|
+
Returns the current version number for this package (as a string).
|
38
38
|
|
39
|
-
|
39
|
+
= Class Methods
|
40
40
|
ProcTable.fields
|
41
|
-
|
41
|
+
Returns a list of fields available on the current OS. Also takes a block.
|
42
42
|
|
43
43
|
ProcTable.ps(pid = nil)
|
44
44
|
ProcTable.ps{ |s| ... }
|
45
|
-
|
46
|
-
|
47
|
-
|
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
48
|
|
49
|
-
|
50
|
-
|
49
|
+
If a pid argument is provided, a single ProcTable struct is returned, or
|
50
|
+
nil if the pid is not found.
|
51
51
|
|
52
|
-
|
52
|
+
= Exception Classes
|
53
53
|
ProcTableError < StandardError
|
54
|
-
|
54
|
+
Raised if the /proc field is unreadable and/or unmounted.
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
= Supported fields
|
57
|
+
You can view the supported fields with the "fields()" class method.
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
68
|
|
69
|
-
|
70
|
-
|
69
|
+
If you find any other bugs please log them on the project
|
70
|
+
page at http://www.rubyforge.org/projects/sysutils
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
= License
|
73
|
+
Ruby's
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
= Copyright
|
76
|
+
(C) 2003-2006 Daniel J. Berger
|
77
|
+
All Rights Reserved
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
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 nospam at gmail dot com
|
87
|
+
imperator on IRC (Freenode)
|
88
|
+
|
89
|
+
= See Also
|
90
|
+
ps, proc
|
data/doc/hpux.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
= Description
|
2
2
|
sys-proctable
|
3
3
|
|
4
4
|
A Ruby version of the 'ps' command. This is a C extension, not parsed
|
5
5
|
output. For HP-UX, proc structs are grabbed via the pstat_getproc() call.
|
6
6
|
|
7
|
-
|
7
|
+
= Synopsis
|
8
8
|
require 'sys/proctable'
|
9
9
|
include Sys
|
10
10
|
|
@@ -24,67 +24,55 @@
|
|
24
24
|
...
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
= Constants
|
28
28
|
VERSION
|
29
|
-
|
29
|
+
Returns the current version number for this package (as a string).
|
30
30
|
|
31
|
-
|
31
|
+
= Class Methods
|
32
32
|
ProcTable.fields
|
33
|
-
|
34
|
-
|
33
|
+
Returns a list of fields available on the current OS. May also take
|
34
|
+
a block.
|
35
35
|
|
36
36
|
ProcTable.ps(pid=nil)
|
37
37
|
ProcTable.ps{ |s| ... }
|
38
|
-
|
39
|
-
|
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
40
|
|
41
|
-
|
42
|
-
|
41
|
+
If a pid is provided then a single ProcTable struct is returned, or nil
|
42
|
+
if the pid is not found.
|
43
43
|
|
44
|
-
|
44
|
+
= Supported fields
|
45
|
+
You can view the supported fields with the "fields()" class method.
|
45
46
|
|
46
|
-
|
47
|
+
= Future Plans
|
48
|
+
Have the flags field return a meaningful value.
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
+
= Notes
|
51
|
+
The "comm" field isn't really part of the psinfo struct. It is just a copy
|
52
|
+
(i.e. is identical to) the "fname" field. I added it to provide a degree
|
53
|
+
of consistency between all of the platforms. I will also make a point
|
54
|
+
of adding it to any future platform releases.
|
50
55
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
of consistency between all of the platforms. I will also make a point
|
55
|
-
of adding it to any future platform releases.
|
56
|
+
= Known Bugs
|
57
|
+
None that I'm aware of. Please log any bugs on the project page at
|
58
|
+
http://www.rubyforge.org/projects/sysutils
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
http://www.rubyforge.org/projects/sysutils
|
60
|
+
= License
|
61
|
+
Ruby's
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
== Copyright
|
65
|
-
(C) 2003-2005 Daniel J. Berger
|
66
|
-
All Rights Reserved.
|
63
|
+
= Copyright
|
64
|
+
(C) 2003-2006 Daniel J. Berger
|
65
|
+
All Rights Reserved.
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
67
|
+
= Warranty
|
68
|
+
This package is provided "as is" and without any express or
|
69
|
+
implied warranties, including, without limitation, the implied
|
70
|
+
warranties of merchantability and fitness for a particular purpose.
|
71
|
+
|
72
|
+
= Author
|
73
|
+
Daniel J. Berger
|
74
|
+
djberg96 at nospam at gmail dot com
|
75
|
+
imperator on IRC (Freenode)
|
76
|
+
|
77
|
+
= See Also
|
78
|
+
ps, proc
|