runger_stripmem 0.1.3 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/strip_mem/app.rb +9 -4
- data/lib/strip_mem/public/app.js +2 -2
- data/lib/strip_mem/version.rb +1 -1
- data/lib/strip_mem/web.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 245daf784fb56991d0a51737d0dfdccfc091f690f9bede4da82ad34c83e5f746
|
|
4
|
+
data.tar.gz: a1a6e09ea2af7fe6922329a5c444a8199d52b5b28cb95d94f0cd2a3d6df2ab60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5158980ef6193c7a35a84d0e984477493b4239bca187f1f5ef236dab6f02d1942471260b7793310c3f41a630ebabd8b0c5e00e608cd946bfbc59676c1579f8a
|
|
7
|
+
data.tar.gz: 9d86912ac61164199bbf6d828698e9366eddf99ec2a98eae7428e7e1ae21fffb41956f295893ec045f2c7b7153c86513332513bb9e01e041b21f8fcb427efa5a
|
data/README.md
CHANGED
|
@@ -4,6 +4,10 @@ Show a live chart of your process's memory usage.
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
+
## ⚠️ Linux only ⚠️
|
|
8
|
+
|
|
9
|
+
`runger_stripmem` reads process memory information directly from `/proc/<pid>/status` (specifically the `RssAnon` and `VmSwap` fields). These interfaces and fields are provided by the Linux kernel and do not exist on other operating systems (macOS, Windows, BSD, etc.). Because the gem depends on this Linux-specific memory accounting, `runger_stripmem` only works on Linux.
|
|
10
|
+
|
|
7
11
|
## Installation
|
|
8
12
|
|
|
9
13
|
To use `runger_stripmem` standalone, install it:
|
data/lib/strip_mem/app.rb
CHANGED
|
@@ -82,15 +82,20 @@ class StripMem::App
|
|
|
82
82
|
|
|
83
83
|
def ps(channel)
|
|
84
84
|
ps =
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
processes.keys.each_with_object({}) do |pid, h|
|
|
86
|
+
status = File.read("/proc/#{pid}/status")
|
|
87
|
+
anon = Integer(status[/^RssAnon:\s+(\d+)/, 1], 10) # kB (preferred)
|
|
88
|
+
swap = Integer(status[/^VmSwap:\s+(\d+)/, 1], 10) # kB
|
|
89
|
+
h[pid] = anon + swap
|
|
90
|
+
rescue Errno::ENOENT, Errno::EACCES
|
|
91
|
+
# process already gone or we lack permission
|
|
87
92
|
end
|
|
93
|
+
|
|
88
94
|
offset = Time.now - start_time
|
|
89
95
|
channel.push(
|
|
90
96
|
offset:,
|
|
91
|
-
|
|
92
97
|
samples: processes.map do |pid, name|
|
|
93
|
-
{ name: "[#{pid}] #{name}",
|
|
98
|
+
{ name: "[#{pid}] #{name}", anon_plus_swap: ps[pid] }
|
|
94
99
|
end,
|
|
95
100
|
)
|
|
96
101
|
end
|
data/lib/strip_mem/public/app.js
CHANGED
|
@@ -159,8 +159,8 @@ $(function() {
|
|
|
159
159
|
lastOffset = data.offset;
|
|
160
160
|
if (!chart)
|
|
161
161
|
chart = charts[sample.name] = new StripChart(d3.select('body'), sample.name);
|
|
162
|
-
if (sample.
|
|
163
|
-
chart.addPoint({x: data.offset, y: sample.
|
|
162
|
+
if (sample.anon_plus_swap)
|
|
163
|
+
chart.addPoint({x: data.offset, y: sample.anon_plus_swap});
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
|
data/lib/strip_mem/version.rb
CHANGED
data/lib/strip_mem/web.rb
CHANGED
|
@@ -9,7 +9,7 @@ class StripMem::Web
|
|
|
9
9
|
|
|
10
10
|
def run!
|
|
11
11
|
puts('Starting a server on http://localhost:9999/')
|
|
12
|
-
App.run!(port: 9999, server: 'puma') do
|
|
12
|
+
App.run!(port: 9999, server: 'puma', server_settings: { config_files: ['-'] }) do
|
|
13
13
|
system('open http://localhost:9999/')
|
|
14
14
|
end
|
|
15
15
|
end
|