diff --git a/functions.php b/functions.php index b26bdff..e89769a 100644 --- a/functions.php +++ b/functions.php @@ -23,6 +23,14 @@ function getJicofoStatus() { $status = trim(shell_exec('systemctl is-active jicofo')); return ($status === 'active') ? 'running' : 'not running'; } +function getJicofoStats($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; +} // get JVB data diff --git a/index.php b/index.php index b7ec3d8..269e1cf 100644 --- a/index.php +++ b/index.php @@ -25,8 +25,11 @@ if ($request === '/nginx' || $request === "/$scriptname/nginx") { // jicofo status } elseif ($request === '/jicofo' || $request === "/$scriptname/jicofo") { + $jicofoStatsCommand = 'curl -s http://localhost:8888/stats'; + $jicofoStatsData = getJicofoStats($jicofoStatsCommand); $data = [ 'jicofo_status' => getJicofoStatus(), + 'jicofo_API_stats' => $jicofoStatsData; ]; echo json_encode($data, JSON_PRETTY_PRINT) . "\n";