get_process_mem 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/get_process_mem.rb +4 -6
- data/lib/get_process_mem/version.rb +1 -1
- data/test/get_process_mem_test.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d66e96644c3f8d171fd8533346150dc2a653badc
|
4
|
+
data.tar.gz: faaa15b6c510b50ced777bc2163042ac2934b9a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03f334783b312689fa9f7adcb28cd692285a2ffe181ebd5753662cb6b8b326249a57391beeea26a0198eddc2c86d8692f20bd70a02d8ab67c1d45be8bd6fc78d
|
7
|
+
data.tar.gz: 865fba383f18073a1bf9d7d9cfa543ad56e57544347aa3e8374899aea1f4144a8ddc7b66dc22f2762e94a55ce04970a5d9c865395577436058791bedaa87673a
|
data/CHANGELOG.md
CHANGED
data/lib/get_process_mem.rb
CHANGED
@@ -53,19 +53,19 @@ class GetProcessMem
|
|
53
53
|
|
54
54
|
# linux stores memory info in a file "/proc/#{pid}/smaps"
|
55
55
|
# If it's available it uses less resources than shelling out to ps
|
56
|
-
# It also allows us to use Pss (the process' proportional share of
|
57
|
-
# the mapping that is resident in RAM) as mem_type
|
58
56
|
def linux_memory(file = @process_file)
|
59
|
-
lines = file.each_line.select {|line| line.match /^
|
57
|
+
lines = file.each_line.select {|line| line.match /^Rss/ }
|
60
58
|
return if lines.empty?
|
61
59
|
lines.reduce(0) do |sum, line|
|
62
60
|
line.match(/(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/) do |m|
|
63
61
|
value = BigDecimal.new(m[:value]) + ROUND_UP
|
64
62
|
unit = m[:unit].downcase
|
65
|
-
sum
|
63
|
+
sum += CONVERSION[unit] * value
|
66
64
|
end
|
67
65
|
sum
|
68
66
|
end
|
67
|
+
rescue Errno::EACCES
|
68
|
+
0
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
@@ -76,5 +76,3 @@ class GetProcessMem
|
|
76
76
|
KB_TO_BYTE * BigDecimal.new(`ps -o rss= -p #{pid}`)
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
GetProcessMem
|
@@ -16,7 +16,7 @@ class GetProcessMemTest < Test::Unit::TestCase
|
|
16
16
|
def test_linux_smap
|
17
17
|
delta = 1
|
18
18
|
bytes = @mem.linux_memory(fixture_path("heroku-bash-smap"))
|
19
|
-
assert_in_delta BigDecimal.new("
|
19
|
+
assert_in_delta BigDecimal.new("2122240.0"), bytes, delta
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_conversions
|
@@ -44,4 +44,4 @@ class GetProcessMemTest < Test::Unit::TestCase
|
|
44
44
|
assert_in_delta 1024.0, @mem.mb(bytes), delta
|
45
45
|
assert_in_delta 1.0, @mem.gb(bytes), delta
|
46
46
|
end
|
47
|
-
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_process_mem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -71,3 +71,4 @@ test_files:
|
|
71
71
|
- test/fixtures/heroku-bash-smap
|
72
72
|
- test/get_process_mem_test.rb
|
73
73
|
- test/test_helper.rb
|
74
|
+
has_rdoc:
|