sys-proctable 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +209 -0
- data/README +68 -0
- data/doc/freebsd.txt +101 -0
- data/doc/hpux.txt +90 -0
- data/doc/linux.txt +101 -0
- data/doc/solaris.txt +120 -0
- data/doc/top.txt +54 -0
- data/doc/windows.txt +122 -0
- data/extconf.rb +104 -0
- data/lib/os/linux.c +315 -0
- data/lib/os/linux.h +138 -0
- data/lib/version.h +2 -0
- data/test/tc_all.rb +69 -0
- data/test/tc_freebsd.rb +60 -0
- data/test/tc_hpux.rb +64 -0
- data/test/tc_kvm_bsd.rb +40 -0
- data/test/tc_linux.rb +61 -0
- data/test/tc_sunos.rb +65 -0
- data/test/tc_top.rb +37 -0
- data/test/tc_windows.rb +51 -0
- data/test/test.rb +70 -0
- data/test/test_memleak.rb +54 -0
- metadata +68 -0
data/test/test.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
########################################################
|
2
|
+
# test.rb
|
3
|
+
#
|
4
|
+
# Generic test script for folks without TestUnit, or
|
5
|
+
# for general futzing.
|
6
|
+
########################################################
|
7
|
+
if File.basename(Dir.pwd) == "test"
|
8
|
+
require "ftools"
|
9
|
+
Dir.chdir ".."
|
10
|
+
$:.unshift Dir.pwd
|
11
|
+
|
12
|
+
begin
|
13
|
+
Dir.mkdir("sys") unless File.exists?("sys")
|
14
|
+
rescue Exception => e
|
15
|
+
STDERR.puts "Problem creating 'sys' directory. Exiting..."
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
extension = ".so"
|
20
|
+
extension = ".sl" if RUBY_PLATFORM =~ /hpux/i
|
21
|
+
extension = ".bundle" if RUBY_PLATFORM =~ /powerpc|darwin|mac/i
|
22
|
+
|
23
|
+
object_file = "proctable" + extension
|
24
|
+
|
25
|
+
# Alter as desired
|
26
|
+
if File::ALT_SEPARATOR
|
27
|
+
pure = "lib/os/windows.rb" # Comment this out to use C extension
|
28
|
+
#pure = object_file # Uncomment this to use C extension
|
29
|
+
begin
|
30
|
+
File.copy(pure,"sys/proctable.rb") # Comment out to use C
|
31
|
+
#File.copy(pure,"sys") # Uncomment to use C
|
32
|
+
rescue Exception => e
|
33
|
+
puts "Problem copying #{pure} file: #{e}"
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
else
|
37
|
+
begin
|
38
|
+
File.copy(object_file,'sys/')
|
39
|
+
rescue Exception => e
|
40
|
+
puts "Problem copying #{object_file} file: #{e}"
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
require "sys/proctable"
|
48
|
+
include Sys
|
49
|
+
|
50
|
+
puts 'VERSION: ' + ProcTable::VERSION
|
51
|
+
puts 'Fields: ' + ProcTable.fields.join("\n")
|
52
|
+
|
53
|
+
puts "-" * 30
|
54
|
+
sleep 1
|
55
|
+
|
56
|
+
ProcTable.ps{ |s|
|
57
|
+
ProcTable.fields{ |f|
|
58
|
+
if f == "environ"
|
59
|
+
puts "#{f}:"
|
60
|
+
s.send(f).each{ |k,v|
|
61
|
+
puts "\t#{k} => #{v}"
|
62
|
+
}
|
63
|
+
else
|
64
|
+
puts "#{f}: [" + s.send(f).to_s + "]"
|
65
|
+
end
|
66
|
+
}
|
67
|
+
puts '=' * 30
|
68
|
+
}
|
69
|
+
|
70
|
+
puts "Finished"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
##########################################################
|
2
|
+
# test_memleak.rb
|
3
|
+
#
|
4
|
+
# Test script to check for memory leaks. For now, it is
|
5
|
+
# only supported on Linux.
|
6
|
+
##########################################################
|
7
|
+
unless PLATFORM =~ /linux/i
|
8
|
+
puts "This program is currently only supported on Linux"
|
9
|
+
puts "Exiting program"
|
10
|
+
exit!
|
11
|
+
end
|
12
|
+
|
13
|
+
base = File.basename(Dir.pwd)
|
14
|
+
if base == "test" || base =~ /^sys-proctable.*/
|
15
|
+
require "ftools"
|
16
|
+
Dir.chdir("..") if base == "test"
|
17
|
+
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
+
File.delete("sys/proctable.so") rescue nil
|
19
|
+
Dir.mkdir("sys") rescue nil
|
20
|
+
File.copy("proctable.so","sys")
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
require "sys/proctable"
|
25
|
+
include Sys
|
26
|
+
|
27
|
+
pid = Process.pid
|
28
|
+
fd_file = "/proc/#{pid}/fd/*"
|
29
|
+
|
30
|
+
initial_fd = 0 # initial number of file descriptors
|
31
|
+
found = false
|
32
|
+
|
33
|
+
puts "ProcTable VERSION: " + ProcTable::VERSION
|
34
|
+
|
35
|
+
0.upto(50){ |n|
|
36
|
+
ProcTable.ps
|
37
|
+
if 0 == n
|
38
|
+
initial_fd = Dir[fd_file].length + 1 # one fd margin of error
|
39
|
+
puts "Initial file descriptors in use: #{initial_fd - 1}"
|
40
|
+
else
|
41
|
+
current_fd = Dir[fd_file].length
|
42
|
+
if current_fd > initial_fd
|
43
|
+
puts "Possible memory leak. FD count now up to #{current_fd}"
|
44
|
+
found = true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
}
|
48
|
+
|
49
|
+
if found
|
50
|
+
puts "You appear to have a file descriptor issue"
|
51
|
+
puts "After 50 iterations you had #{n} file descriptors open"
|
52
|
+
else
|
53
|
+
puts "No apparent fd leaks"
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: sys-proctable
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.7.3
|
7
|
+
date: 2006-08-01 00:00:00 -06:00
|
8
|
+
summary: An interface for providing process table information
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: djberg96@gmail.com
|
12
|
+
homepage: http://www.rubyforge.org/projects/sysutils
|
13
|
+
rubyforge_project: sysutils
|
14
|
+
description: An interface for providing process table information
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Daniel J. Berger
|
31
|
+
files:
|
32
|
+
- doc/freebsd.txt
|
33
|
+
- doc/top.txt
|
34
|
+
- doc/solaris.txt
|
35
|
+
- doc/windows.txt
|
36
|
+
- doc/hpux.txt
|
37
|
+
- doc/linux.txt
|
38
|
+
- test/tc_linux.rb
|
39
|
+
- test/tc_sunos.rb
|
40
|
+
- test/tc_kvm_bsd.rb
|
41
|
+
- test/tc_hpux.rb
|
42
|
+
- test/tc_windows.rb
|
43
|
+
- test/test.rb
|
44
|
+
- test/test_memleak.rb
|
45
|
+
- test/tc_all.rb
|
46
|
+
- test/tc_freebsd.rb
|
47
|
+
- test/tc_top.rb
|
48
|
+
- CHANGES
|
49
|
+
- README
|
50
|
+
- extconf.rb
|
51
|
+
- lib/version.h
|
52
|
+
- lib/os/linux.c
|
53
|
+
- lib/os/linux.h
|
54
|
+
test_files: []
|
55
|
+
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
extra_rdoc_files:
|
59
|
+
- CHANGES
|
60
|
+
- README
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions:
|
64
|
+
- extconf.rb
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
dependencies: []
|
68
|
+
|