Fixes the jvb api stats

main
Yasen Pramatarov 2024-09-01 16:53:12 +03:00
parent b29f530575
commit 41a3e04d68
2 changed files with 12 additions and 1 deletions

View File

@ -35,8 +35,16 @@ function getJicofoStats($command) {
// get JVB data // get JVB data
function getJVBStatus() { function getJVBStatus() {
$status = trim(shell_exec('systemctl is-active jitsi-videobridge')); $status = trim(shell_exec('systemctl is-active jitsi-videobridge2'));
return ($status === 'active') ? 'running' : 'not running'; return ($status === 'active') ? 'running' : 'not running';
} }
function getJVBStats($command) {
$data = shell_exec($command);
$decodedData = json_decode($data, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return ['error' => 'Failed to decode the JSON reply from the service.'];
}
return $decodedData;
}
?> ?>

View File

@ -35,8 +35,11 @@ if ($request === '/nginx' || $request === "/$scriptname/nginx") {
// jvb status // jvb status
} elseif ($request === '/jvb' || $request === "/$scriptname/jvb") { } elseif ($request === '/jvb' || $request === "/$scriptname/jvb") {
$jvbStatsCommand = 'curl -s http://localhost:8080/stats';
$jvbStatsData = getJVBStats($jvbStatsCommand);
$data = [ $data = [
'jvb_status' => getJVBStatus(), 'jvb_status' => getJVBStatus(),
'jvb_API_stats' => $jvbStatsData,
]; ];
echo json_encode($data, JSON_PRETTY_PRINT) . "\n"; echo json_encode($data, JSON_PRETTY_PRINT) . "\n";