sys-proctable 0.8.1-x86-freebsd-7 → 0.8.2-x86-freebsd-7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,22 @@
1
+ == 0.9.0 - 14-Oct-2009
2
+ * Changed the license to Artistic 2.0.
3
+ * Fixed a bug in the OS X code where a segfault would occur when an attempt
4
+ was made to gather resource usage information on zombie processes. From
5
+ now on that information is always set to nil for zombie processes. Thanks
6
+ go to Tom Lianza for the spot and Philip Kromer for investigating the
7
+ root cause of the failure.
8
+ * Removed the FreeBSD code that read out of /proc. It was a pain from a
9
+ maintenance point of view, and most FreeBSD installs do not mount /proc
10
+ by default. The FreeBSD platform now uses the same code that the other
11
+ BSD platforms use.
12
+ * Fixed a bug in the BSD code where the ProcTable::Error class had the
13
+ wrong parent class.
14
+ * Some major gemspec updates, including an updated license. The platform
15
+ handling logic is now in the Rakefile in the 'gem' task.
16
+ * Updated the README file to include an additional acknowledgement, a
17
+ license change and some minor formatting changes.
18
+ * The test-unit library was changed from a runtime to a development dependency.
19
+
1
20
  == 0.8.1 - 6-Apr-2009
2
21
  * The Linux and Solaris libraries now handle the possibility of a process
3
22
  terminating in the middle of a read more gracefully. If that happens, they
data/MANIFEST CHANGED
@@ -1,38 +1,30 @@
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
1
+ * CHANGES
2
+ * MANIFEST
3
+ * Rakefile
4
+ * README
5
+ * sys-proctable.gemspec
6
+ * doc/bsd.txt
7
+ * doc/hpux.txt
8
+ * doc/linux.txt
9
+ * doc/solaris.txt
10
+ * doc/top.txt
11
+ * doc/windows.txt
12
+ * example/example_ps.rb
13
+ * ext/bsd/extconf.rb
14
+ * ext/bsd/sys/proctable.c
15
+ * ext/darwin/extconf.rb
16
+ * ext/darwin/sys/proctable.c
17
+ * ext/hpux/extconf.rb
18
+ * ext/hpux/sys/proctable.c
19
+ * lib/sys/top.rb
20
+ * lib/linux/sys/proctable.rb
21
+ * lib/sunos/sys/proctable.rb
22
+ * lib/windows/sys/proctable.rb
23
+ * test/test_sys_proctable_all.rb
24
+ * test/test_sys_proctable_darwin.rb
25
+ * test/test_sys_proctable_hpux.rb
26
+ * test/test_sys_proctable_bsd.rb
27
+ * test/test_sys_proctable_linux.rb
28
+ * test/test_sys_proctable_sunos.rb
29
+ * test/test_sys_proctable_windows.rb
30
+ * test/test_sys_top.rb
data/README CHANGED
@@ -1,21 +1,30 @@
1
- = Description
1
+ == Description
2
2
  A Ruby interface for gathering process information.
3
3
 
4
- = Prerequisites
4
+ == Prerequisites
5
5
  * Ruby 1.8.2 or later
6
- * Test::Unit 2.x
6
+ * Test::Unit 2.x (development only)
7
7
 
8
- = Supported Platforms
8
+ == Supported Platforms
9
9
  * Windows NT family (NT, 2000, XP, etc)
10
- * Linux
11
- * FreeBSD
12
- * Solaris 2.8+
13
- * HP-UX
14
- * OS X
10
+ * Linux 2.6+
11
+ * BSD (various flavors)
12
+ * Solaris 8+
13
+ * HP-UX 10+
14
+ * OS X 10.4+
15
15
 
16
- = Installation
17
- * rake test (optional)
18
- * rake install
16
+ == Installation
17
+ === Rubygems
18
+ gem install sys-proctable
19
+
20
+ You may need to specify a platform in some cases. For example:
21
+
22
+ gem install sys-proctable --platform mswin32 # Windows
23
+ gem install sys-proctable --platform sunos # Solaris
24
+ gem install sys-proctalbe --platform linux # Linux
25
+
26
+ === Standard
27
+ rake install
19
28
 
20
29
  = Synopsis
21
30
  require 'sys/proctable'
@@ -43,24 +52,14 @@
43
52
  ...
44
53
  end
45
54
 
46
- = Notes
55
+ == Notes
47
56
  Windows users may pass a host name as a second argument to get process
48
57
  information from a different host. This relies on the WMI service running.
49
58
 
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.
59
+ == Known Issues
60
+ === BSD
61
+ A kvm interface is used. That means the owner of the process using the
62
+ sys-proctable library needs to be a member of the kvm group (or root).
64
63
 
65
64
  === Solaris
66
65
  The cmdline member on Solaris is limited to 80 characters unless you (or
@@ -75,27 +74,19 @@
75
74
  Proc::ProcessTable module. You can find that module on CPAN. Point your
76
75
  browser at http://search.cpan.org.
77
76
 
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
77
  === 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
78
+ I am not currently using a thread-safe version of readdir(). I am not
79
+ especially concerned about it either. If you are trying to read information
89
80
  out of /proc from different threads at the same time there is something
90
81
  seriously wrong with your code logic. Using readdir_r() still won't solve
91
82
  all potential thread safety issues anyway.
92
83
 
93
- = Future Plans
84
+ == Future Plans
94
85
  Research has indicated that the kvm approach is less favored than a sysctl
95
86
  approach on BSD variants. I will try to add this interface in a future
96
87
  release.
97
88
 
98
- = Acknowledgements
89
+ == Acknowledgements
99
90
  This library is largely based on the Perl module Proc::ProcessTable by
100
91
  Dan Urist. Many ideas, as well as large chunks of code, were taken
101
92
  from his work. So, a big THANK YOU goes out to Dan Urist.
@@ -109,29 +100,27 @@
109
100
  Thanks go to James Hranicky for providing a patch that grabs name, eid,
110
101
  euid, gid and guid info in the Linux version, along with some general
111
102
  debugging help.
103
+
104
+ Thanks go to David Felstead for the original OS X code.
112
105
 
113
106
  Finally I'd like to thank all the folks who have submitted bug reports
114
107
  and/or patches.
115
108
 
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.
109
+ == Help Wanted
110
+ I do not have access to all platforms. If your platform is not supported
111
+ then you will need to either submit a patch or give me a remote account
112
+ on a box with a compiler so that I can write the code.
122
113
 
123
- = More documentation
114
+ == More documentation
124
115
  See the documentation under the 'doc' directory for more information,
125
116
  including platform specific notes and issues.
126
117
 
127
- = License
128
- Ruby's
118
+ == License
119
+ Artistic 2.0
129
120
 
130
- = Copyright
121
+ == Copyright
131
122
  (C) 2003-2009 Daniel J. Berger
132
123
  All Rights Reserved.
133
124
 
134
- = Author
125
+ == Author
135
126
  Daniel J. Berger
136
- djberg96 at nospam at gmail dot com
137
- imperator on IRC (Freenode)
@@ -0,0 +1,167 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+
6
+ desc 'Clean the build files for C versions of sys-proctable'
7
+ task :clean do
8
+ rm_rf('.test-result') if File.exists?('.test-result')
9
+ Dir['*.gem'].each{ |f| File.delete(f) }
10
+
11
+ case Config::CONFIG['host_os']
12
+ when /bsd/i
13
+ dir = 'ext/bsd'
14
+ when /darwin/i
15
+ dir = 'ext/darwin'
16
+ when /hpux/i
17
+ dir = 'ext/hpux'
18
+ end
19
+
20
+ unless Config::CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|linux|sunos|solaris/i
21
+ Dir.chdir(dir) do
22
+ if Dir['*.o'].length > 0
23
+ sh 'make distclean'
24
+ Dir['sys/proctable.*'].each{ |f| rm(f) if File.extname(f) != '.c' }
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ desc 'Build the sys-proctable library for C versions of sys-proctable'
31
+ task :build => [:clean] do
32
+ case Config::CONFIG['host_os']
33
+ when /bsd/i
34
+ dir = 'ext/bsd'
35
+ when /darwin/i
36
+ dir = 'ext/darwin'
37
+ when /hpux/i
38
+ dir = 'ext/hpux'
39
+ end
40
+
41
+ unless Config::CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|linux|sunos|solaris/i
42
+ Dir.chdir(dir) do
43
+ ruby 'extconf.rb'
44
+ sh 'make'
45
+ cp 'proctable.' + Config::CONFIG['DLEXT'], 'sys'
46
+ end
47
+ end
48
+ end
49
+
50
+ desc 'Install the sys-proctable library'
51
+ task :install => [:build] do
52
+ file = nil
53
+ dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
54
+
55
+ Dir.mkdir(dir) unless File.exists?(dir)
56
+
57
+ case Config::CONFIG['host_os']
58
+ when /mswin|win32|msdos|cygwin|mingw/i
59
+ file = 'lib/windows/sys/proctable.rb'
60
+ when /linux/i
61
+ file = 'lib/linux/sys/proctable.rb'
62
+ when /sunos|solaris/i
63
+ file = 'lib/sunos/sys/proctable.rb'
64
+ when /bsd/i
65
+ Dir.chdir('ext/bsd'){ sh 'make install' }
66
+ when /darwin/i
67
+ Dir.chdir('ext/darwin'){ sh 'make install' }
68
+ when /hpux/i
69
+ Dir.chdir('ext/hpux'){ sh 'make install' }
70
+ end
71
+
72
+ cp(file, dir, :verbose => true) if file
73
+ end
74
+
75
+ desc 'Uninstall the sys-proctable library'
76
+ task :uninstall do
77
+ case Config::CONFIG['host_os']
78
+ when /win32|mswin|dos|cygwin|mingw|linux|sunos|solaris/i
79
+ dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
80
+ file = File.join(dir, 'proctable.rb')
81
+ else
82
+ dir = File.join(Config::CONFIG['sitearchdir'], 'sys')
83
+ file = File.join(dir, 'proctable.' + Config::CONFIG['DLEXT'])
84
+ end
85
+
86
+ rm(file)
87
+ end
88
+
89
+ desc 'Run the benchmark suite'
90
+ task :bench => [:build] do
91
+ sh "ruby -Ilib benchmarks/bench_ps.rb"
92
+ end
93
+
94
+ desc 'Run the example program'
95
+ task :example => [:build] do
96
+ sh 'ruby -Ilib -Iext examples/example_ps.rb'
97
+ end
98
+
99
+ desc 'Run the test suite'
100
+ Rake::TestTask.new do |t|
101
+ task :test => :build
102
+ t.libs << 'test'
103
+
104
+ case Config::CONFIG['host_os']
105
+ when /mswin|msdos|cygwin|mingw/i
106
+ t.test_files = FileList['test/test_sys_proctable_windows.rb']
107
+ t.libs << 'lib/windows'
108
+ when /linux/i
109
+ t.test_files = FileList['test/test_sys_proctable_linux.rb']
110
+ t.libs << 'lib/linux'
111
+ when /sunos|solaris/i
112
+ t.test_files = FileList['test/test_sys_proctable_sunos.rb']
113
+ t.libs << 'lib/sunos'
114
+ when /darwin/i
115
+ t.libs << 'ext/darwin'
116
+ t.test_files = FileList['test/test_sys_proctable_darwin.rb']
117
+ when /bsd/i
118
+ t.libs << 'ext/bsd'
119
+ t.test_files = FileList['test/test_sys_proctable_bsd.rb']
120
+ when /hpux/i
121
+ t.libs << 'ext/hpux'
122
+ t.test_files = FileList['test/test_sys_proctable_hpux.rb']
123
+ end
124
+ end
125
+
126
+ desc 'Create a gem'
127
+ task :gem do
128
+ spec = eval(IO.read('sys-proctable.gemspec'))
129
+
130
+ case Config::CONFIG['host_os']
131
+ when /bsd/i
132
+ spec.files << 'ext/bsd/sys/proctable.c'
133
+ spec.extra_rdoc_files << 'ext/bsd/sys/proctable.c'
134
+ spec.test_files << 'test/test_sys_proctable_bsd.rb'
135
+ spec.extensions = ['ext/bsd/extconf.rb']
136
+ when /darwin/i
137
+ spec.files << 'ext/darwin/sys/proctable.c'
138
+ spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
139
+ spec.test_files << 'test/test_sys_proctable_darwin.rb'
140
+ spec.extensions = ['ext/darwin/extconf.rb']
141
+ when /hpux/i
142
+ spec.files << 'ext/hpux/sys/proctable.c'
143
+ spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
144
+ spec.test_files << 'test/test_sys_proctable_hpux.rb'
145
+ spec.extensions = ['ext/hpux/extconf.rb']
146
+ when /linux/i
147
+ spec.require_paths = ['lib', 'lib/linux']
148
+ spec.files += ['lib/linux/sys/proctable.rb']
149
+ spec.test_files << 'test/test_sys_proctable_linux.rb'
150
+ when /sunos|solaris/i
151
+ spec.require_paths = ['lib', 'lib/sunos']
152
+ spec.files += ['lib/sunos/sys/proctable.rb']
153
+ spec.test_files << 'test/test_sys_proctable_sunos.rb'
154
+ when /mswin|win32|dos|cygwin|mingw/i
155
+ spec.require_paths = ['lib', 'lib/windows']
156
+ spec.files += ['lib/windows/sys/proctable.rb']
157
+ spec.test_files << 'test/test_sys_proctable_windows.rb'
158
+ end
159
+
160
+ Gem::Builder.new(spec).build
161
+ end
162
+
163
+ desc 'Install the sys-proctable library as a gem'
164
+ task :install_gem => [:gem] do
165
+ gem_name = Dir['*.gem'].first
166
+ sh "gem install #{gem_name}"
167
+ end
@@ -0,0 +1,21 @@
1
+ ########################################################################
2
+ # bench_ps.rb
3
+ #
4
+ # Benchmark program to show overall speed and compare the block form
5
+ # versus the non-block form. You should run this benchmark via the
6
+ # 'rake bench' Rake task.
7
+ ########################################################################
8
+ require 'benchmark'
9
+ require 'sys/proctable'
10
+
11
+ MAX = 10
12
+
13
+ Benchmark.bm do |bench|
14
+ bench.report("Block form"){
15
+ MAX.times{ Sys::ProcTable.ps{} }
16
+ }
17
+
18
+ bench.report("Non-block form"){
19
+ MAX.times{ Sys::ProcTable.ps }
20
+ }
21
+ end
@@ -7,9 +7,8 @@
7
7
 
8
8
  = Synopsis
9
9
  require "sys/top"
10
- include Sys
11
10
 
12
- Top.top(5).each{ |ps|
11
+ Sys::Top.top(5).each{ |ps|
13
12
  p ps
14
13
  }
15
14
 
@@ -18,7 +17,7 @@ VERSION
18
17
  Returns the version number of this package as a String.
19
18
 
20
19
  = Class Methods
21
- Top.top(number=10, field="pctcpu")
20
+ Sys::Top.top(number=10, field="pctcpu")
22
21
  Returns an array of ProcTableStruct's. The size of the array (i.e. the
23
22
  number of processes) that it returns is based on +number+, and sorted by
24
23
  +pctcpu+. By default, the size and field values are 10 and "pctcpu",
@@ -33,7 +32,7 @@ Top.top(number=10, field="pctcpu")
33
32
  http://www.rubyforge.org/projects/sysutils
34
33
 
35
34
  = License
36
- Ruby's
35
+ Artistic 2.0
37
36
 
38
37
  = Copyright
39
38
  (C) 2004-2009 Daniel J. Berger
@@ -45,6 +44,4 @@ Top.top(number=10, field="pctcpu")
45
44
  warranties of merchantability and fitness for a particular purpose.
46
45
 
47
46
  = Author
48
- Daniel J. Berger
49
- djberg96 at nospam at gmail dot com
50
- imperator on IRC (Freenode)
47
+ Daniel J. Berger
@@ -0,0 +1,20 @@
1
+ #######################################################################
2
+ # example_ps.rb
3
+ #
4
+ # Generic test program that demonstrates the use of ProcTable.ps. You
5
+ # can run this via the 'rake example' task.
6
+ #
7
+ # Modify as you see fit
8
+ #######################################################################
9
+ require 'sys/proctable'
10
+ include Sys
11
+
12
+ puts "VERSION: " + ProcTable::VERSION
13
+ sleep 2
14
+
15
+ ProcTable.ps{ |s|
16
+ ProcTable.fields.each{ |field|
17
+ puts "#{field}: " + s.send(field).to_s
18
+ }
19
+ puts '=' * 30
20
+ }
@@ -0,0 +1,14 @@
1
+ require 'mkmf'
2
+
3
+ have_type('rb_pid_t', 'ruby.h')
4
+
5
+ have_library('kvm')
6
+ have_func('kvm_openfiles')
7
+ have_struct_member('struct kinfo_proc', 'kp_proc', 'sys/user.h')
8
+ have_struct_member('struct kinfo_proc', 'kp_eproc', 'sys/user.h')
9
+ have_struct_member('struct kinfo_proc', 'u_kproc', 'sys/user.h')
10
+ have_struct_member('struct eproc', 'e_stats', 'sys/sysctl.h')
11
+ have_struct_member('struct eproc', 'p_oncpu', 'sys/sysctl.h')
12
+ have_struct_member('struct eproc', 'p_runtime', 'sys/sysctl.h')
13
+
14
+ create_makefile('sys/proctable', 'sys')
@@ -1,14 +1,10 @@
1
1
  /**********************************************************************
2
- * bsd.c
2
+ * proctable.c
3
3
  *
4
- * This is a generic kvm interface used by OpenBSD and NetBSD by
5
- * default, and by FreeBSD if /proc isn't mounted.
6
- *
7
- * It may also work on Solaris, but will probably _not_ work on OS X
8
- * because they've phased out /dev/mem and /dev/kmem.
4
+ * This is a generic kvm interface used by the various BSD flavors
5
+ * for the sys-proctable library.
9
6
  **********************************************************************/
10
7
  #include "ruby.h"
11
- #include "version.h"
12
8
  #include <kvm.h>
13
9
  #include <sys/param.h>
14
10
  #include <sys/stat.h>
@@ -16,6 +12,8 @@
16
12
  #include <sys/types.h>
17
13
  #include <sys/user.h>
18
14
 
15
+ #define SYS_PROCTABLE_VERSION "0.9.0"
16
+
19
17
  VALUE cProcTableError, sProcStruct;
20
18
 
21
19
  char* fields[] = {
@@ -274,7 +272,7 @@ void Init_proctable(){
274
272
  cProcTable = rb_define_class_under(mSys, "ProcTable", rb_cObject);
275
273
 
276
274
  /* The error typically raised if any of the ProcTable methods fail */
277
- cProcTableError = rb_define_class_under(cProcTable, "Error", rb_cObject);
275
+ cProcTableError = rb_define_class_under(cProcTable, "Error", rb_eStandardError);
278
276
 
279
277
  /* Singleton Methods */
280
278
 
@@ -286,7 +284,7 @@ void Init_proctable(){
286
284
 
287
285
  /* Constants */
288
286
 
289
- /* 0.8.1: The version of the sys-proctable library */
287
+ /* 0.9.0: The version of the sys-proctable library */
290
288
  rb_define_const(cProcTable, "VERSION", rb_str_new2(SYS_PROCTABLE_VERSION));
291
289
 
292
290
  /* Structures */
@@ -18,9 +18,11 @@ module Sys
18
18
  #
19
19
  def self.top(num=10, field='pctcpu')
20
20
  field = field.to_s if field.is_a?(Symbol)
21
+
22
+ windows = /mswin|win32|dos|cygwin|mingw/i
21
23
 
22
24
  # Sort by pid on Windows by default
23
- if Config::CONFIG['host_os'].match('mswin') && field == 'pctcpu'
25
+ if Config::CONFIG['host_os'].match(windows) && field == 'pctcpu'
24
26
  field = 'pid'
25
27
  end
26
28
 
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'rbconfig'
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'sys-proctable'
6
+ gem.version = '0.8.2'
7
+ gem.author = 'Daniel J. Berger'
8
+ gem.license = 'Artistic 2.0'
9
+ gem.email = 'djberg96@gmail.com'
10
+ gem.homepage = 'http://www.rubyforge.org/projects/sysutils'
11
+ gem.platform = Gem::Platform::CURRENT
12
+ gem.summary = 'An interface for providing process table information'
13
+ gem.has_rdoc = true
14
+ gem.test_files = ['test/test_sys_proctable_all.rb']
15
+
16
+ # Additional files for your platform are added by the 'rake gem' task.
17
+ gem.files = [
18
+ 'benchmarks/bench_ps.rb',
19
+ 'examples/example_ps.rb',
20
+ 'lib/sys/top.rb',
21
+ 'CHANGES',
22
+ 'MANIFEST',
23
+ 'Rakefile',
24
+ 'README',
25
+ 'sys-proctable.gemspec'
26
+ ]
27
+
28
+ gem.rubyforge_project = 'sysutils'
29
+ gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
30
+
31
+ gem.add_development_dependency('test-unit', '>= 2.0.3')
32
+
33
+ gem.description = <<-EOF
34
+ The sys-proctable library provides an interface for gathering information
35
+ about processes on your system, i.e. the process table. Most major
36
+ platforms are supported and, while different platforms may return
37
+ different information, the external interface is identical across
38
+ platforms.
39
+ EOF
40
+ end
@@ -23,7 +23,7 @@ class TC_ProcTable_All < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_version
26
- assert_equal('0.8.1', ProcTable::VERSION)
26
+ assert_equal('0.9.0', ProcTable::VERSION)
27
27
  end
28
28
 
29
29
  def test_fields
@@ -69,6 +69,11 @@ class TC_ProcTable_All < Test::Unit::TestCase
69
69
  def test_new_not_allowed
70
70
  assert_raise(NoMethodError){ Sys::ProcTable.new }
71
71
  end
72
+
73
+ def test_error_class_defined
74
+ assert_not_nil(Sys::ProcTable::Error)
75
+ assert_kind_of(StandardError, Sys::ProcTable::Error.new)
76
+ end
72
77
 
73
78
  def teardown
74
79
  @pid = nil
@@ -1,7 +1,8 @@
1
1
  ################################################################
2
- # test_sys_proctable_kvm.rb
2
+ # test_sys_proctable_bsd.rb
3
3
  #
4
- # Test suite for the BSD specific version of the kvm interface.
4
+ # Test suite for various BSD flavors for the sys-proctable
5
+ # library. You should run these tests via 'rake test'.
5
6
  ################################################################
6
7
  require 'rubygems'
7
8
  gem 'test-unit'
@@ -11,7 +12,7 @@ require 'sys/proctable'
11
12
  require 'test/test_sys_proctable_all'
12
13
  include Sys
13
14
 
14
- class TC_Sys_ProcTable_Kvm < Test::Unit::TestCase
15
+ class TC_Sys_ProcTable_BSD < Test::Unit::TestCase
15
16
  def self.startup
16
17
  @@fields = %w/
17
18
  pid ppid pgid ruid rgid comm state pctcpu oncpu ttynum ttydev
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: 0.8.1
4
+ version: 0.8.2
5
5
  platform: x86-freebsd-7
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,45 +9,46 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-08 00:00:00 -06:00
12
+ date: 2009-10-15 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: test-unit
17
- type: :runtime
17
+ type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.0.2
23
+ version: 2.0.3
24
24
  version:
25
- description: An interface for providing process table information
25
+ description: " The sys-proctable library provides an interface for gathering information\n about processes on your system, i.e. the process table. Most major\n platforms are supported and, while different platforms may return\n different information, the external interface is identical across\n platforms.\n"
26
26
  email: djberg96@gmail.com
27
27
  executables: []
28
28
 
29
29
  extensions:
30
- - ext/extconf.rb
30
+ - ext/bsd/extconf.rb
31
31
  extra_rdoc_files:
32
32
  - CHANGES
33
33
  - README
34
34
  - MANIFEST
35
35
  - doc/top.txt
36
- - ext/bsd/bsd.c
36
+ - ext/bsd/sys/proctable.c
37
37
  files:
38
+ - benchmarks/bench_ps.rb
39
+ - examples/example_ps.rb
38
40
  - lib/sys/top.rb
39
- - test/test_sys_proctable_all.rb
40
- - test/test_sys_proctable_kvm.rb
41
41
  - CHANGES
42
- - README
43
42
  - MANIFEST
43
+ - Rakefile
44
+ - README
45
+ - sys-proctable.gemspec
44
46
  - doc/top.txt
45
- - ext/bsd/bsd.c
46
- - ext/extconf.rb
47
- - ext/version.h
48
- - doc/freebsd.txt
47
+ - ext/bsd/sys/proctable.c
49
48
  has_rdoc: true
50
49
  homepage: http://www.rubyforge.org/projects/sysutils
50
+ licenses:
51
+ - Artistic 2.0
51
52
  post_install_message:
52
53
  rdoc_options: []
53
54
 
@@ -68,10 +69,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  requirements: []
69
70
 
70
71
  rubyforge_project: sysutils
71
- rubygems_version: 1.3.1
72
+ rubygems_version: 1.3.5
72
73
  signing_key:
73
- specification_version: 2
74
+ specification_version: 3
74
75
  summary: An interface for providing process table information
75
76
  test_files:
76
77
  - test/test_sys_proctable_all.rb
77
- - test/test_sys_proctable_kvm.rb
78
+ - test/test_sys_proctable_bsd.rb
@@ -1,91 +0,0 @@
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 if
6
- readable. Otherwise, a kvm approach is used.
7
-
8
- = Synopsis
9
- require 'sys/proctable'
10
- include Sys
11
-
12
- # Everything
13
- ProcTable.ps{ |p|
14
- puts p.pid.to_s
15
- puts p.comm
16
- ...
17
- }
18
-
19
- or
20
-
21
- # Just one process
22
- p = ProcTable.ps(2123)
23
- puts p.pid.to_s
24
- puts p.comm
25
- ...
26
-
27
- or
28
-
29
- # Return the results as an array of ProcTableStructs
30
- a = ProcTable.ps()
31
- a.each do |p|
32
- puts a.pid
33
- ...
34
- end
35
-
36
- = Constants
37
- VERSION
38
- Returns the current version number for this package (as a string).
39
-
40
- = Class Methods
41
- ProcTable.fields
42
- Returns an array of fields available on the current OS.
43
-
44
- ProcTable.ps(pid = nil)
45
- ProcTable.ps{ |s| ... }
46
- If no pid's or processes are included as arguments, in block form it
47
- returns a struct of type ProcTableStruct for every process in the proc
48
- table. Otherwise it returns an array of ProcTableStruct's.
49
-
50
- If a pid argument is provided, a single ProcTable struct is returned, or
51
- nil if the pid is not found.
52
-
53
- = Exception Classes
54
- ProcTable::Error < StandardError
55
- Raised if the /proc field is unreadable and/or unmounted.
56
-
57
- = Supported fields
58
- You can view the supported fields with the "fields()" class method.
59
-
60
- = Future Plans
61
- Add a pure-ruby version as an alternative
62
- Add support for other *BSD flavors
63
- Add ttydev info
64
- Add a sysctl version
65
-
66
- = Known Bugs
67
- The kvm version for FreeBSD 5.x does not support all of the fields that
68
- the 4.x version supports.
69
-
70
- If you find any other bugs please log them on the project
71
- page at http://www.rubyforge.org/projects/sysutils
72
-
73
- = License
74
- Ruby's
75
-
76
- = Copyright
77
- (C) 2003-2009 Daniel J. Berger
78
- All Rights Reserved
79
-
80
- = Warranty
81
- This package is provided "as is" and without any express or
82
- implied warranties, including, without limitation, the implied
83
- warranties of merchantability and fitness for a particular purpose
84
-
85
- = Author
86
- Daniel J. Berger
87
- djberg96 at nospam at gmail dot com
88
- imperator on IRC (Freenode)
89
-
90
- = See Also
91
- ps, proc
@@ -1,78 +0,0 @@
1
- #############################################################################
2
- # Installation script for sys-proctable.
3
- #
4
- # By running this file, it is assumed that you want a C extension, and not
5
- # a pure Ruby version. If you want a pure Ruby version (and you're on a
6
- # platform for which it's supported), run install.rb instead.
7
- #############################################################################
8
- require 'mkmf'
9
- require 'fileutils'
10
- require 'rbconfig'
11
-
12
- c_file = nil
13
- h_file = nil
14
-
15
- ########################################################################
16
- # Ruby 1.8.3 and later mandates the use of rb_pid_t over pid_t because
17
- # some libraries define their own pid_t. So, we check for that.
18
- ########################################################################
19
- have_type('rb_pid_t', 'ruby.h')
20
-
21
- ##########################################################################
22
- # Determine appropriate source files based on platform. Also, check for
23
- # certain header files and/or libraries on some platforms.
24
- #
25
- # FreeBSD has its own source file if /proc is mounted and contains data.
26
- # Otherwise it uses the kvm interface. All other BSD platforms always use
27
- # the kvm interface.
28
- ##########################################################################
29
- case Config::CONFIG['host_os']
30
- when /hpux/i
31
- c_file = 'hpux/hpux.c'
32
- h_file = 'hpux/hpux.h'
33
- when /bsd/i
34
- if Config::CONFIG['host_os'].match('freebsd') && Dir['/proc/*'].length > 0
35
- c_file = 'freebsd/freebsd.c'
36
- h_file = 'freebsd/freebsd.h'
37
- else
38
- have_library('kvm')
39
- have_func('kvm_openfiles')
40
- have_struct_member('struct kinfo_proc', 'kp_proc', 'sys/user.h')
41
- have_struct_member('struct kinfo_proc', 'kp_eproc', 'sys/user.h')
42
- have_struct_member('struct kinfo_proc', 'u_kproc', 'sys/user.h')
43
- have_struct_member('struct eproc', 'e_stats', 'sys/sysctl.h')
44
- have_struct_member('struct eproc', 'p_oncpu', 'sys/sysctl.h')
45
- have_struct_member('struct eproc', 'p_runtime', 'sys/sysctl.h')
46
- c_file = 'bsd/bsd.c'
47
- end
48
- when /darwin/i
49
- c_file = 'darwin/darwin.c'
50
- when /windows|mswin|cygwin|mingw|dos|linux|sunos|solaris/i
51
- STDERR.puts "Use the 'rake install' task to install pure Ruby versions"
52
- exit
53
- else
54
- STDERR.puts 'This platform not currently supported. Exiting...'
55
- exit
56
- end
57
-
58
- #####################################################################
59
- # Move the '.rb' files under 'lib/sys/' to '.orig' to prevent
60
- # mkmf from installing them during the 'make install' phase.
61
- #####################################################################
62
- Dir.chdir("../lib/sys"){
63
- Dir["*.rb"].each{ |file|
64
- next if file == 'top.rb'
65
- File.rename(file, File.basename(file, '.rb') + '.orig')
66
- }
67
- }
68
-
69
- ########################################################################
70
- # Copy or link files to current directory for create_makefile to work.
71
- ########################################################################
72
- File.delete('proctable.c') rescue nil
73
- File.delete(File.basename(h_file)) rescue nil
74
-
75
- FileUtils.cp(c_file, 'proctable.c')
76
- FileUtils.cp(h_file, File.basename(h_file)) if h_file
77
-
78
- create_makefile('sys/proctable')
@@ -1,2 +0,0 @@
1
- /* version.h - stores the version number for all platforms (that use C) */
2
- #define SYS_PROCTABLE_VERSION "0.8.1"