Skip to content

Commit

Permalink
Fix swap calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Eva Charlotte Mayer <eva-charlotte.mayer@posteo.de>
  • Loading branch information
ec-m committed Dec 23, 2015
1 parent 99d78dc commit 2948831
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lxc/lxc-ls.in
Expand Up @@ -311,8 +311,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:
Expand Down

0 comments on commit 2948831

Please sign in to comment.