Created
April 11, 2019 09:11
-
-
Save robie2011/e037937fc86cf66ee2e50db7a42269bb to your computer and use it in GitHub Desktop.
Memory Usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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