1
0
Fork 0

Added Service-Monitoring

New Tab with service-monitoring added
main
Kim Huebel 3 years ago
parent fd56a1ea87
commit 07a824d3c2

4
.gitmodules vendored

@ -1,3 +1,7 @@
[submodule "html/metar.js"] [submodule "html/metar.js"]
path = html/metar.js path = html/metar.js
url = https://github.com/skydivejkl/metar.js url = https://github.com/skydivejkl/metar.js
[submodule "html/open-iconic"]
path = html/open-iconic
url = https://github.com/iconic/open-iconic
branch = master

@ -30,3 +30,6 @@ td.dt-nowrap { white-space: nowrap }
.red { .red {
background-color: Coral !important; background-color: Coral !important;
} }
#services_monitor_list {list-style-type: none;}

@ -6,8 +6,8 @@ YSF,0,1,Local Parrot,
YSF,0,2,DEV Reflector, YSF,0,2,DEV Reflector,
YSF,0,10,YSF2DMR TG26250, YSF,0,10,YSF2DMR TG26250,
YSF,0,40,DL Multimode 263,https://c4fm.ysfreflector.de/Germany/ YSF,0,40,DL Multimode 263,https://c4fm.ysfreflector.de/Germany/
YSF,0,41,DL-RAMSES, YSF,0,41,DL-RAMSES,http://161.97.140.131:8000/RAMSES.html
YSF,0,42,DL-RAMSES-II, YSF,0,42,DL-RAMSES-II,http://161.97.140.131:8000/RAMSES-II.html
YSF,0,43,DL-RAMSES-III, YSF,0,43,DL-RAMSES-III,
YSF,0,44,DL-PEGASUS, YSF,0,44,DL-PEGASUS,
YSF,0,45,DL-SAAR,https://c4fm.ysfreflector.de/DL-Saar/ YSF,0,45,DL-SAAR,https://c4fm.ysfreflector.de/DL-Saar/

1 MODE TS TG LABEL URL
6 YSF 0 2 DEV Reflector
7 YSF 0 10 YSF2DMR TG26250
8 YSF 0 40 DL Multimode 263 https://c4fm.ysfreflector.de/Germany/
9 YSF 0 41 DL-RAMSES http://161.97.140.131:8000/RAMSES.html
10 YSF 0 42 DL-RAMSES-II http://161.97.140.131:8000/RAMSES-II.html
11 YSF 0 43 DL-RAMSES-III
12 YSF 0 44 DL-PEGASUS
13 YSF 0 45 DL-SAAR https://c4fm.ysfreflector.de/DL-Saar/

@ -29,6 +29,7 @@
<script type="text/javascript" src="js/functions.js"></script> <script type="text/javascript" src="js/functions.js"></script>
<link rel="stylesheet" href="css/styles.css"> <link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/tooltip.css"> <link rel="stylesheet" href="css/tooltip.css">
<link href="open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet">
<title>DG9VH - MMDVM-Dashboard by DG9VH</title> <title>DG9VH - MMDVM-Dashboard by DG9VH</title>
</head> </head>
<body> <body>
@ -87,6 +88,9 @@
<li class="nav-item" name="sysinfo"> <li class="nav-item" name="sysinfo">
<a class="nav-link" id="sysinfo-tab" data-toggle="tab" href="#sysinfo" role="tab" aria-controls="sysinfo" aria-selected="false">System Info</a> <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>
<li class="nav-item" name="services">
<a class="nav-link" id="services-tab" data-toggle="tab" href="#services" role="tab" aria-controls="services" aria-selected="false">Services Monitor</a>
</li>
<li class="nav-item" name="about"> <li class="nav-item" name="about">
<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>
@ -294,6 +298,15 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="services" role="tabpanel" aria-labelledby="services-tab">
<div class="panel panel-default">
<!-- Standard-Panel-Inhalt -->
<div class="panel-heading">Services Monitor<span class="pull-right clickable"><i class="glyphicon glyphicon-chevron-up"></i></span></div>
<div class="panel-body">
<span id="services_monitor"><ul class="services_monitor"></span>
</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 -->
@ -446,6 +459,13 @@
t_dapnet.order( [ 0, 'desc' ] ).draw(); t_dapnet.order( [ 0, 'desc' ] ).draw();
} }
if (services > 0) {
var ws3 = new WebSocket("ws://" + window.location.hostname + ":5678/SERVICES");
ws3.onmessage = function (event) {
getServicesStatus(document, event);
};
}
checkConfigStructure(); checkConfigStructure();
</script> </script>
</body> </body>

@ -1,5 +1,5 @@
// config structure version, please change to value in github-file after update and adding new values // config structure version, please change to value in github-file after update and adding new values
var config_struc_ver = 20210312.1; var config_struc_ver = 20210414.1;
// 1 = show link to QRZ.com, 0 = off // 1 = show link to QRZ.com, 0 = off
var qrz = 1; var qrz = 1;
@ -20,6 +20,7 @@ var allheard = 1;
var qso = 1; var qso = 1;
var dapnet = 1; var dapnet = 1;
var sysinfo = 1; var sysinfo = 1;
var services = 1;
var about = 1; var about = 1;
// Set displayed timezone and timestamp to timezone of browser if 1, else use UTC for displaying // Set displayed timezone and timestamp to timezone of browser if 1, else use UTC for displaying
@ -38,4 +39,4 @@ var qrz_blacklist = [
var dashboard_blacklist = [ var dashboard_blacklist = [
"MY0CALL", "MY0CALL",
] ]

@ -1,4 +1,4 @@
var act_config_struc_ver = 20210312.1; var act_config_struc_ver = 20210314.1;
var messagecount = 0; var messagecount = 0;
var ts1TXing = null; var ts1TXing = null;
var ts2TXing = null; var ts2TXing = null;
@ -21,6 +21,8 @@ dapnet = typeof(dapnet) == 'undefined' ? 1 : dapnet;
sysinfo = typeof(sysinfo) == 'undefined' ? 1 : sysinfo; sysinfo = typeof(sysinfo) == 'undefined' ? 1 : sysinfo;
about = typeof(about) == 'undefined' ? 1 : about; about = typeof(about) == 'undefined' ? 1 : about;
var array_services = [];
setInterval(getCurrentTXing, 1000); setInterval(getCurrentTXing, 1000);
function logIt(message) { function logIt(message) {
@ -857,6 +859,61 @@ function getSysInfo(document, event) {
}); });
} }
function getServiceName(event) {
return event.data.substring(17, event.data.lastIndexOf(":"));
}
function getServiceState(event) {
return event.data.substr(event.data.lastIndexOf(":") + 1);
}
function addToServices(servicename, servicestate) {
var newService = new Array();
newService[0] = servicename;
newService[1] = servicestate;
array_services.push(newService);
}
function insertOrUpdateServiceState(servicename, servicestate) {
updated = false;
for (i = 0; i < array_services.length; ++i){
actual_service = array_services[i];
if (actual_service[0] == servicename) {
var newService = new Array();
newService[0] = servicename;
newService[1] = servicestate;
array_services[i] = newService;
updated = true;
}
}
if (updated == false) {
addToServices(servicename, servicestate);
}
}
function getServicesStatus(document, event) {
$(document).ready(function() {
if (event.data.startsWith("SERVICESMONITOR")) {
var servicename = getServiceName(event);
var servicestate = getServiceState(event);
insertOrUpdateServiceState(servicename, servicestate);
document.getElementById("services_monitor").innerHTML = '<ul id="services_monitor_list">';
//document.getElementById("services_monitor").innerHTML = '<ul id="services_monitor_list" style="list-style-type: none;">';
array_services.forEach(function(actual_service){
if (actual_service[1] == "running") {
document.getElementById("services_monitor_list").innerHTML += '<li title="' + actual_service[0] + ' is running"><span class="oi oi-media-play"></span> ' + actual_service[0] + '</li>';
} else {
document.getElementById("services_monitor_list").innerHTML += '<li title="' + actual_service[0] + ' is stopped"><span class="oi oi-media-stop"></span> ' + actual_service[0] + '</li>';
}
});
document.getElementById("services_monitor").innerHTML += "</ul>";
}
});
}
function activateDefaultTab(name) { function activateDefaultTab(name) {
var element = document.getElementById(name + "-tab"); var element = document.getElementById(name + "-tab");
element.classList.add("active"); element.classList.add("active");

@ -1 +1 @@
var dashboard_version = "2021-04-10 19:54:10"; var dashboard_version = "2021-04-14 22:04:34";

@ -0,0 +1 @@
Subproject commit 1d1e8885c5031874b32f4e480e371ce2b1c24144

@ -41,3 +41,9 @@ MMDVM_bin=/usr/local/bin/MMDVMHost
Logdir=/mnt/ramdisk/ Logdir=/mnt/ramdisk/
Prefix=DAPNETGateway Prefix=DAPNETGateway
[ServiceMonitoring]
# Here you list your Services to be monitored
BinaryName1=MMDVMHost
BinaryName2=DMRGateway
BinaryName3=DGIdGateway
BinaryName4=YSF2DMR

@ -260,7 +260,8 @@ async def view_log(websocket, path):
await websocket.send(line) await websocket.send(line)
else: else:
await asyncio.sleep(0.2) await asyncio.sleep(0.2)
elif path == "/SYSINFO":
if path == "/SYSINFO":
mmdvmhost_version = str(subprocess.Popen(config['MMDVMHost']['MMDVM_bin'] + " -v", shell=True, stdout=subprocess.PIPE).stdout.read().decode("utf-8")) 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_ctime = time.ctime(os.path.getmtime(config['MMDVMHost']['MMDVM_bin']))
mmdvmhost_buildtime = datetime.datetime.strptime(mmdvmhost_ctime, "%a %b %d %H:%M:%S %Y") mmdvmhost_buildtime = datetime.datetime.strptime(mmdvmhost_ctime, "%a %b %d %H:%M:%S %Y")
@ -304,6 +305,19 @@ async def view_log(websocket, path):
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) 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)
await asyncio.sleep(10) await asyncio.sleep(10)
if path == "/SERVICES":
services_items = [x for x in config.items('ServiceMonitoring') if x[0] not in config.defaults()]
while True:
for key, value in services_items:
logging.info('key: ' + key + " = " + value)
if checkIfProcessRunning(value):
logging.info('process ' + value + " is running")
await websocket.send("SERVICESMONITOR: " + value + ":running")
else:
logging.info('process ' + value + " is stopped")
await websocket.send("SERVICESMONITOR: " + value + ":stopped")
await asyncio.sleep(30)
except ValueError as e: except ValueError as e:
try: try:
await websocket.send('Logtailer-Errormessage: ValueError: {}'.format(e)) await websocket.send('Logtailer-Errormessage: ValueError: {}'.format(e))
@ -325,6 +339,21 @@ async def view_log(websocket, path):
log_close(websocket, path) log_close(websocket, path)
def checkIfProcessRunning(processName):
'''
Check if there is any running process that contains the given name processName.
'''
#Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False;
def log_close(websocket, path, exception=None): def log_close(websocket, path, exception=None):
message = 'Closed, remote={}, path={}'.format(websocket.remote_address, path) message = 'Closed, remote={}, path={}'.format(websocket.remote_address, path)
if exception is not None: if exception is not None:

Loading…
Cancel
Save