Fixes the status checks

main
Yasen Pramatarov 2024-09-01 16:49:43 +03:00
parent 813a9594fb
commit f78ef4fe40
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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";