2024-09-01 13:29:59 +00:00
|
|
|
<?php
|
|
|
|
|
2024-09-01 13:57:57 +00:00
|
|
|
require 'config.php';
|
2024-09-01 13:29:59 +00:00
|
|
|
include 'functions.php';
|
|
|
|
|
2024-09-01 13:40:47 +00:00
|
|
|
$scriptname = basename($_SERVER['SCRIPT_NAME']);
|
|
|
|
$request = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
|
|
|
2024-09-01 13:29:59 +00:00
|
|
|
// the response is in JSON
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
|
|
|
// nginx status
|
2024-09-01 13:40:47 +00:00
|
|
|
if ($request === '/nginx' || $request === "/$scriptname/nginx") {
|
2024-09-01 13:29:59 +00:00
|
|
|
$data = [
|
|
|
|
'nginx_status' => getNginxStatus(),
|
|
|
|
'nginx_connections' => getNginxConnections(),
|
|
|
|
];
|
|
|
|
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
|
|
|
|
2024-09-01 13:40:47 +00:00
|
|
|
// 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") {
|
2024-09-01 13:57:57 +00:00
|
|
|
$jicofoStatsCommand = "curl -s $jicofoStatsURL";
|
2024-09-01 13:49:43 +00:00
|
|
|
$jicofoStatsData = getJicofoStats($jicofoStatsCommand);
|
2024-09-01 13:40:47 +00:00
|
|
|
$data = [
|
|
|
|
'jicofo_status' => getJicofoStatus(),
|
2024-09-01 13:50:28 +00:00
|
|
|
'jicofo_API_stats' => $jicofoStatsData,
|
2024-09-01 13:40:47 +00:00
|
|
|
];
|
|
|
|
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
|
|
|
|
2024-09-01 13:29:59 +00:00
|
|
|
// jvb status
|
2024-09-01 13:40:47 +00:00
|
|
|
} elseif ($request === '/jvb' || $request === "/$scriptname/jvb") {
|
2024-09-01 13:57:57 +00:00
|
|
|
$jvbStatsCommand = "curl -s $jvbStatsURL";
|
2024-09-01 13:53:12 +00:00
|
|
|
$jvbStatsData = getJVBStats($jvbStatsCommand);
|
2024-09-01 13:29:59 +00:00
|
|
|
$data = [
|
|
|
|
'jvb_status' => getJVBStatus(),
|
2024-09-01 13:53:12 +00:00
|
|
|
'jvb_API_stats' => $jvbStatsData,
|
2024-09-01 13:29:59 +00:00
|
|
|
];
|
|
|
|
echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
|
|
|
|
|
|
|
|
// default response - error
|
|
|
|
} else {
|
|
|
|
echo json_encode(['error' => 'Endpoint not found']) . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|