sys-proctable 0.7.6 → 1.2.0

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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -0
  4. data/CHANGES +165 -0
  5. data/MANIFEST +33 -41
  6. data/README +115 -135
  7. data/Rakefile +94 -0
  8. data/benchmarks/bench_ps.rb +21 -0
  9. data/doc/top.txt +5 -11
  10. data/examples/example_ps.rb +20 -0
  11. data/lib/aix/sys/proctable.rb +458 -0
  12. data/lib/darwin/sys/proctable.rb +363 -0
  13. data/lib/freebsd/sys/proctable.rb +363 -0
  14. data/lib/linux/sys/proctable.rb +314 -0
  15. data/lib/linux/sys/proctable/cgroup_entry.rb +50 -0
  16. data/lib/linux/sys/proctable/smaps.rb +118 -0
  17. data/lib/sunos/sys/proctable.rb +456 -0
  18. data/lib/sys-proctable.rb +1 -0
  19. data/lib/sys-top.rb +1 -0
  20. data/lib/sys/proctable.rb +18 -0
  21. data/lib/sys/proctable/version.rb +6 -0
  22. data/lib/sys/top.rb +28 -19
  23. data/lib/windows/sys/proctable.rb +208 -0
  24. data/spec/sys_proctable_aix_spec.rb +328 -0
  25. data/spec/sys_proctable_all_spec.rb +89 -0
  26. data/spec/sys_proctable_darwin_spec.rb +120 -0
  27. data/spec/sys_proctable_freebsd_spec.rb +210 -0
  28. data/spec/sys_proctable_linux_spec.rb +310 -0
  29. data/spec/sys_proctable_sunos_spec.rb +316 -0
  30. data/spec/sys_proctable_windows_spec.rb +317 -0
  31. data/spec/sys_top_spec.rb +51 -0
  32. data/sys-proctable.gemspec +38 -0
  33. metadata +140 -64
  34. metadata.gz.sig +0 -0
  35. data/doc/freebsd.txt +0 -90
  36. data/doc/hpux.txt +0 -77
  37. data/doc/linux.txt +0 -85
  38. data/doc/solaris.txt +0 -99
  39. data/doc/windows.txt +0 -122
  40. data/ext/extconf.rb +0 -98
  41. data/ext/sunos/sunos.c +0 -374
  42. data/ext/sunos/sunos.h +0 -177
  43. data/ext/version.h +0 -2
  44. data/test/tc_all.rb +0 -59
  45. data/test/tc_freebsd.rb +0 -45
  46. data/test/tc_hpux.rb +0 -49
  47. data/test/tc_kvm_bsd.rb +0 -31
  48. data/test/tc_linux.rb +0 -45
  49. data/test/tc_sunos.rb +0 -52
  50. data/test/tc_top.rb +0 -26
  51. data/test/tc_windows.rb +0 -40
  52. data/test/test_memleak.rb +0 -54
@@ -0,0 +1,51 @@
1
+ ##############################################################################
2
+ # sys_top_spec.rb
3
+ #
4
+ # Test suite for the sys-top library that is included with this distribution.
5
+ ##############################################################################
6
+ require 'rspec'
7
+ require 'sys/top'
8
+
9
+ describe Sys::Top do
10
+ context "constants" do
11
+ it "sets the version to the expected value" do
12
+ expect(Sys::Top::VERSION).to eql('1.0.5')
13
+ end
14
+ end
15
+
16
+ context "top" do
17
+ it "defines a top method" do
18
+ expect(described_class).to respond_to(:top)
19
+ end
20
+
21
+ it "returns an array" do
22
+ expect(described_class.top).to be_kind_of(Array)
23
+ end
24
+
25
+ it "works with no arguments" do
26
+ expect{ described_class.top }.to_not raise_error
27
+ end
28
+
29
+ it "accepts a maximum of two arguments" do
30
+ expect{ described_class.top(1, 'foo', 2) }.to raise_error(ArgumentError)
31
+ end
32
+
33
+ it "accepts optional arguments" do
34
+ expect{ described_class.top(5) }.to_not raise_error
35
+ expect{ described_class.top(5, 'cmdline') }.to_not raise_error
36
+ end
37
+
38
+ it "returns the expected results with no arguments" do
39
+ expect(described_class.top.size).to eql(10)
40
+ expect(described_class.top.first).to be_kind_of(Struct::ProcTableStruct)
41
+ end
42
+
43
+ it "returns the expected result with a size argument" do
44
+ expect(described_class.top(5).size).to eql(5)
45
+ end
46
+
47
+ it "returns the expected result with a size and sort_by argument" do
48
+ expect(described_class.top(5, :cmdline).size).to eql(5)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sys-proctable'
5
+ spec.version = '1.2.0'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.license = 'Apache 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://github.com/djberg96/sys-proctable'
10
+ spec.summary = 'An interface for providing process table information'
11
+ spec.test_files = FileList['spec/**/*.rb']
12
+ spec.cert_chain = ['certs/djberg96_pub.pem']
13
+
14
+ spec.files = FileList[
15
+ "benchmarks/**/*.rb",
16
+ "examples/**/*.rb",
17
+ "lib/**/*.rb",
18
+ 'CHANGES',
19
+ 'MANIFEST',
20
+ 'Rakefile',
21
+ 'README',
22
+ 'sys-proctable.gemspec'
23
+ ]
24
+
25
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
26
+
27
+ spec.add_dependency('ffi')
28
+ spec.add_development_dependency('rspec')
29
+ spec.add_development_dependency('rake')
30
+
31
+ spec.description = <<-EOF
32
+ The sys-proctable library provides an interface for gathering information
33
+ about processes on your system, i.e. the process table. Most major
34
+ platforms are supported and, while different platforms may return
35
+ different information, the external interface is identical across
36
+ platforms.
37
+ EOF
38
+ end
metadata CHANGED
@@ -1,73 +1,149 @@
1
- --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
1
+ --- !ruby/object:Gem::Specification
4
2
  name: sys-proctable
5
- version: !ruby/object:Gem::Version
6
- version: 0.7.6
7
- date: 2007-07-11 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:
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
- authors:
6
+ authors:
30
7
  - Daniel J. Berger
31
- files:
32
- - doc/freebsd.txt
33
- - doc/hpux.txt
34
- - doc/linux.txt
35
- - doc/solaris.txt
36
- - doc/top.txt
37
- - doc/windows.txt
38
- - test/tc_all.rb
39
- - test/tc_freebsd.rb
40
- - test/tc_hpux.rb
41
- - test/tc_kvm_bsd.rb
42
- - test/tc_linux.rb
43
- - test/tc_sunos.rb
44
- - test/tc_top.rb
45
- - test/tc_windows.rb
46
- - test/test_memleak.rb
47
- - lib/sys/top.rb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTE4MDIxOTIzMjIxMloXDTI4MDIxNzIzMjIxMlowPzERMA8GA1UEAwwIZGpi
16
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAOFYobQ3ovXNC4RexrdP
18
+ malr3eyK6lvQuS5DOQpHQrT3sRbrhAy5c2effNmznnUzDDGnHs+ZKkAeVmUDIi+K
19
+ lfXjV8uPEkLMXUpDndg9rbmQmfie07ixCdE9JYRPwfMTcE+jbtUyZqEUIg7XYmuJ
20
+ j28bgsq7I9SMOPS9I+3DiEK50NzGd1ixA+RW8yfApC0jU6KkBQBekETvgQ2OOEH+
21
+ RwoQqLQ2OpujQsmiofRyvpm3i8DNaQ5Awx7dnCrX9M98KxKHrBuAGARUQl6xh7nU
22
+ vebWtf6p348oBopTwav0fulZ7zF54B0zVWUTBwHP4q9ulOfHYjqUUfu6NixtNisd
23
+ Qv4Dp82Qi12aeTd4KGBlbnNHSM+SENKlOydE3+ROEUHK+G6LjccwxBHtFMCjCjaD
24
+ PAH4f+RtfeuBFUJDzQKrM4dfosVHnAoILL4jv4rJNDvkdj7TD2qF1MZblbhc2R5W
25
+ Ap4PN2gtzmPAyAe1PXf6dT/Jd2b4GNgxYXLCDOufZDviLQIDAQABo3cwdTAJBgNV
26
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUhSCp+aIknYPSqLCGAaPvJN4n
27
+ BZYwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
28
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAQCx5R3MfmTTZAd9+
29
+ RjqLjSzoaFEnqrhZCpuHzY9xEHmSldwHlzwLy60i4CHP7GySmlzTNZNJmPEG0ev5
30
+ YGXeRygkbN0x2pvCPdXHwcU4POTlM2JDntLIjWxNkOI9l9QNixuBrliqQ7UCMRkz
31
+ z+2K66CGGps2pGEPYU1hp0vjn4bQOyM1tPx5GothXvY5E8nd5mWuBjl3EmDLSIeC
32
+ AEA054SX5fumB3x83fLXQMl4Yw9nje/d8PkJgOUJOfCi5+P2I/YJ5YhjHpozvspN
33
+ cphsPbIxhkkKY+8YKXQRoHZPNuu0QdMHH6gvYTdjLmz9s4MICkp0Kg5UmWL96oCR
34
+ IZqb0JCjioPrrG3n/WV/ix5rPQ9MffHVPDFRD4wlbazwYn+A+KB0TxXJndHY9e6x
35
+ u7vZCyU93PFHpp/w270tu8VbayZSbmxF/oCsRuzWD0+xVsgLejqfWBbyGqwis995
36
+ p1I1Aujksa9wuoPhNNl8J4zKV1YtYorUDA44xq1iJEUE+ChB
37
+ -----END CERTIFICATE-----
38
+ date: 2018-02-20 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: ffi
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rake
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ description: |2
83
+ The sys-proctable library provides an interface for gathering information
84
+ about processes on your system, i.e. the process table. Most major
85
+ platforms are supported and, while different platforms may return
86
+ different information, the external interface is identical across
87
+ platforms.
88
+ email: djberg96@gmail.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files:
48
92
  - CHANGES
49
93
  - README
50
94
  - MANIFEST
51
- - ext/sunos/sunos.c
52
- - ext/extconf.rb
53
- - ext/version.h
54
- - ext/sunos/sunos.h
55
- test_files:
56
- - test/tc_sunos.rb
57
- rdoc_options: []
58
-
59
- extra_rdoc_files:
95
+ - doc/top.txt
96
+ files:
97
+ - benchmarks/bench_ps.rb
98
+ - examples/example_ps.rb
99
+ - lib/aix/sys/proctable.rb
100
+ - lib/darwin/sys/proctable.rb
101
+ - lib/freebsd/sys/proctable.rb
102
+ - lib/linux/sys/proctable.rb
103
+ - lib/linux/sys/proctable/cgroup_entry.rb
104
+ - lib/linux/sys/proctable/smaps.rb
105
+ - lib/sunos/sys/proctable.rb
106
+ - lib/sys-proctable.rb
107
+ - lib/sys-top.rb
108
+ - lib/sys/proctable.rb
109
+ - lib/sys/proctable/version.rb
110
+ - lib/sys/top.rb
111
+ - lib/windows/sys/proctable.rb
60
112
  - CHANGES
61
- - README
62
113
  - MANIFEST
63
- - doc/top.txt
64
- - doc/solaris.txt
65
- - ext/sunos/sunos.c
66
- executables: []
67
-
68
- extensions:
69
- - ext/extconf.rb
114
+ - Rakefile
115
+ - README
116
+ - sys-proctable.gemspec
117
+ homepage: http://github.com/djberg96/sys-proctable
118
+ licenses:
119
+ - Apache 2.0
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
70
135
  requirements: []
71
-
72
- dependencies: []
73
-
136
+ rubyforge_project:
137
+ rubygems_version: 2.6.11
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: An interface for providing process table information
141
+ test_files:
142
+ - spec/sys_proctable_aix_spec.rb
143
+ - spec/sys_proctable_all_spec.rb
144
+ - spec/sys_proctable_darwin_spec.rb
145
+ - spec/sys_proctable_freebsd_spec.rb
146
+ - spec/sys_proctable_linux_spec.rb
147
+ - spec/sys_proctable_sunos_spec.rb
148
+ - spec/sys_proctable_windows_spec.rb
149
+ - spec/sys_top_spec.rb
Binary file
@@ -1,90 +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.
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 an array of fields available on the current OS.
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-2006 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 nospam at gmail dot com
87
- imperator on IRC (Freenode)
88
-
89
- = See Also
90
- ps, proc
@@ -1,77 +0,0 @@
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 an array of fields available on the current OS.
34
-
35
- ProcTable.ps(pid=nil)
36
- ProcTable.ps{ |s| ... }
37
- Returns a struct of type ProcTableStruct for every process in the proc
38
- table in block form. Otherwise it returns an array of ProcTableStruct's.
39
-
40
- If a pid is provided then a single ProcTable struct is returned, or nil
41
- if the pid is not found.
42
-
43
- = Supported fields
44
- You can view the supported fields with the "fields()" class method.
45
-
46
- = Future Plans
47
- Have the flags field return a meaningful value.
48
-
49
- = Notes
50
- The "comm" field isn't really part of the psinfo struct. It is just a copy
51
- (i.e. is identical to) the "fname" field. I added it to provide a degree
52
- of consistency between all of the platforms. I will also make a point
53
- of adding it to any future platform releases.
54
-
55
- = Known Bugs
56
- None that I'm aware of. Please log any bugs on the project page at
57
- http://www.rubyforge.org/projects/sysutils
58
-
59
- = License
60
- Ruby's
61
-
62
- = Copyright
63
- (C) 2003-2006 Daniel J. Berger
64
- All Rights Reserved.
65
-
66
- = Warranty
67
- This package is provided "as is" and without any express or
68
- implied warranties, including, without limitation, the implied
69
- warranties of merchantability and fitness for a particular purpose.
70
-
71
- = Author
72
- Daniel J. Berger
73
- djberg96 at nospam at gmail dot com
74
- imperator on IRC (Freenode)
75
-
76
- = See Also
77
- ps, proc