-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinfo.py
executable file
·39 lines (28 loc) · 925 Bytes
/
info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3
import psutil
def get_cpu_tempfunc():
""" Return CPU temperature """
result = 0
mypath = "/sys/class/thermal/thermal_zone0/temp"
with open(mypath, 'r') as mytmpfile:
for line in mytmpfile:
result = line
result = float(result)/1000
result = round(result, 1)
return str(result)
def get_gpu_tempfunc():
""" Return GPU temperature as a character string"""
res = os.popen('/opt/vc/bin/vcgencmd measure_temp').readline()
return res.replace("temp=", "")
def get_cpu_use():
""" Return CPU usage using psutil"""
cpu_cent = psutil.cpu_percent()
return str(cpu_cent)
def get_ram_info():
""" Return RAM usage using psutil """
ram_cent = psutil.virtual_memory()[2]
return str(ram_cent)
def get_swap_info():
""" Return swap memory usage using psutil """
swap_cent = psutil.swap_memory()[3]
return str(swap_cent)