|
|
@ -13,7 +13,7 @@ import os
|
|
|
|
from collections import deque
|
|
|
|
from collections import deque
|
|
|
|
from urllib.parse import urlparse, parse_qs
|
|
|
|
from urllib.parse import urlparse, parse_qs
|
|
|
|
from ansi2html import Ansi2HTMLConverter
|
|
|
|
from ansi2html import Ansi2HTMLConverter
|
|
|
|
from gpiozero import CPUTemperature
|
|
|
|
#from gpiozero import CPUTemperature
|
|
|
|
from os import popen
|
|
|
|
from os import popen
|
|
|
|
import psutil
|
|
|
|
import psutil
|
|
|
|
|
|
|
|
|
|
|
@ -112,9 +112,21 @@ def view_log(websocket, path):
|
|
|
|
yield from asyncio.sleep(0.2)
|
|
|
|
yield from asyncio.sleep(0.2)
|
|
|
|
elif path == "/SYSINFO":
|
|
|
|
elif path == "/SYSINFO":
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
cpu = CPUTemperature()
|
|
|
|
# cpu = CPUTemperature()
|
|
|
|
f = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
|
|
|
|
# cpu_temp = psutil.sensors_temperatures()
|
|
|
|
cpufrq = str((int(f.read()) / 1000))
|
|
|
|
cpu_temp = ""
|
|
|
|
|
|
|
|
temps = psutil.sensors_temperatures()
|
|
|
|
|
|
|
|
if not temps:
|
|
|
|
|
|
|
|
cpu_temp = "N/A"
|
|
|
|
|
|
|
|
for name, entries in temps.items():
|
|
|
|
|
|
|
|
for entry in entries:
|
|
|
|
|
|
|
|
cpu_temp = str(entry.current)
|
|
|
|
|
|
|
|
# f = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
|
|
|
|
|
|
|
|
cpufrqs = psutil.cpu_freq()
|
|
|
|
|
|
|
|
cpufrq = "N/A"
|
|
|
|
|
|
|
|
if cpufrqs:
|
|
|
|
|
|
|
|
cpufrq = str(cpufrqs.current)
|
|
|
|
|
|
|
|
# cpufrq = str((int(f.read()) / 1000))
|
|
|
|
cpu_usage = str(psutil.cpu_percent())
|
|
|
|
cpu_usage = str(psutil.cpu_percent())
|
|
|
|
cpu_load = os.getloadavg();
|
|
|
|
cpu_load = os.getloadavg();
|
|
|
|
cpu_load1 = str(cpu_load[0])
|
|
|
|
cpu_load1 = str(cpu_load[0])
|
|
|
@ -132,7 +144,8 @@ def view_log(websocket, path):
|
|
|
|
disk_used = str(disk.used / 2**30)
|
|
|
|
disk_used = str(disk.used / 2**30)
|
|
|
|
disk_free = str(disk.free / 2**30)
|
|
|
|
disk_free = str(disk.free / 2**30)
|
|
|
|
disk_percent_used = str(disk.percent)
|
|
|
|
disk_percent_used = str(disk.percent)
|
|
|
|
yield from websocket.send("SYSINFO: cputemp:" + str(cpu.temperature) + " cpufrg:" + cpufrq + " cpuusage:" + cpu_usage + " cpu_load1:" + cpu_load1 + " cpu_load5:" + cpu_load5 + " cpu_load15:" + cpu_load15 + " ram_total:" + ram_total + " ram_used:" + ram_used + " ram_free:" + ram_free + " ram_percent_used:" + ram_percent_used + " disk_total:" + disk_total + " disk_used:" + disk_used + " disk_free:" + disk_free + " disk_percent_used:" + disk_percent_used)
|
|
|
|
yield from websocket.send("SYSINFO: cputemp:" + cpu_temp + " cpufrg:" + cpufrq + " cpuusage:" + cpu_usage + " cpu_load1:" + cpu_load1 + " cpu_load5:" + cpu_load5 + " cpu_load15:" + cpu_load15 + " ram_total:" + ram_total + " ram_used:" + ram_used + " ram_free:" + ram_free + " ram_percent_used:" + ram_percent_used + " disk_total:" + disk_total + " disk_used:" + disk_used + " disk_free:" + disk_free + " disk_percent_used:" + disk_percent_used)
|
|
|
|
|
|
|
|
# yield from websocket.send("SYSINFO: cputemp:" + str(cpu.temperature) + " cpufrg:" + cpufrq + " cpuusage:" + cpu_usage + " cpu_load1:" + cpu_load1 + " cpu_load5:" + cpu_load5 + " cpu_load15:" + cpu_load15 + " ram_total:" + ram_total + " ram_used:" + ram_used + " ram_free:" + ram_free + " ram_percent_used:" + ram_percent_used + " disk_total:" + disk_total + " disk_used:" + disk_used + " disk_free:" + disk_free + " disk_percent_used:" + disk_percent_used)
|
|
|
|
yield from asyncio.sleep(10)
|
|
|
|
yield from asyncio.sleep(10)
|
|
|
|
|
|
|
|
|
|
|
|
except ValueError as e:
|
|
|
|
except ValueError as e:
|
|
|
|