sys-proctable 0.9.9-universal-linux → 1.0.0-universal-linux
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES +4 -0
- data/README +1 -1
- data/Rakefile +1 -1
- data/lib/linux/sys/proctable.rb +10 -1
- data/lib/linux/sys/proctable/cgroup_entry.rb +1 -1
- data/lib/linux/sys/proctable/smaps.rb +118 -0
- data/lib/sys/proctable/version.rb +1 -1
- data/sys-proctable.gemspec +1 -1
- data/test/test_sys_proctable_all.rb +1 -1
- data/test/test_sys_proctable_linux.rb +6 -1
- metadata +4 -3
- 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: 6d0b0a05d36c394362b0da61c6996ee92c98f5cf
|
4
|
+
data.tar.gz: 6f93ad7718224d50c60010375a0d7fa72ab8df2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bbd13a460d6b1fa732b9a36466de419dc5f79c9d55b879d5949a77b6faf70b983cd0d4902705c3befdb984fcb02f86235c6d2a161152188a8a05344d8997686
|
7
|
+
data.tar.gz: b064d160df07a3734ddce2758bfefca86c7dd360e9de948e62b915592035479981fa13fc3e36b64addcebe65ae5cfd2a21841cd92ba4a1e44c2c022db7acd8fb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.0.0 - 11-Jan-2016
|
2
|
+
* Added smaps information for Linux. Thanks go to Joe Rafaniello for the patch.
|
3
|
+
* This is not really a major release. I just ran out of version numbers.
|
4
|
+
|
1
5
|
== 0.9.9 - 8-Nov-2015
|
2
6
|
* Added support for cgroups on Linux. Thanks go to Dennis Günnewig for the patch.
|
3
7
|
* Added a sys-proctable.rb file for convenience.
|
data/README
CHANGED
data/Rakefile
CHANGED
@@ -166,7 +166,7 @@ namespace :gem do
|
|
166
166
|
when /linux/i
|
167
167
|
spec.platform = Gem::Platform.new(['universal', 'linux'])
|
168
168
|
spec.require_paths = ['lib', 'lib/linux']
|
169
|
-
spec.files += ['lib/linux/sys/proctable.rb', 'lib/linux/sys/proctable/cgroup_entry.rb']
|
169
|
+
spec.files += ['lib/linux/sys/proctable.rb', 'lib/linux/sys/proctable/cgroup_entry.rb', 'lib/linux/sys/proctable/smaps.rb']
|
170
170
|
spec.test_files << 'test/test_sys_proctable_linux.rb'
|
171
171
|
when /sunos|solaris/i
|
172
172
|
spec.platform = Gem::Platform.new(['universal', 'solaris'])
|
data/lib/linux/sys/proctable.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sys/proctable/version'
|
2
2
|
require_relative 'proctable/cgroup_entry'
|
3
|
+
require_relative 'proctable/smaps'
|
3
4
|
|
4
5
|
# The Sys module serves as a namespace only.
|
5
6
|
module Sys
|
@@ -73,7 +74,8 @@ module Sys
|
|
73
74
|
'pctcpu', # Percent of CPU usage (custom field)
|
74
75
|
'pctmem', # Percent of Memory usage (custom field)
|
75
76
|
'nlwp', # Number of Light-Weight Processes associated with the process (threads)
|
76
|
-
'cgroup'
|
77
|
+
'cgroup', # Control groups to which the process belongs
|
78
|
+
'smaps' # Process memory size for all mapped files
|
77
79
|
]
|
78
80
|
|
79
81
|
public
|
@@ -169,6 +171,13 @@ module Sys
|
|
169
171
|
# Get control groups to which the process belongs
|
170
172
|
struct.cgroup = IO.readlines("/proc/#{file}/cgroup").map { |l| CgroupEntry.new(l) } rescue []
|
171
173
|
|
174
|
+
# Read smaps, returning a parsable string if we don't have permissions.
|
175
|
+
# Note: We're blindly rescuing because File.readable?/readable_real?
|
176
|
+
# are true for a file in the /proc fileystem but raises a ErrNo:EACCESS
|
177
|
+
# when your try to read it without permissions.
|
178
|
+
smaps_contents = IO.read("/proc/#{file}/smaps") rescue ""
|
179
|
+
struct.smaps = Smaps.new(file, smaps_contents)
|
180
|
+
|
172
181
|
# Deal with spaces in comm name. Courtesy of Ara Howard.
|
173
182
|
re = %r/\([^\)]+\)/
|
174
183
|
comm = stat[re]
|
@@ -3,7 +3,7 @@ module Sys
|
|
3
3
|
# This represents a cgroup entry
|
4
4
|
#
|
5
5
|
# Have a look at `man 5 proc` on a linux distribution, to get some more
|
6
|
-
# information about the lines and
|
6
|
+
# information about the lines and their fields in `/proc/[pid]/cgroup`.
|
7
7
|
#
|
8
8
|
# Example:
|
9
9
|
#
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module Sys
|
2
|
+
class ProcTable
|
3
|
+
# Smaps represents a process' memory size for all mapped files
|
4
|
+
#
|
5
|
+
# A single mapped file memory entry looks like this:
|
6
|
+
#
|
7
|
+
# 00400000-004d4000 r-xp 00000000 fd:00 785 /bin/bash
|
8
|
+
# Size: 848 kB
|
9
|
+
# Rss: 572 kB
|
10
|
+
# Pss: 572 kB
|
11
|
+
# Shared_Clean: 0 kB
|
12
|
+
# Shared_Dirty: 0 kB
|
13
|
+
# Private_Clean: 572 kB
|
14
|
+
# Private_Dirty: 0 kB
|
15
|
+
# Referenced: 572 kB
|
16
|
+
# Anonymous: 0 kB
|
17
|
+
# AnonHugePages: 0 kB
|
18
|
+
# Swap: 0 kB
|
19
|
+
# KernelPageSize: 4 kB
|
20
|
+
# MMUPageSize: 4 kB
|
21
|
+
#
|
22
|
+
# Have a look at `man 5 proc` on a linux distribution, to get some more
|
23
|
+
# information about the lines and fields in `/proc/[pid]/smaps`.
|
24
|
+
#
|
25
|
+
# Example:
|
26
|
+
#
|
27
|
+
# smaps = Smaps.new(123, IO.read("/proc/1234/smaps")
|
28
|
+
# => #<Sys::ProcTable::Smaps:0x007f8ac5930768 @pid=123, @pss=107000, @rss=368000, @uss=96000, @swap=192000, @vss=136752000>
|
29
|
+
# smaps.pss # => 109568
|
30
|
+
# smaps.rss # => 376832
|
31
|
+
# smaps.uss # => 98304
|
32
|
+
# smaps.swap # => 196608
|
33
|
+
# smaps.vss # => 140034048
|
34
|
+
#
|
35
|
+
class Smaps
|
36
|
+
|
37
|
+
# Process ID for this smaps
|
38
|
+
attr_reader :pid
|
39
|
+
|
40
|
+
# Proportional set size
|
41
|
+
#
|
42
|
+
# PSS is the size of private pages added to each shared mapping's size
|
43
|
+
# divided by the number of processes that share it. It is meant to
|
44
|
+
# provide a better representation of the amount of memory actually used
|
45
|
+
# by a process.
|
46
|
+
#
|
47
|
+
# If a process has 4k of private pages, 4k of shared pages shared with one
|
48
|
+
# other process, and 3k of pages shared with two other processes, the PSS
|
49
|
+
# is:
|
50
|
+
#
|
51
|
+
# 4k + (4k / 2) + (3k / 3) = 7k
|
52
|
+
#
|
53
|
+
attr_reader :pss
|
54
|
+
alias_method :proportional_set_size, :pss
|
55
|
+
|
56
|
+
# Resident set size
|
57
|
+
#
|
58
|
+
# RSS is the total size of all pages, shared or not, mapped to a process.
|
59
|
+
attr_reader :rss
|
60
|
+
alias_method :resident_set_size, :rss
|
61
|
+
|
62
|
+
# Unique set size
|
63
|
+
#
|
64
|
+
# USS is the total size of all private pages mapped to a process.
|
65
|
+
attr_reader :uss
|
66
|
+
alias_method :unique_set_size, :uss
|
67
|
+
|
68
|
+
# Swap
|
69
|
+
#
|
70
|
+
# Swap is the total size of all swapped pages mapped to a process.
|
71
|
+
attr_reader :swap
|
72
|
+
|
73
|
+
# Virtual set size
|
74
|
+
#
|
75
|
+
# VSS is the total accessible address space in a process. Since files are
|
76
|
+
# lazily loaded, this value represents the total size of all mapped files
|
77
|
+
# if they were all loaded.
|
78
|
+
attr_reader :vss
|
79
|
+
alias_method :virtual_set_size, :vss
|
80
|
+
|
81
|
+
# Create a new smaps object
|
82
|
+
#
|
83
|
+
#
|
84
|
+
# This expects a process id and a string containing the contents of
|
85
|
+
# /proc/PID/smaps - see `man 5 proc` for a reference.
|
86
|
+
#
|
87
|
+
# The smaps contents are parsed and memory sizes are calculated in bytes.
|
88
|
+
def initialize(pid, smaps_contents)
|
89
|
+
@pid = pid
|
90
|
+
@pss = 0
|
91
|
+
@rss = 0
|
92
|
+
@uss = 0
|
93
|
+
@swap = 0
|
94
|
+
@vss = 0
|
95
|
+
smaps_contents.each_line { |line| parse_smaps_line(line) }
|
96
|
+
end
|
97
|
+
|
98
|
+
alias_method :to_s, :inspect
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def parse_smaps_line(line)
|
103
|
+
case line
|
104
|
+
when /^Pss:\s+?(\d+)/
|
105
|
+
@pss += Regexp.last_match[1].to_i * 1000
|
106
|
+
when /^Rss:\s+?(\d+)/
|
107
|
+
@rss += Regexp.last_match[1].to_i * 1000
|
108
|
+
when /^Size:\s+?(\d+)/
|
109
|
+
@vss += Regexp.last_match[1].to_i * 1000
|
110
|
+
when /^Swap:\s+?(\d+)/
|
111
|
+
@swap += Regexp.last_match[1].to_i * 1000
|
112
|
+
when /^Private_(Clean|Dirty):\s+?(\d+)/
|
113
|
+
@uss += Regexp.last_match[2].to_i * 1000
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/sys-proctable.gemspec
CHANGED
@@ -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 cgroup
|
20
|
+
pctcpu pctmem nlwp cgroup smaps
|
21
21
|
/
|
22
22
|
end
|
23
23
|
|
@@ -301,6 +301,11 @@ class TC_ProcTable_Linux < Test::Unit::TestCase
|
|
301
301
|
assert_kind_of(ProcTable::CgroupEntry, @ptable.cgroup.first)
|
302
302
|
end
|
303
303
|
|
304
|
+
def test_smaps
|
305
|
+
assert_respond_to(@ptable, :smaps)
|
306
|
+
assert_kind_of(ProcTable::Smaps, @ptable.smaps)
|
307
|
+
end
|
308
|
+
|
304
309
|
def teardown
|
305
310
|
@ptable = nil
|
306
311
|
end
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: universal-linux
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
|
31
31
|
tGSHgAmcLlkdGgan182qsE/4kKM=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: test-unit
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- test/test_sys_proctable_all.rb
|
90
90
|
- lib/linux/sys/proctable.rb
|
91
91
|
- lib/linux/sys/proctable/cgroup_entry.rb
|
92
|
+
- lib/linux/sys/proctable/smaps.rb
|
92
93
|
homepage: http://github.com/djberg96/sys-proctable
|
93
94
|
licenses:
|
94
95
|
- Artistic 2.0
|
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
113
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.5.
|
114
|
+
rubygems_version: 2.5.1
|
114
115
|
signing_key:
|
115
116
|
specification_version: 4
|
116
117
|
summary: An interface for providing process table information
|
metadata.gz.sig
CHANGED
Binary file
|