Added System Load to sysinfo-tab
This commit is contained in:
parent
a6f35b294e
commit
e1a3653b33
3 changed files with 18 additions and 3 deletions
|
@ -196,6 +196,12 @@
|
|||
<li>Frequency: <span id="cpufrg"></span> MHz</li>
|
||||
<li>Usage: <span id="cpuusage"></span> %</li>
|
||||
</ul>
|
||||
<b>Load:</b>
|
||||
<ul>
|
||||
<li>Last Minute: <span id="cpu_load1"></span></li>
|
||||
<li>Last 5 Minutes: <span id="cpu_load5"></span></li>
|
||||
<li>Last 15 Minutes: <span id="cpu_load15"></span></li>
|
||||
</ul>
|
||||
<b>Memory:</b>
|
||||
<ul>
|
||||
<li>Total: <span id="ram_total"></span> MB</li>
|
||||
|
|
|
@ -452,17 +452,21 @@ function getDapnetMessages(document, event) {
|
|||
|
||||
function getSysInfo(document, event) {
|
||||
$(document).ready(function() {
|
||||
// cputemp:49.388 cpufrg:600.0 cpuusage:0.8 ram_total:974.37890625 ram_used:159.69140625 ram_free:157.265625 ram_percent_used:27.9 disk_total:7.084514617919922 disk_used:3.5408592224121094 disk_free:3.2069854736328125 disk_percent_used:52.5
|
||||
logIt(event.data);
|
||||
data = event.data;
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
logIt(data);
|
||||
document.getElementById("cputemp").innerHTML = parseFloat(data.substring(data.indexOf("cputemp:") + 8, data.indexOf(" "))).toFixed(1);
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("cpufrg").innerHTML = data.substring(data.indexOf("cpufrg:") + 7, data.indexOf(" "));
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("cpuusage").innerHTML = data.substring(data.indexOf("cpuusage:") + 9, data.indexOf(" "));
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("cpu_load1").innerHTML = data.substring(data.indexOf("cpu_load1:") + 10, data.indexOf(" "));
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("cpu_load5").innerHTML = data.substring(data.indexOf("cpu_load5:") + 10, data.indexOf(" "));
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("cpu_load15").innerHTML = data.substring(data.indexOf("cpu_load15:") + 11, data.indexOf(" "));
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("ram_total").innerHTML = Math.round(data.substring(data.indexOf("ram_total:") + 10, data.indexOf(" ")));
|
||||
data = data.substring(data.indexOf(" ") + 1);
|
||||
document.getElementById("ram_used").innerHTML = Math.round(data.substring(data.indexOf("ram_used:") + 9, data.indexOf(" ")));
|
||||
|
|
|
@ -116,6 +116,11 @@ def view_log(websocket, path):
|
|||
f = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
|
||||
cpufrq = str((int(f.read()) / 1000))
|
||||
cpu_usage = str(psutil.cpu_percent())
|
||||
cpu_load = os.getloadavg();
|
||||
cpu_load1 = str(cpu_load[0])
|
||||
cpu_load5 = str(cpu_load[1])
|
||||
cpu_load15 = str(cpu_load[2])
|
||||
|
||||
ram = psutil.virtual_memory()
|
||||
ram_total = str(ram.total / 2**20)
|
||||
ram_used = str(ram.used / 2**20)
|
||||
|
@ -127,7 +132,7 @@ 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 + " 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…
Reference in a new issue