Fixes status checks

main
Yasen Pramatarov 2024-09-01 16:40:47 +03:00
parent 8c97bd2873
commit 813a9594fb
2 changed files with 34 additions and 14 deletions

View File

@ -10,22 +10,25 @@ function getNginxConnections() {
return intval(trim($connections));
}
// get prosody data
function getProsodyStatus() {
$status = trim(shell_exec('systemctl is-active prosody'));
return ($status === 'active') ? 'running' : 'not running';
}
// get jicofo data
function getJicofoStatus() {
$status = trim(shell_exec('systemctl is-active jicofo'));
return ($status === 'active') ? 'running' : 'not running';
}
// get JVB data
function getJVBStatus() {
$status = trim(shell_exec('systemctl is-active jitsi-videobridge'));
return ($status === 'active') ? 'running' : 'not running';
}
function getProsodyStatus() {
$status = trim(shell_exec('systemctl is-active prosody'));
return ($status === 'active') ? 'running' : 'not running';
}
function getJicofoStatus() {
$status = trim(shell_exec('systemctl is-active jicofo'));
return ($status === 'active') ? 'running' : 'not running';
}
?>

View File

@ -2,19 +2,36 @@
include 'functions.php';
$scriptname = basename($_SERVER['SCRIPT_NAME']);
$request = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
// the response is in JSON
header('Content-Type: application/json');
// nginx status
if ($_SERVER['REQUEST_URI'] === '/nginx') {
if ($request === '/nginx' || $request === "/$scriptname/nginx") {
$data = [
'nginx_status' => getNginxStatus(),
'nginx_connections' => getNginxConnections(),
];
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
// prosody status
} elseif ($request === '/prosody' || $request === "/$scriptname/prosody") {
$data = [
'prosody_status' => getProsodyStatus(),
];
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
// jicofo status
} elseif ($request === '/jicofo' || $request === "/$scriptname/jicofo") {
$data = [
'jicofo_status' => getJicofoStatus(),
];
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
// jvb status
} elseif ($_SERVER['REQUEST_URI'] === '/jvb') {
} elseif ($request === '/jvb' || $request === "/$scriptname/jvb") {
$data = [
'jvb_status' => getJVBStatus(),
];