sys-proctable 0.9.8-universal-linux → 0.9.9-universal-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/CHANGES +6 -0
- data/MANIFEST +1 -0
- data/Rakefile +30 -10
- data/lib/linux/sys/proctable.rb +6 -1
- data/lib/linux/sys/proctable/cgroup_entry.rb +50 -0
- data/lib/sys-proctable.rb +1 -0
- data/lib/sys/proctable/version.rb +1 -1
- data/sys-proctable.gemspec +2 -1
- data/test/test_sys_proctable_all.rb +1 -1
- data/test/test_sys_proctable_linux.rb +7 -1
- metadata +29 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f13537cd8a33add0739cb78526d05006bc6aa5
|
4
|
+
data.tar.gz: 18433abb3f9dd310603bc9633ec2d55e24025c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9824df5d678bb2cfc4aaa3f8fc202b0acca08d6498d9798b97e51e4b3d9a789e0417be6dcfc4c90cb0cc340a6a3f1b2906897864411a4fe7ff800cb3676da44
|
7
|
+
data.tar.gz: bef2ef2d8b351d42065327e10bcba67e0334d4a7dc758ba5d789754301382d9eab6fa4fa123bb7bf4db33f85e6b868b9c665e30e71c78f6a128295b09c36298f
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.9.9 - 8-Nov-2015
|
2
|
+
* Added support for cgroups on Linux. Thanks go to Dennis Günnewig for the patch.
|
3
|
+
* Added a sys-proctable.rb file for convenience.
|
4
|
+
* This gem is now signed.
|
5
|
+
* Gem related tasks in the Rakefile now assume Rubygems 2.x.
|
6
|
+
|
1
7
|
== 0.9.8 - 18-Apr-2015
|
2
8
|
* Fixed a bug in the gemspec. Last version got yanked.
|
3
9
|
|
data/MANIFEST
CHANGED
data/Rakefile
CHANGED
@@ -126,15 +126,25 @@ Rake::TestTask.new do |t|
|
|
126
126
|
end
|
127
127
|
|
128
128
|
namespace :gem do
|
129
|
-
desc 'Create a gem'
|
130
|
-
task :create => [:clean] do
|
129
|
+
desc 'Create a gem for the specified OS, or your current OS by default'
|
130
|
+
task :create, [:os] => [:clean] do |_task, args|
|
131
|
+
require 'rubygems/package'
|
132
|
+
|
133
|
+
if args.is_a?(String)
|
134
|
+
os = args
|
135
|
+
else
|
136
|
+
args.with_defaults(:os => CONFIG['host_os'])
|
137
|
+
os = args[:os]
|
138
|
+
end
|
139
|
+
|
131
140
|
spec = eval(IO.read('sys-proctable.gemspec'))
|
141
|
+
spec.files += ['lib/sys-proctable.rb']
|
132
142
|
|
133
143
|
# I've had to manually futz with the spec here in some cases
|
134
144
|
# in order to get the universal platform settings I want because
|
135
145
|
# of some bugginess in Rubygems' platform.rb.
|
136
146
|
#
|
137
|
-
case
|
147
|
+
case os
|
138
148
|
when /freebsd/i
|
139
149
|
spec.platform = Gem::Platform.new(['universal', 'freebsd'])
|
140
150
|
spec.require_paths = ['lib', 'lib/freebsd']
|
@@ -156,7 +166,7 @@ namespace :gem do
|
|
156
166
|
when /linux/i
|
157
167
|
spec.platform = Gem::Platform.new(['universal', 'linux'])
|
158
168
|
spec.require_paths = ['lib', 'lib/linux']
|
159
|
-
spec.files += ['lib/linux/sys/proctable.rb']
|
169
|
+
spec.files += ['lib/linux/sys/proctable.rb', 'lib/linux/sys/proctable/cgroup_entry.rb']
|
160
170
|
spec.test_files << 'test/test_sys_proctable_linux.rb'
|
161
171
|
when /sunos|solaris/i
|
162
172
|
spec.platform = Gem::Platform.new(['universal', 'solaris'])
|
@@ -173,6 +183,8 @@ namespace :gem do
|
|
173
183
|
spec.require_paths = ['lib', 'lib/windows']
|
174
184
|
spec.files += ['lib/windows/sys/proctable.rb']
|
175
185
|
spec.test_files << 'test/test_sys_proctable_windows.rb'
|
186
|
+
else
|
187
|
+
raise "Unsupported platform: #{os}"
|
176
188
|
end
|
177
189
|
|
178
190
|
spec.test_files << 'test/test_sys_top.rb'
|
@@ -180,12 +192,20 @@ namespace :gem do
|
|
180
192
|
# https://github.com/rubygems/rubygems/issues/147
|
181
193
|
spec.original_platform = spec.platform
|
182
194
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
195
|
+
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
196
|
+
|
197
|
+
Gem::Package.build(spec, true)
|
198
|
+
end
|
199
|
+
|
200
|
+
desc 'Create a gem for each supported OS'
|
201
|
+
task :create_all => [:clean] do
|
202
|
+
platforms = %w[aix darwin freebsd hpux linux solaris windows]
|
203
|
+
Rake::Task["clean"].execute
|
204
|
+
platforms.each{ |os|
|
205
|
+
FileUtils.mkdir_p("pkg/#{os}")
|
206
|
+
Rake::Task["gem:create"].execute(os)
|
207
|
+
Dir.glob("*.gem").each{ |gem| FileUtils.mv(gem, "pkg/#{os}") }
|
208
|
+
}
|
189
209
|
end
|
190
210
|
|
191
211
|
desc 'Install the sys-proctable library as a gem'
|
data/lib/linux/sys/proctable.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'sys/proctable/version'
|
2
|
+
require_relative 'proctable/cgroup_entry'
|
2
3
|
|
3
4
|
# The Sys module serves as a namespace only.
|
4
5
|
module Sys
|
@@ -71,7 +72,8 @@ module Sys
|
|
71
72
|
'egid', # Effective group ID
|
72
73
|
'pctcpu', # Percent of CPU usage (custom field)
|
73
74
|
'pctmem', # Percent of Memory usage (custom field)
|
74
|
-
'nlwp'
|
75
|
+
'nlwp', # Number of Light-Weight Processes associated with the process (threads)
|
76
|
+
'cgroup' # Control groups to which the process belongs
|
75
77
|
]
|
76
78
|
|
77
79
|
public
|
@@ -164,6 +166,9 @@ module Sys
|
|
164
166
|
# Every process has at least one thread, so if we fail to read the task directory, set nlwp to 1.
|
165
167
|
struct.nlwp = Dir.glob("/proc/#{file}/task/*").length rescue struct.nlwp = 1
|
166
168
|
|
169
|
+
# Get control groups to which the process belongs
|
170
|
+
struct.cgroup = IO.readlines("/proc/#{file}/cgroup").map { |l| CgroupEntry.new(l) } rescue []
|
171
|
+
|
167
172
|
# Deal with spaces in comm name. Courtesy of Ara Howard.
|
168
173
|
re = %r/\([^\)]+\)/
|
169
174
|
comm = stat[re]
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Sys
|
2
|
+
class ProcTable
|
3
|
+
# This represents a cgroup entry
|
4
|
+
#
|
5
|
+
# Have a look at `man 5 proc` on a linux distribution, to get some more
|
6
|
+
# information about the lines and there fields in `/proc/[pid]/cgroup`.
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# entry = CgroupEntry.new '7:devices:/init.scope'
|
11
|
+
# entry.hierarchy_id # => 7
|
12
|
+
# entry.subsystems # => ['devices']
|
13
|
+
# entry.control_group # => '/init.scope'
|
14
|
+
#
|
15
|
+
class CgroupEntry
|
16
|
+
# Create a new cgroup entry object
|
17
|
+
#
|
18
|
+
# This expects a string of '7:devices:/init.scope' - see `man 5 proc` for a
|
19
|
+
# reference.
|
20
|
+
def initialize(string)
|
21
|
+
@string = string.chomp
|
22
|
+
@fields = @string.split(/:/)
|
23
|
+
rescue
|
24
|
+
@fields = []
|
25
|
+
end
|
26
|
+
|
27
|
+
# This returns the hierarchy id of the cgroup entry
|
28
|
+
def hierarchy_id
|
29
|
+
@fields[0].to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return sets of subsystems bound to the hierarchy
|
33
|
+
def subsystems
|
34
|
+
@fields[1].split(/,/)
|
35
|
+
rescue
|
36
|
+
[]
|
37
|
+
end
|
38
|
+
|
39
|
+
# control group in the hierarchy to which the process belongs
|
40
|
+
def control_group
|
41
|
+
@fields[2]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Return the line itself
|
45
|
+
def to_s
|
46
|
+
@string
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sys/proctable'
|
data/sys-proctable.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-proctable'
|
5
|
-
spec.version = '0.9.
|
5
|
+
spec.version = '0.9.9'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.platform = Gem::Platform::CURRENT # Probably altered by Rake task
|
11
11
|
spec.summary = 'An interface for providing process table information'
|
12
12
|
spec.test_files = ['test/test_sys_proctable_all.rb']
|
13
|
+
spec.cert_chain = ['certs/djberg96_pub.pem']
|
13
14
|
|
14
15
|
# Additional files for your platform are added by the 'rake gem' task.
|
15
16
|
spec.files = [
|
@@ -17,7 +17,7 @@ class TC_ProcTable_Linux < Test::Unit::TestCase
|
|
17
17
|
stime cutime cstime priority nice itrealvalue starttime vsize
|
18
18
|
rss rlim startcode endcode startstack kstkesp kstkeip signal blocked
|
19
19
|
sigignore sigcatch wchan nswap cnswap exit_signal processor environ
|
20
|
-
pctcpu pctmem nlwp
|
20
|
+
pctcpu pctmem nlwp cgroup
|
21
21
|
/
|
22
22
|
end
|
23
23
|
|
@@ -295,6 +295,12 @@ class TC_ProcTable_Linux < Test::Unit::TestCase
|
|
295
295
|
assert_kind_of(Fixnum, @ptable.nlwp)
|
296
296
|
end
|
297
297
|
|
298
|
+
def test_cgroup
|
299
|
+
assert_respond_to(@ptable, :cgroup)
|
300
|
+
assert_kind_of(Array, @ptable.cgroup)
|
301
|
+
assert_kind_of(ProcTable::CgroupEntry, @ptable.cgroup.first)
|
302
|
+
end
|
303
|
+
|
298
304
|
def teardown
|
299
305
|
@ptable = nil
|
300
306
|
end
|
metadata
CHANGED
@@ -1,14 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-proctable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: universal-linux
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
|
14
|
+
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
+
MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
|
16
|
+
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
+
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
|
18
|
+
Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
|
19
|
+
S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
|
20
|
+
gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
|
21
|
+
FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
|
22
|
+
zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
|
23
|
+
DtkCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEwe
|
24
|
+
nn6bfJADmuIDiMSOzedOrL+xMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
|
25
|
+
bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
|
26
|
+
ggEBAHmNOCWoDVD75zHFueY0viwGDVP1BNGFC+yXcb7u2GlK+nEMCORqzURbYPf7
|
27
|
+
tL+/hzmePIRz7i30UM//64GI1NLv9jl7nIwjhPpXpf7/lu2I9hOTsvwSumb5UiKC
|
28
|
+
/sqBxI3sfj9pr79Wpv4MuikX1XPik7Ncb7NPsJPw06Lvyc3Hkg5X2XpPtLtS+Gr2
|
29
|
+
wKJnmzb5rIPS1cmsqv0M9LPWflzfwoZ/SpnmhagP+g05p8bRNKjZSA2iImM/GyYZ
|
30
|
+
EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
|
31
|
+
tGSHgAmcLlkdGgan182qsE/4kKM=
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-11-08 00:00:00.000000000 Z
|
12
34
|
dependencies:
|
13
35
|
- !ruby/object:Gem::Dependency
|
14
36
|
name: test-unit
|
@@ -60,13 +82,13 @@ files:
|
|
60
82
|
- benchmarks/bench_ps.rb
|
61
83
|
- doc/top.txt
|
62
84
|
- examples/example_ps.rb
|
63
|
-
- lib/
|
85
|
+
- lib/sys-proctable.rb
|
64
86
|
- lib/sys/proctable/version.rb
|
65
87
|
- lib/sys/top.rb
|
66
88
|
- sys-proctable.gemspec
|
67
89
|
- test/test_sys_proctable_all.rb
|
68
|
-
-
|
69
|
-
-
|
90
|
+
- lib/linux/sys/proctable.rb
|
91
|
+
- lib/linux/sys/proctable/cgroup_entry.rb
|
70
92
|
homepage: http://github.com/djberg96/sys-proctable
|
71
93
|
licenses:
|
72
94
|
- Artistic 2.0
|
@@ -88,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
110
|
version: '0'
|
89
111
|
requirements: []
|
90
112
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.5.0
|
92
114
|
signing_key:
|
93
115
|
specification_version: 4
|
94
116
|
summary: An interface for providing process table information
|
metadata.gz.sig
ADDED
Binary file
|