Fixes the jvb api stats
parent
b29f530575
commit
41a3e04d68
|
@ -35,8 +35,16 @@ function getJicofoStats($command) {
|
||||||
|
|
||||||
// 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-videobridge2'));
|
||||||
return ($status === 'active') ? 'running' : 'not running';
|
return ($status === 'active') ? 'running' : 'not running';
|
||||||
}
|
}
|
||||||
|
function getJVBStats($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;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -35,8 +35,11 @@ if ($request === '/nginx' || $request === "/$scriptname/nginx") {
|
||||||
|
|
||||||
// jvb status
|
// jvb status
|
||||||
} elseif ($request === '/jvb' || $request === "/$scriptname/jvb") {
|
} elseif ($request === '/jvb' || $request === "/$scriptname/jvb") {
|
||||||
|
$jvbStatsCommand = 'curl -s http://localhost:8080/stats';
|
||||||
|
$jvbStatsData = getJVBStats($jvbStatsCommand);
|
||||||
$data = [
|
$data = [
|
||||||
'jvb_status' => getJVBStatus(),
|
'jvb_status' => getJVBStatus(),
|
||||||
|
'jvb_API_stats' => $jvbStatsData,
|
||||||
];
|
];
|
||||||
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue