Modes get red if corresponding process on host is not running, output of \'not linked\' if ircddbgateway is starting up or message if ircddbgateway is not running but D-Star is switched on in MMDVM.ini

This commit is contained in:
dg9vh 2016-05-13 16:02:21 +00:00
parent 0af9a21df3
commit 4ac7486324
2 changed files with 39 additions and 4 deletions

View file

@ -71,6 +71,9 @@ switch (DISTRIBUTION) {
define("CONFIGFILENAME", "ircddbgateway"); define("CONFIGFILENAME", "ircddbgateway");
define("GATEWAYCONFIGPATH", CONFIGPATH . "/" . CONFIGFILENAME); define("GATEWAYCONFIGPATH", CONFIGPATH . "/" . CONFIGFILENAME);
// set to called ircddbgateway-programm like ircddbgatewayd or ircddbgateway
define("IRCDDBGATEWAY", "ircddbgatewayd");
// set time to refresh page // set time to refresh page
define("REFRESHAFTER", "60"); define("REFRESHAFTER", "60");

View file

@ -6,8 +6,19 @@ function getMMDVMHostVersion() {
if (file_exists($filename)) { if (file_exists($filename)) {
return date("Y-m-d", filectime($filename)); return date("Y-m-d", filectime($filename));
} }
} }
function isProcessRunning($processname) {
exec("pgrep " . $processname, $pids);
if(empty($pids)) {
// process not running!
return false;
} else {
// process running!
return true;
}
}
function getMMDVMConfig() { function getMMDVMConfig() {
// loads MMDVM.ini into array for further use // loads MMDVM.ini into array for further use
$mmdvmconfigs = array(); $mmdvmconfigs = array();
@ -49,7 +60,21 @@ function showMode($mode, $mmdvmconfigs) {
?> ?>
<td><span class="label <?php <td><span class="label <?php
if (getEnabled($mode, $mmdvmconfigs) == 1) { if (getEnabled($mode, $mmdvmconfigs) == 1) {
echo "label-success"; if ($mode == "D-Star" || $mode == "D-Star Network") {
if (isProcessRunning(IRCDDBGATEWAY)) {
echo "label-success";
} else {
echo "label-danger";
}
} else {
if ($mode =="DMR" || $mode =="DMR Network" || $mode =="System Fusion" || $mode =="System Fusion Network") {
if (isProcessRunning("MMDVMHost")) {
echo "label-success";
} else {
echo "label-danger";
}
}
}
} else { } else {
echo "label-default"; echo "label-default";
} }
@ -236,6 +261,9 @@ function getActualMode($logLines, $mmdvmconfigs) {
function getDSTARLinks() { function getDSTARLinks() {
// returns link-states of all D-Star-modules // returns link-states of all D-Star-modules
if (filesize(LINKLOGPATH) == 0) {
return "not linked";
}
$out = "<table>"; $out = "<table>";
if ($linkLog = fopen(LINKLOGPATH,'r')) { if ($linkLog = fopen(LINKLOGPATH,'r')) {
while ($linkLine = fgets($linkLog)) { while ($linkLine = fgets($linkLog)) {
@ -293,7 +321,11 @@ function getActualLink($logLines, $mode) {
array_multisort($logLines,SORT_DESC); array_multisort($logLines,SORT_DESC);
switch ($mode) { switch ($mode) {
case "D-Star": case "D-Star":
return getDSTARLinks(); if (isProcessRunning(IRCDDBGATEWAY)) {
return getDSTARLinks();
} else {
return "ircddbgateway not running!";
}
break; break;
case "DMR Slot 1": case "DMR Slot 1":
foreach ($logLines as $logLine) { foreach ($logLines as $logLine) {