diff --git a/ajax.php b/ajax.php index 3063da0..ddf87d6 100644 --- a/ajax.php +++ b/ajax.php @@ -8,232 +8,232 @@ include "include/functions.php"; $mmdvmconfigs = getMMDVMConfig(); if (!defined("MMDVMLOGPREFIX")) - define("MMDVMLOGPREFIX", getConfigItem("Log", "FileRoot", $mmdvmconfigs)); + define("MMDVMLOGPREFIX", getConfigItem("Log", "FileRoot", $mmdvmconfigs)); if (!defined("TIMEZONE")) - define("TIMEZONE", "UTC"); + define("TIMEZONE", "UTC"); $logLinesMMDVM = getMMDVMLog(); $reverseLogLinesMMDVM = $logLinesMMDVM; array_multisort($reverseLogLinesMMDVM,SORT_DESC); if ($_GET['section'] == "mode") { - $mode = getActualMode(getLastHeard($reverseLogLinesMMDVM, TRUE), $mmdvmconfigs); - echo $mode; + $mode = getActualMode(getLastHeard($reverseLogLinesMMDVM, TRUE), $mmdvmconfigs); + echo $mode; } if ($_GET['section'] == "lastHeard") { - $lastHeard = getLastHeard($reverseLogLinesMMDVM, FALSE); - echo '{"data": '.json_encode($lastHeard)."}"; + $lastHeard = getLastHeard($reverseLogLinesMMDVM, FALSE); + echo '{"data": '.json_encode($lastHeard)."}"; } if ($_GET['section'] == "localTx") { - $localTXList = getHeardList($reverseLogLinesMMDVM, FALSE); - $lastHeard = Array(); - for ($i = 0; $i < count($localTXList); $i++) { - $listElem = $localTXList[$i]; - if (defined("ENABLEXTDLOOKUP")) { - if ($listElem[6] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) { - $listElem[3] = getName($listElem[2]); - if ($listElem[2] !== "??????????") { - if (!is_numeric($listElem[2])) { - if (constant("SHOWQRZ")) { - $listElem[2] = "".str_replace("0","Ø",$listElem[2]).""; - } else { - $listElem[2] = "".$listElem[2].""; - } - } else { - $listElem[2] = "".$listElem[2].""; - } - } - array_push($lastHeard, $listElem); - } - } else { - if ($listElem[5] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) { - if ($listElem[2] !== "??????????") { - if (!is_numeric($listElem[2])) { - if (constant("SHOWQRZ")) { - $listElem[2] = "".str_replace("0","Ø",$listElem[2]).""; - } else { - $listElem[2] = "".$listElem[2].""; - } - } else { - $listElem[2] = "".$listElem[2].""; - } - } - array_push($lastHeard, $listElem); - } - } - } - echo '{"data": '.json_encode($lastHeard)."}"; + $localTXList = getHeardList($reverseLogLinesMMDVM, FALSE); + $lastHeard = Array(); + for ($i = 0; $i < count($localTXList); $i++) { + $listElem = $localTXList[$i]; + if (defined("ENABLEXTDLOOKUP")) { + if ($listElem[6] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) { + $listElem[3] = getName($listElem[2]); + if ($listElem[2] !== "??????????") { + if (!is_numeric($listElem[2])) { + if (constant("SHOWQRZ")) { + $listElem[2] = "".str_replace("0","Ø",$listElem[2]).""; + } else { + $listElem[2] = "".$listElem[2].""; + } + } else { + $listElem[2] = "".$listElem[2].""; + } + } + array_push($lastHeard, $listElem); + } + } else { + if ($listElem[5] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) { + if ($listElem[2] !== "??????????") { + if (!is_numeric($listElem[2])) { + if (constant("SHOWQRZ")) { + $listElem[2] = "".str_replace("0","Ø",$listElem[2]).""; + } else { + $listElem[2] = "".$listElem[2].""; + } + } else { + $listElem[2] = "".$listElem[2].""; + } + } + array_push($lastHeard, $listElem); + } + } + } + echo '{"data": '.json_encode($lastHeard)."}"; } if ($_GET['section'] == "sysinfo") { - $cputemp = NULL; - $cpufreq = NULL; - if (file_exists ("/sys/class/thermal/thermal_zone0/temp")) { - exec("cat /sys/class/thermal/thermal_zone0/temp", $cputemp); - $cputemp = $cputemp[0] / 1000; - } - showLapTime("cputemp"); - if (file_exists ("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")) { - exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $cpufreq); - $cpufreq = $cpufreq[0] / 1000; - } - showLapTime("cpufreq"); + $cputemp = NULL; + $cpufreq = NULL; + if (file_exists ("/sys/class/thermal/thermal_zone0/temp")) { + exec("cat /sys/class/thermal/thermal_zone0/temp", $cputemp); + $cputemp = $cputemp[0] / 1000; + } + showLapTime("cputemp"); + if (file_exists ("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")) { + exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $cpufreq); + $cpufreq = $cpufreq[0] / 1000; + } + showLapTime("cpufreq"); - if (defined("TEMPERATUREALERT") && $cputemp > TEMPERATUREHIGHLEVEL && $cputemp !== NULL) { + if (defined("TEMPERATUREALERT") && $cputemp > TEMPERATUREHIGHLEVEL && $cputemp !== NULL) { ?> - + makeLayer('LYR1',x,y,200,100,'red',1,1); + $y) $cpu[$x] = round($y / $total * 100, 1); - $cpuusage = round($cpu['user'] + $cpu['sys'], 2); - showLapTime("cpuusage"); + $output = shell_exec('cat /proc/loadavg'); + $sysload = substr($output,0,strpos($output," "))*100; + showLapTime("sysload"); + $stat1 = file('/proc/stat'); + sleep(1); + $stat2 = file('/proc/stat'); + $info1 = explode(" ", preg_replace("!cpu +!", "", $stat1[0])); + $info2 = explode(" ", preg_replace("!cpu +!", "", $stat2[0])); + $dif = array(); + $dif['user'] = $info2[0] - $info1[0]; + $dif['nice'] = $info2[1] - $info1[1]; + $dif['sys'] = $info2[2] - $info1[2]; + $dif['idle'] = $info2[3] - $info1[3]; + $total = array_sum($dif); + $cpu = array(); + foreach($dif as $x=>$y) $cpu[$x] = round($y / $total * 100, 1); + $cpuusage = round($cpu['user'] + $cpu['sys'], 2); + showLapTime("cpuusage"); - $output = shell_exec('grep -c processor /proc/cpuinfo'); - $cpucores = $output; + $output = shell_exec('grep -c processor /proc/cpuinfo'); + $cpucores = $output; - $output = shell_exec('cat /proc/uptime'); - $uptime = format_time(substr($output,0,strpos($output," "))); - $idletime = format_time((substr($output,strpos($output," ")))/$cpucores); - showLapTime("idletime"); + $output = shell_exec('cat /proc/uptime'); + $uptime = format_time(substr($output,0,strpos($output," "))); + $idletime = format_time((substr($output,strpos($output," ")))/$cpucores); + showLapTime("idletime"); - if (defined("SHOWPOWERSTATE")) { - $pinStatus = trim(shell_exec("gpio -g read ".POWERONLINEPIN)); // Pin 18 - } - //returns 0 = low; 1 = high + if (defined("SHOWPOWERSTATE")) { + $pinStatus = trim(shell_exec("gpio -g read ".POWERONLINEPIN)); // Pin 18 + } + //returns 0 = low; 1 = high ?>
-I think, after all the time this dashboard is developed mainly by myself, it is time to say "Thank you" to all those, wo delivered some ideas or code into this project.
This are explicit named following persons:
Those, who felt forgotten, feel free to comit a change into github of this file.
-Many thanks to you all!
-Best 73, Kim, DG9VH
+Those, who felt forgotten, feel free to comit a change into github of this file.
+Many thanks to you all!
+Best 73, Kim, DG9VH