D-Star - linking is coming from Links.log now, LH-list now shows network watchdog-lines also with duration, loss and ber

This commit is contained in:
dg9vh 2016-05-05 19:30:33 +02:00
parent 762cc24c78
commit 5be21a6df2
4 changed files with 124 additions and 7 deletions

View file

@ -1,9 +1,75 @@
<?php
date_default_timezone_set('UTC');
define("REPEATERCALLSIGN","DG9VH");
define("LOGPATH","/mnt/ramdisk/");
define("LOGPREFIX","MMDVM");
define("LOGFILE",LOGPATH . LOGPREFIX . "-" . date("Y-m-d") . ".log");
define("MMDVMLOGPATH","/mnt/ramdisk/"); // hint: add trailing / !!!
define("MMDVMLOGPREFIX","MMDVM");
define("MMDVMLOGFILE",MMDVMLOGPATH . MMDVMLOGPREFIX . "-" . date("Y-m-d") . ".log");
// enter exact path to your log files.
// If your Linux is a MARYLAND-DSTAR-Image, this paths would work.
// Adjust to suit, uncomment correct line, if no line is uncommented, customize
// else-path to suitable paths.
define("DISTRIBUTION","MARYLAND");
//define("DISTRIBUTION","WESTERN");
//define("DISTRIBUTION","DL5DI_DEBIAN");
//define("DISTRIBUTION","DL5DI_CENTOS");
//define("DISTRIBUTION","OTHER");
switch (DISTRIBUTION) {
case "MARYLAND":
// Configuration for Maryland-Dstar-Image
define("LOGPATH", "/var/log");
define("CONFIGPATH", "/etc/gateway");
define("DSTARREPEATERLOGPATH", LOGPATH. "/dstarrepeater_1");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater_Repeater-1-");
define("LINKLOGPATH", LOGPATH . "/gateway/Links.log");
define("HRDLOGPATH", LOGPATH . "/gateway/Headers.log");
break;
case "WESTERN":
// Configuration for Western-Dstar-Image
define("LOGPATH", "/var/log");
define("CONFIGPATH", "/etc");
define("DSTARREPEATERLOGPATH", LOGPATH. "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
case "DL5DI_CENTOS":
// Configuration for DL5DI-Installation-packages on CENTOS
define("LOGPATH", "/var/log/dstar");
define("CONFIGPATH", "/etc");
define("DSTARREPEATERLOGPATH", LOGPATH. "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater_1-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
case "DL5DI_DEBIAN":
// Configuration for DL5DI-Installation-packages on DEBIAN
define("LOGPATH", "/var/log/opendv");
define("CONFIGPATH", "/home/opendv/ircddbgateway");
define("DSTARREPEATERLOGPATH", LOGPATH. "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater_1-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
case "OTHER":
// Configuration for all others, please customize
// if necessary
define("LOGPATH", "/var/log");
define("CONFIGPATH", "/etc");
define("DSTARREPEATERLOGPATH", LOGPATH. "/");
define("DSTARREPEATERLOGFILENAME", "DStarRepeater-");
define("LINKLOGPATH", LOGPATH . "/Links.log");
define("HRDLOGPATH", LOGPATH . "/Headers.log");
break;
}
define("CONFIGFILENAME","ircddbgateway");
define("GATEWAYCONFIGPATH", CONFIGPATH."/".CONFIGFILENAME);
define("REFRESHAFTER","60");
define("TEMPERATUREALERT",true);
define("TEMPERATUREHIGHLEVEL", 60);

View file

@ -2,7 +2,7 @@
function getLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
if ($log = fopen(LOGFILE,'r')) {
if ($log = fopen(MMDVMLOGFILE,'r')) {
while ($logLine = fgets($log)) {
array_push($logLines, $logLine);
}
@ -45,7 +45,7 @@ function getHeardList($logLines) {
continue;
}
if(strpos($logLine,"end of")) {
if(strpos($logLine,"end of") || strpos($logLine,"watchdog has expired")) {
$lineTokens = explode(", ",$logLine);
$duration = strtok($lineTokens[2], " ");
@ -158,6 +158,55 @@ function getActualMode($logLines) {
return "Idle";
}
function getDSTARLinks() {
$out = "";
if ($linkLog = fopen(LINKLOGPATH,'r')) {
while ($linkLine = fgets($linkLog)) {
$linkDate = "&nbsp;";
$protocol = "&nbsp;";
$linkType = "&nbsp;";
$linkSource = "&nbsp;";
$linkDest = "&nbsp;";
$linkDir = "&nbsp;";
// Reflector-Link, sample:
// 2011-09-22 02:15:06: DExtra link - Type: Repeater Rptr: DB0LJ B Refl: XRF023 A Dir: Outgoing
// 2012-04-03 08:40:07: DPlus link - Type: Dongle Rptr: DB0ERK B Refl: REF006 D Dir: Outgoing
// 2012-04-03 08:40:07: DCS link - Type: Repeater Rptr: DB0ERK C Refl: DCS001 C Dir: Outgoing
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*Rptr: (.{8}).*Refl: (.{8}).*Dir: (.{8})/',$linkLine,$linx) > 0){
$linkDate = $linx[1][0];
$protocol = $linx[2][0];
$linkType = $linx[3][0];
$linkSource = $linx[4][0];
$linkDest = $linx[5][0];
$linkDir = $linx[6][0];
}
// CCS-Link, sample:
// 2013-03-30 23:21:53: CCS link - Rptr: PE1AGO C Remote: PE1KZU Dir: Incoming
if(preg_match_all('/^(.{19}).*(CC[A-Za-z]*).*Rptr: (.{8}).*Remote: (.{8}).*Dir: (.{8})/',$linkLine,$linx) > 0){
$linkDate = $linx[1][0];
$protocol = $linx[2][0];
$linkType = $linx[2][0];
$linkSource = $linx[3][0];
$linkDest = $linx[4][0];
$linkDir = $linx[5][0];
}
// Dongle-Link, sample:
// 2011-09-24 07:26:59: DPlus link - Type: Dongle User: DC1PIA Dir: Incoming
// 2012-03-14 21:32:18: DPlus link - Type: Dongle User: DC1PIA Dir: Incoming
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*User: (.{6,8}).*Dir: (.*)$/',$linkLine,$linx) > 0){
$linkDate = $linx[1][0];
$protocol = $linx[2][0];
$linkType = $linx[3][0];
$linkSource = "&nbsp;";
$linkDest = $linx[4][0];
$linkDir = $linx[5][0];
}
$out .= $protocol . "-link to &gt;" . $linkDest . "&lt; " . $linkDir . "<br>";
}
}
return $out;
}
function getActualLink($logLines, $mode) {
//M: 2016-05-02 07:04:10.504 D-Star link status set to "Verlinkt zu DCS002 S"
//M: 2016-04-03 16:16:18.638 DMR Slot 2, received network voice header from 4000 to 2625094
@ -165,12 +214,15 @@ function getActualLink($logLines, $mode) {
array_multisort($logLines,SORT_DESC);
switch ($mode) {
case "D-Star":
/*
foreach ($logLines as $logLine) {
if (strpos($logLine, "D-Star link status set to")) {
return substr($logLine, 54, strlen($logLine) - 56);
}
}
return "not linked";
*/
return getDSTARLinks();
break;
case "DMR Slot 1":
foreach ($logLines as $logLine) {

View file

@ -9,7 +9,7 @@
<table class="table">
<tr>
<th>Actual Mode</th>
<th>D-Star last linked to</th>
<th>D-Star linked to</th>
<th>DMR TS1 last linked to</th>
<th>DMR TS2 last linked to</th>
</tr>

View file

@ -34,7 +34,6 @@ include "include/lh.php";
?>
<div class="panel panel-info">
<?php
date_default_timezone_set("UTC");
$datum = date("d.m.Y");
$uhrzeit = date("H:i:s");
echo "Last Update $datum, $uhrzeit";