Created
October 17, 2019 21:46
-
-
Save usuyama/3420762bd6f2919fa9f799b0b8fdbe4b to your computer and use it in GitHub Desktop.
print system memory usage Linux/Ubuntu Python
This file contains hidden or 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
def print_memory_usage(): | |
import os | |
lines = os.popen('free -t -m').readlines() | |
tot_m, used_m, free_m = map(int, lines[-1].split()[1:]) | |
for l in lines: | |
print(l.rstrip()) | |
return {'total_memory': tot_m, 'used_memory': used_m, 'free_memory': free_m} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment