Adds simple status checks for nginx and JVB
parent
4e8de4b728
commit
8c97bd2873
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
// get nginx data
|
||||
function getNginxStatus() {
|
||||
$status = trim(shell_exec('systemctl is-active nginx'));
|
||||
return ($status === 'active') ? 'running' : 'not running';
|
||||
}
|
||||
function getNginxConnections() {
|
||||
$connections = shell_exec("netstat -an | grep ':80' | wc -l");
|
||||
return intval(trim($connections));
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
include 'functions.php';
|
||||
|
||||
// the response is in JSON
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// nginx status
|
||||
if ($_SERVER['REQUEST_URI'] === '/nginx') {
|
||||
$data = [
|
||||
'nginx_status' => getNginxStatus(),
|
||||
'nginx_connections' => getNginxConnections(),
|
||||
];
|
||||
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
||||
|
||||
// jvb status
|
||||
} elseif ($_SERVER['REQUEST_URI'] === '/jvb') {
|
||||
$data = [
|
||||
'jvb_status' => getJVBStatus(),
|
||||
];
|
||||
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
||||
|
||||
// default response - error
|
||||
} else {
|
||||
echo json_encode(['error' => 'Endpoint not found']) . "\n";
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
// nginx status
|
||||
if ($_SERVER['REQUEST_URI'] === '/nginx/status') {
|
||||
echo json_encode(['nginx' => shell_exec('/etc/init.d/nginx status')]);
|
||||
|
||||
// jvb status
|
||||
} elseif ($_SERVER['REQUEST_URI'] === '/jvb/status') {
|
||||
echo json_encode(['jvb' => shell_exec('/etc/init.d/jitsi-videobridge status')]);
|
||||
|
||||
// default response - error
|
||||
} else {
|
||||
echo json_encode(['error' => 'Endpoint not found']);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue