Commit 290ce5d5 by Eva Charlotte Mayer Committed by Stéphane Graber

Fix swap calculation

parent 37bb2dd9
......@@ -284,8 +284,10 @@ def get_containers(fd=None, base="/", root=False):
memory_ram = 0
try:
memory_swap = int(container.get_cgroup_item(
"memory.memsw.usage_in_bytes")) - memory_ram
memory_stat = container.get_cgroup_item("memory.stat")
beg = memory_stat.find("\nswap ") + 6
end = memory_stat[beg:].find("\n") + len(memory_stat[:beg])
memory_swap = int(memory_stat[beg:end])
except:
memory_swap = 0
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment