From 67aad6d611edee2d7835a842ed9796d63776e3c1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 26 Mar 2022 14:25:26 -0600 Subject: [PATCH] Add switch status to the dashboard --- app/switch/app_config.php | 33 ++++ app/switch/app_languages.php | 135 ++++++++++++++ app/switch/resources/dashboard/config.php | 16 ++ .../resources/dashboard/switch_status.php | 173 ++++++++++++++++++ 4 files changed, 357 insertions(+) create mode 100644 app/switch/app_config.php create mode 100644 app/switch/app_languages.php create mode 100644 app/switch/resources/dashboard/config.php create mode 100644 app/switch/resources/dashboard/switch_status.php diff --git a/app/switch/app_config.php b/app/switch/app_config.php new file mode 100644 index 0000000000..9ccf373f07 --- /dev/null +++ b/app/switch/app_config.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/app/switch/app_languages.php b/app/switch/app_languages.php new file mode 100644 index 0000000000..96d677de40 --- /dev/null +++ b/app/switch/app_languages.php @@ -0,0 +1,135 @@ + \ No newline at end of file diff --git a/app/switch/resources/dashboard/config.php b/app/switch/resources/dashboard/config.php new file mode 100644 index 0000000000..efb1070e47 --- /dev/null +++ b/app/switch/resources/dashboard/config.php @@ -0,0 +1,16 @@ + diff --git a/app/switch/resources/dashboard/switch_status.php b/app/switch/resources/dashboard/switch_status.php new file mode 100644 index 0000000000..33b2278593 --- /dev/null +++ b/app/switch/resources/dashboard/switch_status.php @@ -0,0 +1,173 @@ +get($_SESSION['domain']['language']['code'], 'app/switch'); + +//switch status + echo "
\n"; + +//set the row style class names + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//connect to event socket + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//switch version + if ($fp) { + $switch_version = event_socket_request($fp, 'api version'); + preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(.*?(\d+\w+)\s*\)/", $switch_version, $matches); + $switch_version = $matches[1]; + $switch_bits = $matches[2]; + } + +//switch uptime + if ($fp) { + $tmp = event_socket_request($fp, 'api status'); + $tmp = explode("\n", $tmp); + $tmp = $tmp[0]; + $tmp = explode(' ', $tmp); + $uptime = (($tmp[1]) ? $tmp[1].'y ' : null); + $uptime .= (($tmp[3]) ? $tmp[3].'d ' : null); + $uptime .= (($tmp[5]) ? $tmp[5].'h ' : null); + $uptime .= (($tmp[7]) ? $tmp[7].'m ' : null); + $uptime .= (($tmp[9]) ? $tmp[9].'s' : null); + if (permission_exists('system_status_sofia_status') || permission_exists('system_status_sofia_status_profile') || if_group("superadmin")) { + $tr_link_sip_status = "href='".PROJECT_PATH."/app/sip_status/sip_status.php'"; + } + } + +//channel count + if ($fp) { + $tmp = event_socket_request($fp, 'api status'); + $matches = Array(); + preg_match("/(\d+)\s+session\(s\)\s+\-\speak/", $tmp, $matches); + $channels = $matches[1] ? $matches[1] : 0; + if (permission_exists('call_active_view')) { + $tr_link_channels = "href='".PROJECT_PATH."/app/calls_active/calls_active.php'"; + } + } + +//registration count + if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { + $registration = new registrations; + $registrations = $registration->count(); + if (permission_exists("registration_all") || if_group("superadmin")) { + $tr_link_registrations = "href='".PROJECT_PATH."/app/registrations/registrations.php'"; + } + } + +//add doughnut chart + ?> +
+
+
+ + + "; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //switch version + if ($switch_version != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //switch uptime + if ($uptime != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + + //switch channels + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + + //switch registrations + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + + + echo "
".$text['label-name']."".$text['label-value']."
\n"; + echo "
"; + $n++; + + echo ""; + echo "\n"; + +?>