From c926da435df024888681102b5304cd01d5b5b8b8 Mon Sep 17 00:00:00 2001 From: Kim Huebel Date: Sat, 6 Feb 2021 23:30:37 +0000 Subject: [PATCH] Getting host-program-version and build-time from progam itself instead of logfile --- README.md | 7 ++++--- html/index.html | 4 ++-- html/js/functions.js | 10 +++++++--- html/js/version.js | 2 +- logtailer.ini | 6 ++++++ logtailer.py | 9 ++++++++- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a7affa5..015b5a1 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Actually known: ### Installation steps * first of all (if not already done by installation of MMDVMHost): create a syetemuser with `sudo adduser --system --no-create-home --group mmdvm` +* add following line to /etc/sudoers with `sudo visudo` for getting the logtailer access to MMDVMHost: `www-data ALL=(ALL) NOPASSWD: /usr/local/bin/MMDVMHost` * clone this repository to your home-directory with `git clone --recurse-submodules -j8 https://github.com/dg9vh/MMDVMHost-Websocketboard` to clone the repository with it's submodules * create directory with `sudo mkdir /opt/MMDVMDash` * copy all files from repository into this folder @@ -63,11 +64,11 @@ Finally you should be able to get the new Dashboard calling the hostname of your ### Troubleshoting If you have any trouble running the software most things depend on the logtailer-component. So it is a good idea to try starting the software on the console wih -`python3 ./logtailer.py` to see the output of the programme. A common error are missing python-libraries you should install with the commands mentioned above. +`python3 ./logtailer.py` to see the output of the program. A common error are missing python-libraries you should install with the commands mentioned above. If you found any further missing library let me know! Just open an issue! -If there are problems with paths for logfiles you also could get some impressions with the output of the programme. +If there are problems with paths for logfiles you also could get some impressions with the output of the program. ### If using DMRHost by BrandMeister-Team If you are using the DMRHost as replacement for MMDVMHost you should enable DMR-ID-Lookup within logtailer.ini by setting the corresponding option = 1 @@ -80,7 +81,7 @@ For getting the best user experience it is recommended to configure your MMDVMHo `FileRotate=0` -This results in having only one logfile for each programme and having it rotated by your linux-system with logrotate if configured. +This results in having only one logfile for each program and having it rotated by your linux-system with logrotate if configured. You should also configure your logtailer.ini with diff --git a/html/index.html b/html/index.html index 10873d9..a97a0be 100644 --- a/html/index.html +++ b/html/index.html @@ -255,9 +255,9 @@
  • Free: GB
  • Usage: %
  • - MMDVMHost: + Host-Program: diff --git a/html/js/functions.js b/html/js/functions.js index 03c7e84..c65a3cc 100644 --- a/html/js/functions.js +++ b/html/js/functions.js @@ -418,18 +418,18 @@ function getLastHeard(document, event) { var duration = 0; lines.forEach(function(line, index, array) { logIt("LogLine: " + line); - + /* if (line.indexOf("MMDVMHost") > 0 ) { mmdvmhost_version = line.substring(line.indexOf("MMDVMHost")); mmdvmhost_version = mmdvmhost_version.substring(0, mmdvmhost_version.indexOf(" ")); document.getElementById("mmdvmhost_version").innerHTML = mmdvmhost_version; } - if (line.indexOf("Built") > 0 ) { built = line.substring(line.indexOf("Built") + 6); document.getElementById("built").innerHTML = built; } + */ if (line.indexOf("description:") > 0 ) { modem = line.substring(line.indexOf("description:") + 12); document.getElementById("modem").innerHTML = modem; @@ -745,7 +745,11 @@ function getSysInfo(document, event) { 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.getElementById("disk_percent_used").innerHTML = data.substring(data.indexOf("disk_percent_used:") + 18, data.indexOf(" ")); + data = data.substring(data.indexOf(" ") + 1); + document.getElementById("mmdvmhost_version").innerHTML = data.substring(data.indexOf("mmdvmhost_version:") + 18, data.indexOf(" mmdvmhost_ctime")); + data = data.substring(data.indexOf(" ") + 1); + document.getElementById("built").innerHTML = data.substring(data.indexOf("mmdvmhost_ctime:") + 16); } }); } diff --git a/html/js/version.js b/html/js/version.js index d520855..a1f96ba 100644 --- a/html/js/version.js +++ b/html/js/version.js @@ -1 +1 @@ -var dashboard_version = "2021-02-06 16:18:53"; +var dashboard_version = "2021-02-06 23:30:37"; diff --git a/logtailer.ini b/logtailer.ini index c9cd6dc..a1c3dad 100644 --- a/logtailer.ini +++ b/logtailer.ini @@ -25,6 +25,12 @@ Prefix=MMDVM DMR_ID_Lookup=1 DMR_ID_LookupFile=/etc/MMDVM/DMRIds.dat +# Location of your MMDVM.ini/DMRHost.ini or similar +MMDVM_ini=/etc/MMDVM/MMDVM.ini + +# Localtion of your MMDVMHost/DMRHost-binary +MMDVM_bin=/usr/local/bin/MMDVMHost + [DAPNETGateway] # Don't throw away the trailing slash! It is important but check logfile-location and Prefix twice :-) Logdir=/mnt/ramdisk/ diff --git a/logtailer.py b/logtailer.py index 85e3643..b007424 100644 --- a/logtailer.py +++ b/logtailer.py @@ -17,6 +17,8 @@ from os import popen import psutil import functools from http import HTTPStatus +import subprocess +import time MIME_TYPES = { "html": "text/html", @@ -185,7 +187,12 @@ async 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) - await 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) + + mmdvmhost_version = str(subprocess.Popen(config['MMDVMHost']['MMDVM_bin'] + " -v", shell=True, stdout=subprocess.PIPE).stdout.read().decode("utf-8")) + + mmdvmhost_ctime = time.ctime(os.path.getmtime(config['MMDVMHost']['MMDVM_bin'])) + mmdvmhost_buildtime = datetime.datetime.strptime(mmdvmhost_ctime, "%a %b %d %H:%M:%S %Y") + await 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 + " mmdvmhost_version:" + mmdvmhost_version + " mmdvmhost_ctime:" + mmdvmhost_ctime) await asyncio.sleep(10) except ValueError as e: