# -*- coding: utf-8 -*
import psutil
import time
if __name__ == "__main__":
while(True):
memory_convent = 1024 * 1024
mem = psutil.virtual_memory()
print_str = " The memory state as follows:\n"
print_str = print_str + " System memory total: "+str( mem.total/( memory_convent ) ) + " MB\n"
print_str = print_str + " System memory used: "+str( mem.used/( memory_convent ) ) + " MB\n"
print_str = print_str + " System memory free: "+str( mem.total/( memory_convent ) - mem.used/( memory_convent )) + "MB\n"
# print_str = print_str + " System memory buffer: "+str( mem.buffers/( memory_convent ) ) + " MB\n"
# print_str = print_str + " System memory cache:" +str( mem.cached/( memory_convent ) ) + " MB\n"
a = (float)(mem.used/( memory_convent ))
b = (float)(mem.total/( memory_convent ))
c = "%.2f%%" % (a/b*100)
print_str = print_str + " Percentage:"+str( c )
print print_str
time.sleep(3)
05
2019
03
不间断获取树莓派内存信息监控脚本
作者:穆琪 | 分类:树莓派+Arduino | 浏览:350 | 评论:0