1
0
Fork 0

Make Sysinfo running on other linux

main
Kim Huebel 4 years ago
parent e1a3653b33
commit cf8c1a9d58

@ -452,6 +452,7 @@ function getDapnetMessages(document, event) {
function getSysInfo(document, event) {
$(document).ready(function() {
if (event.data.startsWith("SYSINFO")) {
logIt(event.data);
data = event.data;
data = data.substring(data.indexOf(" ") + 1);
@ -482,6 +483,7 @@ function getSysInfo(document, event) {
document.getElementById("disk_free").innerHTML = parseFloat(data.substring(data.indexOf("disk_free:") + 10, data.indexOf(" "))).toFixed(3);
data = data.substring(data.indexOf(" ") + 1);
document.getElementById("disk_percent_used").innerHTML = data.substring(data.indexOf("disk_percent_used:") + 18);
}
});
}

@ -13,7 +13,7 @@ import os
from collections import deque
from urllib.parse import urlparse, parse_qs
from ansi2html import Ansi2HTMLConverter
from gpiozero import CPUTemperature
#from gpiozero import CPUTemperature
from os import popen
import psutil
@ -112,9 +112,21 @@ def view_log(websocket, path):
yield from asyncio.sleep(0.2)
elif path == "/SYSINFO":
while True:
cpu = CPUTemperature()
f = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
cpufrq = str((int(f.read()) / 1000))
# cpu = CPUTemperature()
# cpu_temp = psutil.sensors_temperatures()
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_load = os.getloadavg();
cpu_load1 = str(cpu_load[0])
@ -132,7 +144,8 @@ def view_log(websocket, path):
disk_used = str(disk.used / 2**30)
disk_free = str(disk.free / 2**30)
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)
except ValueError as e:

Loading…
Cancel
Save