1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
Daniel Neto 2024-12-27 17:16:01 -03:00
parent 360d70e29e
commit d89471174f
9 changed files with 68 additions and 47 deletions

View file

@ -31,6 +31,7 @@ function getFfmpegProcesses()
'pidEncrypted' => encryptString($parts[1]), 'pidEncrypted' => encryptString($parts[1]),
'cpu' => $parts[2], 'cpu' => $parts[2],
'mem' => $parts[3], 'mem' => $parts[3],
'runtime' => $parts[9], // Extracts the elapsed time (e.g., "00:05:32")
'command' => $parts[10], 'command' => $parts[10],
]; ];
} }
@ -39,6 +40,7 @@ function getFfmpegProcesses()
return $processes; return $processes;
} }
// Handle AJAX requests // Handle AJAX requests
if (isset($_GET['action']) && $_GET['action'] === 'fetch') { if (isset($_GET['action']) && $_GET['action'] === 'fetch') {
header('Content-Type: application/json'); header('Content-Type: application/json');
@ -74,22 +76,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['pid'], $_POST['csrf_t
exit; exit;
} }
// Load the page
$_page = new Page('FFmpeg Process Manager');
$_page->setExtraScripts(array('node_modules/chart.js/dist/chart.umd.js', 'view/css/DataTables/datatables.min.js'));
$_page->setExtraStyles(
array(
'view/css/DataTables/datatables.min.css'
)
);
?> ?>
<script src="<?php echo getURL('node_modules/chart.js/dist/chart.umd.js'); ?>" type="text/javascript"></script>
<script src="<?php echo getURL('view/css/DataTables/datatables.min.js'); ?>" type="text/javascript"></script>
<link href="<?php echo getURL('view/css/DataTables/datatables.min.css'); ?>" rel="stylesheet" type="text/css" />
<div class="container-fluid"> <div class="container-fluid">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h1 class="text-center">FFmpeg Process Manager</h1> <h1 class="text-center">FFmpeg Monitor</h1>
</div> </div>
<div class="panel-body"> <div class="panel-body">
@ -118,6 +114,7 @@ $_page->setExtraStyles(
<th>PID</th> <th>PID</th>
<th>CPU%</th> <th>CPU%</th>
<th>MEM%</th> <th>MEM%</th>
<th>Runtime</th> <!-- New Column -->
<th>Command</th> <th>Command</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
@ -146,6 +143,7 @@ $_page->setExtraStyles(
null, null,
null, null,
null, null,
null,
{ {
"orderable": false "orderable": false
} }
@ -203,7 +201,7 @@ $_page->setExtraStyles(
// Fetch processes and update the table and charts // Fetch processes and update the table and charts
function fetchCPUProcesses() { function fetchCPUProcesses() {
$.ajax({ $.ajax({
url: webSiteRootURL + 'view/ffmpegMonitor.php?action=fetch', url: webSiteRootURL + 'admin/ffmpegMonitor.php?action=fetch',
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
@ -215,7 +213,7 @@ $_page->setExtraStyles(
processRAM.length = 0; processRAM.length = 0;
data.forEach(process => { data.forEach(process => {
table.row.add([process.user, process.pid, process.cpu, process.mem, process.command, `<button class="btn btn-danger btn-kill btn-block" data-pid="${process.pidEncrypted}">Kill</button>`]); table.row.add([process.user, process.pid, process.cpu, process.mem,process.runtime, process.command, `<button class="btn btn-danger btn-kill btn-block" data-pid="${process.pidEncrypted}">Kill</button>`]);
totalCPU += parseFloat(process.cpu); totalCPU += parseFloat(process.cpu);
totalRAM += parseFloat(process.mem); totalRAM += parseFloat(process.mem);
@ -243,6 +241,9 @@ $_page->setExtraStyles(
historicalLine.data.datasets[0].data = historicalCPU; historicalLine.data.datasets[0].data = historicalCPU;
historicalLine.data.datasets[1].data = historicalRAM; historicalLine.data.datasets[1].data = historicalRAM;
historicalLine.update(); historicalLine.update();
setTimeout(() => {
fetchCPUProcesses();
}, 2000);
}, },
error: function() { error: function() {
alert('Failed to fetch process data.'); alert('Failed to fetch process data.');
@ -250,13 +251,7 @@ $_page->setExtraStyles(
}); });
} }
// Refresh data every 5 seconds
setInterval(fetchCPUProcesses, 5000);
// Initial fetch // Initial fetch
fetchCPUProcesses(); fetchCPUProcesses();
}); });
</script> </script>
<?php
$_page->print();

View file

@ -100,6 +100,9 @@ $itens[] = $menu;
$menu = new MenuAdmin(__("Health Check"), "fas fa-notes-medical", "health_check"); $menu = new MenuAdmin(__("Health Check"), "fas fa-notes-medical", "health_check");
$itens[] = $menu; $itens[] = $menu;
$menu = new MenuAdmin(__("FFmpeg Monitor"), "fas fa-film", "ffmpeg_monitor");
$itens[] = $menu;
$_GET['page'] = xss_esc(@$_GET['page']); $_GET['page'] = xss_esc(@$_GET['page']);
$includeHead = ''; $includeHead = '';
@ -184,6 +187,9 @@ switch ($_GET['page']) {
case "health_check": case "health_check":
$includeBody = $global['systemRootPath'] . 'admin/health_check.php'; $includeBody = $global['systemRootPath'] . 'admin/health_check.php';
break; break;
case "ffmpeg_monitor":
$includeBody = $global['systemRootPath'] . 'admin/ffmpegMonitor.php';
break;
default: default:
$includeHead = $global['systemRootPath'] . 'view/charts_head.php'; $includeHead = $global['systemRootPath'] . 'view/charts_head.php';
$includeBody = $global['systemRootPath'] . 'view/charts_body.php'; $includeBody = $global['systemRootPath'] . 'view/charts_body.php';
@ -197,31 +203,38 @@ if (!empty($includeHead) && file_exists($includeHead)) {
?> ?>
<style> <style>
@media (max-width: 767px) { @media (max-width: 767px) {
.affix { .affix {
position: static; position: static;
} }
} }
.leftMenu .panel-body {
.leftMenu .panel-body {
padding: 0px; padding: 0px;
} }
.adminLeftMenu.panel-default i, .adminLeftMenu.panel-default{
.adminLeftMenu.panel-default i,
.adminLeftMenu.panel-default {
-webkit-transition: opacity 0.5s ease-in-out; -webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out; transition: opacity 0.5s ease-in-out;
} }
.adminLeftMenu.panel-default i{
.adminLeftMenu.panel-default i {
opacity: 0.2; opacity: 0.2;
} }
.adminLeftMenu:hover.panel-default i{
.adminLeftMenu:hover.panel-default i {
opacity: 1; opacity: 1;
} }
.adminLeftMenu.panel-default{
.adminLeftMenu.panel-default {
opacity: 0.6; opacity: 0.6;
} }
.adminLeftMenu:hover.panel-default{
.adminLeftMenu:hover.panel-default {
opacity: 1; opacity: 1;
} }
</style> </style>
<div class="container-fluid"> <div class="container-fluid">
<br> <br>

View file

@ -3050,6 +3050,7 @@ function clearCache($firstPageOnly = false)
function clearAllUsersSessionCache() function clearAllUsersSessionCache()
{ {
_error_log("clearAllUsersSessionCache ".json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
sendSocketMessageToAll(time(), 'socketClearSessionCache'); sendSocketMessageToAll(time(), 'socketClearSessionCache');
} }

View file

@ -291,6 +291,8 @@ if ($obj->video['status'] == Video::$statusActive) {
_error_log('clearFirstPageCache end'); _error_log('clearFirstPageCache end');
//clearAllUsersSessionCache(); //clearAllUsersSessionCache();
} }
// it cannot clear async otherwise it will cause issues on the videos manager list.
$obj->clearCache = Video::clearCache($obj->videos_id, false, false, false);
$rowsPath[] = array('line' => __LINE__, 'ElapsedTime' => getElapsedTime()); $rowsPath[] = array('line' => __LINE__, 'ElapsedTime' => getElapsedTime());
$obj->rowsPath = $rowsPath; $obj->rowsPath = $rowsPath;
TimeLogEnd(__FILE__, __LINE__); TimeLogEnd(__FILE__, __LINE__);

View file

@ -310,7 +310,7 @@ $ffmpegCommand = addKeywordToFFmpegCommand($ffmpegCommand, $keyword);
file_put_contents($logFile, $ffmpegCommand.PHP_EOL.PHP_EOL); file_put_contents($logFile, $ffmpegCommand.PHP_EOL.PHP_EOL);
$ffmpegCommand .= " > {$logFile} 2>&1"; $ffmpegCommand .= " > {$logFile} 2>&1";
_error_log("Executing FFMPEG Command [$keyword]: $ffmpegCommand"); _error_log("Executing FFMPEG Command [$keyword]: $ffmpegCommand ".json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
try { try {
$pid = execAsync($ffmpegCommand, $keyword); $pid = execAsync($ffmpegCommand, $keyword);

View file

@ -747,7 +747,7 @@ Disallow: *action=tagsearch*
if (!Permissions::canAdminVideos()) { if (!Permissions::canAdminVideos()) {
return false; return false;
} }
$video = new Video('', '', $videos_id); $video = new Video('', '', $videos_id, true);
$users_id = $video->getUsers_id(); $users_id = $video->getUsers_id();
$user = new User($users_id); $user = new User($users_id);
return $user->addExternalOptions('doNotShowAdsOnThisChannel', $doNotShowAdsOnThisChannel); return $user->addExternalOptions('doNotShowAdsOnThisChannel', $doNotShowAdsOnThisChannel);

View file

@ -9,7 +9,7 @@ $obj->liveTransmitionHistory_id = 0;
_error_log("NGINX ON Publish POST: " . json_encode($_POST)); _error_log("NGINX ON Publish POST: " . json_encode($_POST));
_error_log("NGINX ON Publish GET: " . json_encode($_GET)); _error_log("NGINX ON Publish GET: " . json_encode($_GET));
_error_log("NGINX ON Publish php://input" . file_get_contents("php://input")); _error_log("NGINX ON Publish php://input " . file_get_contents("php://input"));
// get GET parameters // get GET parameters
$url = $_POST['tcurl']; $url = $_POST['tcurl'];

View file

@ -129,7 +129,7 @@ if (empty($meet_schedule_id)) {
openBridgeChannel: 'websocket', openBridgeChannel: 'websocket',
liveStreamingEnabled: true, liveStreamingEnabled: true,
fileRecordingsEnabled: false, fileRecordingsEnabled: false,
inviteUrl: window.location.href //inviteUrl: window.location.href
}, },
interfaceConfigOverwrite: { interfaceConfigOverwrite: {
TOOLBAR_BUTTONS: TOOLBAR_BUTTONS, TOOLBAR_BUTTONS: TOOLBAR_BUTTONS,

View file

@ -1946,7 +1946,14 @@ async function checkDescriptionArea() {
} }
}); });
} }
var clearCacheExecuted = false;
function clearCache(showPleaseWait, FirstPage, sessionOnly) { function clearCache(showPleaseWait, FirstPage, sessionOnly) {
if(clearCacheExecuted){
return false;
}
clearCacheExecuted = true;
console.trace();
if (showPleaseWait) { if (showPleaseWait) {
modal.showPleaseWait(); modal.showPleaseWait();
} }
@ -1956,6 +1963,9 @@ function clearCache(showPleaseWait, FirstPage, sessionOnly) {
if (showPleaseWait) { if (showPleaseWait) {
avideoResponse(response); avideoResponse(response);
modal.hidePleaseWait(); modal.hidePleaseWait();
setTimeout(() => {
clearCacheExecuted = false;
}, 1000);
} }
} }
}); });