diff --git a/functions.php b/functions.php index e89769a..4145986 100644 --- a/functions.php +++ b/functions.php @@ -35,8 +35,16 @@ function getJicofoStats($command) { // get JVB data 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'; } +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; +} ?> diff --git a/index.php b/index.php index 9bb74c2..e5676e6 100644 --- a/index.php +++ b/index.php @@ -35,8 +35,11 @@ if ($request === '/nginx' || $request === "/$scriptname/nginx") { // jvb status } elseif ($request === '/jvb' || $request === "/$scriptname/jvb") { + $jvbStatsCommand = 'curl -s http://localhost:8080/stats'; + $jvbStatsData = getJVBStats($jvbStatsCommand); $data = [ 'jvb_status' => getJVBStatus(), + 'jvb_API_stats' => $jvbStatsData, ]; echo json_encode($data, JSON_PRETTY_PRINT) . "\n";