-
-
Save youqingkui/6b43b43460df7df164299cf05076611c to your computer and use it in GitHub Desktop.
Revisions
-
582033 created this gist
Jun 28, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- ''' 显示树莓派cpu温度、使用率及内存使用率 ''' import os def show_temp(): file = open("/sys/class/thermal/thermal_zone0/temp") temp = float(file.read()) / 1000 file.close() print "Temp: %.1f ℃" %temp def show_mem(): mem_cmd = "free -m | grep Mem | awk '{print ($4+$6)/$2}'" mem_sur = round(float(os.popen(mem_cmd).read()), 2) * 100 print "Mem: %d%%" % mem_sur def show_cpu(): cpu_cmd = "uptime | awk '{print $8,$9,$10,$11,$12}'" cpu_used = os.popen(cpu_cmd).read() print "Cpu: %s" % cpu_used.replace('\n', '') if __name__ == '__main__': show_temp() show_cpu() show_mem()