Adds config file.

main
Yasen Pramatarov 2024-09-01 16:57:57 +03:00
parent 41a3e04d68
commit 27ec647ef5
3 changed files with 11 additions and 3 deletions

7
config.php 100644
View File

@ -0,0 +1,7 @@
<?php
$jicofoStatsURL = 'http://localhost:8888/stats';
$jvbStatsURL = 'http://localhost:8080/colibri/stats';
$nginxPort = '80';
?>

View File

@ -6,7 +6,7 @@ function getNginxStatus() {
return ($status === 'active') ? 'running' : 'not running'; return ($status === 'active') ? 'running' : 'not running';
} }
function getNginxConnections() { function getNginxConnections() {
$connections = shell_exec("netstat -an | grep ':80' | wc -l"); $connections = shell_exec("netstat -an | grep ':$nginxPort' | wc -l");
return intval(trim($connections)); return intval(trim($connections));
} }

View File

@ -1,5 +1,6 @@
<?php <?php
require 'config.php';
include 'functions.php'; include 'functions.php';
$scriptname = basename($_SERVER['SCRIPT_NAME']); $scriptname = basename($_SERVER['SCRIPT_NAME']);
@ -25,7 +26,7 @@ if ($request === '/nginx' || $request === "/$scriptname/nginx") {
// jicofo status // jicofo status
} elseif ($request === '/jicofo' || $request === "/$scriptname/jicofo") { } elseif ($request === '/jicofo' || $request === "/$scriptname/jicofo") {
$jicofoStatsCommand = 'curl -s http://localhost:8888/stats'; $jicofoStatsCommand = "curl -s $jicofoStatsURL";
$jicofoStatsData = getJicofoStats($jicofoStatsCommand); $jicofoStatsData = getJicofoStats($jicofoStatsCommand);
$data = [ $data = [
'jicofo_status' => getJicofoStatus(), 'jicofo_status' => getJicofoStatus(),
@ -35,7 +36,7 @@ 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'; $jvbStatsCommand = "curl -s $jvbStatsURL";
$jvbStatsData = getJVBStats($jvbStatsCommand); $jvbStatsData = getJVBStats($jvbStatsCommand);
$data = [ $data = [
'jvb_status' => getJVBStatus(), 'jvb_status' => getJVBStatus(),