Skip to content

Instantly share code, notes, and snippets.

@robie2011
Created April 11, 2019 09:11
Show Gist options
  • Save robie2011/e037937fc86cf66ee2e50db7a42269bb to your computer and use it in GitHub Desktop.
Save robie2011/e037937fc86cf66ee2e50db7a42269bb to your computer and use it in GitHub Desktop.
Memory Usage
import os
def get_memory_usage_in_kb():
memory_usage = os.popen("cat /proc/meminfo").read().split("\n")
infos = {}
for s in memory_usage:
if (s.strip() == ""):
continue
name, value = s.split(":")
infos[name] = int(value.strip().split(" ")[0])
return infos
m = get_memory_usage_in_kb()
for k in m.keys():
print(f"{k}: {m[k]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment