1
0
Fork 0
Kim - DG9VH 4 years ago
parent ce35c1fcd0
commit dd99558ca8

@ -23,6 +23,7 @@ You'll need to install several python3 modules. A concrete list will follow here
Actually known: Actually known:
* websockets: `sudo apt install python3-websockets` * websockets: `sudo apt install python3-websockets`
* ansi2html: `sudo pip3 install ansi2html` * ansi2html: `sudo pip3 install ansi2html`
* gpiozero: `sudo apt install python3-gpiozero`
### Reommendations ### Reommendations
* take care to set Loglevel for FileLevel = 2 in your MMDVM.ini * take care to set Loglevel for FileLevel = 2 in your MMDVM.ini

@ -52,6 +52,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="dapnet-tab" data-toggle="tab" href="#dapnet" role="tab" aria-controls="dapnet" aria-selected="false">DAPNET Messages</a> <a class="nav-link" id="dapnet-tab" data-toggle="tab" href="#dapnet" role="tab" aria-controls="dapnet" aria-selected="false">DAPNET Messages</a>
</li> </li>
<li class="nav-item">
<a class="nav-link" id="sysinfo-tab" data-toggle="tab" href="#sysinfo" role="tab" aria-controls="sysinfo" aria-selected="false">System Info</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="about-tab" data-toggle="tab" href="#about" role="tab" aria-controls="about" aria-selected="false">About</a> <a class="nav-link" id="about-tab" data-toggle="tab" href="#about" role="tab" aria-controls="about" aria-selected="false">About</a>
</li> </li>
@ -182,6 +185,27 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="sysinfo" role="tabpanel" aria-labelledby="sysinfo-tab">
<div class="panel panel-default">
<!-- Standard-Panel-Inhalt -->
<div class="panel-heading">System Info<span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span></div>
<div class="panel-body">
<ul>
<li>CPU Temperature: <span id="cputemp"></span> °C</li>
<li>CPU Frequency: <span id="cpufrg"></span> MHz</li>
<li>CPU Usage: <span id="cpuusage"></span>%</li>
<li>RAM Total: <span id="ram_total"></span> MB</li>
<li>RAM Used: <span id="ram_used"></span> MB</li>
<li>RAM Free: <span id="ram_free"></span> MB</li>
<li>RAM Usage: <span id="ram_percent_used"></span> %</li>
<li>Disk Total: <span id="disk_total"></span> GB</li>
<li>Disk Used: <span id="disk_used"></span> GB</li>
<li>Disk Free: <span id="disk_free"></span> GB</li>
<li>Disk Usage: <span id="disk_percent_used"></span> %</li>
</ul>
</div>
</div>
</div>
<div class="tab-pane fade" id="about" role="tabpanel" aria-labelledby="about-tab"> <div class="tab-pane fade" id="about" role="tabpanel" aria-labelledby="about-tab">
<div class="panel panel-default"> <div class="panel panel-default">
<!-- Standard-Panel-Inhalt --> <!-- Standard-Panel-Inhalt -->
@ -215,6 +239,11 @@
"order": [[ 0, "desc" ]] "order": [[ 0, "desc" ]]
} ); } );
var ws3 = new WebSocket("ws://" + window.location.hostname + ":5678/SYSINFO");
ws3.onmessage = function (event) {
getSysInfo(document, event);
};
var ws1 = new WebSocket("ws://" + window.location.hostname + ":5678/MMDVM"); var ws1 = new WebSocket("ws://" + window.location.hostname + ":5678/MMDVM");
ws1.onmessage = function (event) { ws1.onmessage = function (event) {
getLastHeard(document, event); getLastHeard(document, event);
@ -246,6 +275,7 @@
getDapnetMessages(document, event); getDapnetMessages(document, event);
}; };
t_dapnet.order( [ 0, 'desc' ] ).draw(); t_dapnet.order( [ 0, 'desc' ] ).draw();
</script> </script>
</body> </body>
</html> </html>

@ -15,8 +15,9 @@ var showLastHeardTab = 1;
var showLocalHeadTab = 1; var showLocalHeadTab = 1;
var showInQSOTab = 1; var showInQSOTab = 1;
var showDAPNETMessagesTab = 1; var showDAPNETMessagesTab = 1;
var showSysInfoTab = 1;
var showAboutTab = 1; var showAboutTab = 1;
// default-tab to show // default-tab to show
// chose from following list: CurrTXTab, LastHeardTab, LocalHeadTab, InQSOTab, DAPNETMessagesTab, AboutTab // chose from following list: CurrTXTab, LastHeardTab, LocalHeadTab, InQSOTab, DAPNETMessagesTab, SysInfoTab, AboutTab
var defaultTab = "LastHeardTab"; var defaultTab = "LastHeardTab";

@ -450,6 +450,37 @@ 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("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(" ")));
data = data.substring(data.indexOf(" ") + 1);
document.getElementById("ram_free").innerHTML = Math.round(data.substring(data.indexOf("ram_free:") + 9, data.indexOf(" ")));
data = data.substring(data.indexOf(" ") + 1);
document.getElementById("ram_percent_used").innerHTML = data.substring(data.indexOf("ram_percent_used:") + 17, data.indexOf(" "));
data = data.substring(data.indexOf(" ") + 1);
document.getElementById("disk_total").innerHTML = parseFloat(data.substring(data.indexOf("disk_total:") + 11, data.indexOf(" "))).toFixed(3);
data = data.substring(data.indexOf(" ") + 1);
document.getElementById("disk_used").innerHTML = parseFloat(data.substring(data.indexOf("disk_used:") + 10, data.indexOf(" "))).toFixed(3);
data = data.substring(data.indexOf(" ") + 1);
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);
});
}
$(document).ready(function() { $(document).ready(function() {
if(showCurrTXTab == 0){ if(showCurrTXTab == 0){
document.getElementById("myTab").children[0].style.display="none"; document.getElementById("myTab").children[0].style.display="none";
@ -471,8 +502,12 @@ $(document).ready(function() {
document.getElementById("myTab").children[4].style.display="none"; document.getElementById("myTab").children[4].style.display="none";
document.getElementById("dapnet").style.display="none"; document.getElementById("dapnet").style.display="none";
} }
if(showAboutTab == 0){ if(showSysInfoTab == 0){
document.getElementById("myTab").children[5].style.display="none"; document.getElementById("myTab").children[5].style.display="none";
document.getElementById("sysinfo").style.display="none";
}
if(showAboutTab == 0){
document.getElementById("myTab").children[6].style.display="none";
document.getElementById("about").style.display="none"; document.getElementById("about").style.display="none";
} }
@ -516,6 +551,14 @@ $(document).ready(function() {
element.classList.add("show"); element.classList.add("show");
element.classList.add("active"); element.classList.add("active");
break; break;
case "SysInfoTab":
var element = document.getElementById("sysinfo-tab");
element.classList.add("active");
var element = document.getElementById("sysinfo");
element.classList.add("show");
element.classList.add("active");
break;
case "AboutTab": case "AboutTab":
var element = document.getElementById("about-tab"); var element = document.getElementById("about-tab");
element.classList.add("active"); element.classList.add("active");

@ -13,6 +13,9 @@ 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 os import popen
import psutil
current_dir = os.getcwd() current_dir = os.getcwd()
config = configparser.ConfigParser() config = configparser.ConfigParser()
@ -53,35 +56,55 @@ def view_log(websocket, path):
elif path == "/DAPNET": elif path == "/DAPNET":
file_path = config['DAPNETGateway']['Logdir']+config['DAPNETGateway']['Prefix']+"-"+year+"-"+month+"-"+day+".log" file_path = config['DAPNETGateway']['Logdir']+config['DAPNETGateway']['Prefix']+"-"+year+"-"+month+"-"+day+".log"
NUM_LINES = 0 NUM_LINES = 0
logging.info(file_path) if path == "/MMDVM" or path == "/DAPNET":
if not os.path.isfile(file_path): logging.info(file_path)
raise ValueError('File not found', format(file_path)) if not os.path.isfile(file_path):
raise ValueError('File not found', format(file_path))
with open(file_path, newline = '\n', encoding="utf8", errors='ignore') as f:
with open(file_path, newline = '\n', encoding="utf8", errors='ignore') as f:
content = ''.join(deque(f, NUM_LINES))
content = conv.convert(content, full=False) content = ''.join(deque(f, NUM_LINES))
lines = content.split("\n") content = conv.convert(content, full=False)
for line in lines: lines = content.split("\n")
if line.find("from ") > 0 and line.find("to ") > 0: for line in lines:
source = line[line.index("from ") + 5:line.index("to ")].strip() if line.find("from ") > 0 and line.find("to ") > 0:
if source in dmrids: source = line[line.index("from ") + 5:line.index("to ")].strip()
line = line.replace(source, dmrids[source]) if source in dmrids:
yield from websocket.send(line) line = line.replace(source, dmrids[source])
yield from websocket.send(line)
while True:
content = f.read()
if content:
content = conv.convert(content, full=False)
lines = content.split("\n")
for line in lines:
if line.find("from ") > 0 and line.find("to ") > 0:
source = line[line.index("from ") + 5:line.index("to ")].strip()
if source in dmrids:
line = line.replace(source, dmrids[source])
yield from websocket.send(line)
else:
yield from asyncio.sleep(0.2)
elif path == "/SYSINFO":
while True: while True:
content = f.read() cpu = CPUTemperature()
if content: f = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")
content = conv.convert(content, full=False) cpufrq = str((int(f.read()) / 1000))
lines = content.split("\n") cpu_usage = str(psutil.cpu_percent())
for line in lines: ram = psutil.virtual_memory()
if line.find("from ") > 0 and line.find("to ") > 0: ram_total = str(ram.total / 2**20)
source = line[line.index("from ") + 5:line.index("to ")].strip() ram_used = str(ram.used / 2**20)
if source in dmrids: ram_free = str(ram.free / 2**20)
line = line.replace(source, dmrids[source]) ram_percent_used = str(ram.percent)
yield from websocket.send(line)
else: disk = psutil.disk_usage('/')
yield from asyncio.sleep(0.2) disk_total = str(disk.total / 2**30)
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 asyncio.sleep(10)
except ValueError as e: except ValueError as e:
try: try:

Loading…
Cancel
Save