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)); 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 // get JVB data
function getJVBStatus() { function getJVBStatus() {
$status = trim(shell_exec('systemctl is-active jitsi-videobridge')); $status = trim(shell_exec('systemctl is-active jitsi-videobridge'));
return ($status === 'active') ? 'running' : 'not running'; 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'; include 'functions.php';
$scriptname = basename($_SERVER['SCRIPT_NAME']);
$request = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
// the response is in JSON // the response is in JSON
header('Content-Type: application/json'); header('Content-Type: application/json');
// nginx status // nginx status
if ($_SERVER['REQUEST_URI'] === '/nginx') { if ($request === '/nginx' || $request === "/$scriptname/nginx") {
$data = [ $data = [
'nginx_status' => getNginxStatus(), 'nginx_status' => getNginxStatus(),
'nginx_connections' => getNginxConnections(), 'nginx_connections' => getNginxConnections(),
]; ];
echo json_encode($data, JSON_PRETTY_PRINT) . "\n"; 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 // jvb status
} elseif ($_SERVER['REQUEST_URI'] === '/jvb') { } elseif ($request === '/jvb' || $request === "/$scriptname/jvb") {
$data = [ $data = [
'jvb_status' => getJVBStatus(), 'jvb_status' => getJVBStatus(),
]; ];