diff --git a/app/system/resources/dashboard/system_status.php b/app/system/resources/dashboard/system_status.php index fdbe9b84cb..aeada84ba9 100644 --- a/app/system/resources/dashboard/system_status.php +++ b/app/system/resources/dashboard/system_status.php @@ -19,303 +19,304 @@ $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings'); //system status - //if (is_array($selected_blocks) && in_array('system', $selected_blocks)) { - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; + echo "
\n"; - //cpu usage - if (stristr(PHP_OS, 'Linux')) { - $result = shell_exec('ps -A -o pcpu'); - $percent_cpu = 0; - foreach (explode("\n", $result) as $value) { - if (is_numeric($value)) { $percent_cpu = $percent_cpu + $value; } - } - $result = trim(shell_exec("grep -P '^processor' /proc/cpuinfo")); - $cores = count(explode("\n", $result)); - if ($percent_cpu > 1) { $percent_cpu = $percent_cpu / $cores; } - $percent_cpu = round($percent_cpu, 2); + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + //cpu usage + if (stristr(PHP_OS, 'Linux')) { + $result = shell_exec('ps -A -o pcpu'); + $percent_cpu = 0; + foreach (explode("\n", $result) as $value) { + if (is_numeric($value)) { $percent_cpu = $percent_cpu + $value; } + } + $result = trim(shell_exec("grep -P '^processor' /proc/cpuinfo")); + $cores = count(explode("\n", $result)); + if ($percent_cpu > 1) { $percent_cpu = $percent_cpu / $cores; } + $percent_cpu = round($percent_cpu, 2); + } + + //disk usage + if (PHP_OS == 'FreeBSD' || PHP_OS == 'Linux') { + $tmp = shell_exec("df /home 2>&1"); + $tmp = explode("\n", $tmp); + $tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space + $tmp = explode(' ', $tmp); + foreach ($tmp as $stat) { + if (substr_count($stat, '%') > 0) { $percent_disk_usage = rtrim($stat,'%'); break; } } - //disk usage - if (PHP_OS == 'FreeBSD' || PHP_OS == 'Linux') { - $tmp = shell_exec("df /home 2>&1"); - $tmp = explode("\n", $tmp); - $tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space - $tmp = explode(' ', $tmp); - foreach ($tmp as $stat) { - if (substr_count($stat, '%') > 0) { $percent_disk_usage = rtrim($stat,'%'); break; } - } + if ($percent_disk_usage != '') { + echo " +
+
+
%
+
- if ($percent_disk_usage != '') { - echo " -
-
-
%
-
+ + "; + } + } - var disk_chart_bgc; - if (".$percent_disk_usage." < 60) { - disk_chart_bgc = '#03c04a'; - } else if (".$percent_disk_usage." < 80 && ".$percent_disk_usage." > 60) { - disk_chart_bgc = '#ff9933'; - } else if (".$percent_disk_usage." >= 80) { - disk_chart_bgc = '#ea4c46'; - } + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; - const disk_chart_config = { - type: 'doughnut', - data: { - datasets: [{ - data:[".$percent_disk_usage.", 100 - ".$percent_disk_usage."], - backgroundColor: [disk_chart_bgc, '#d4d4d4'], - borderColor: 'rgba(0,0,0,0)', - cutout: chart_cutout - }] - }, - options: { - responsive: true, - maintainAspectRatio: false, - circumference: 180, - rotation: 270, - plugins: { - chart_counter_2: { - chart_text: ".$percent_disk_usage.", - }, - legend: { - display: false - }, - title: { - display: true, - text: '".$text['label-disk_usage']."' - } - } - }, - plugins: [chart_counter_2], - }; + //pbx version + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; - const disk_usage_chart = new Chart( - document.getElementById('disk_usage_chart'), - disk_chart_config - ); - - "; + //os uptime + if (stristr(PHP_OS, 'Linux')) { + unset($tmp); + $cut = shell_exec("/usr/bin/which cut"); + $uptime = trim(shell_exec(escapeshellcmd($cut." -d. -f1 /proc/uptime"))); + $tmp['y'] = floor($uptime/60/60/24/365); + $tmp['d'] = $uptime/60/60/24%365; + $tmp['h'] = $uptime/60/60%24; + $tmp['m'] = $uptime/60%60; + $tmp['s'] = $uptime%60; + $uptime = (($tmp['y'] != 0 && $tmp['y'] != '') ? $tmp['y'].'y ' : null); + $uptime .= (($tmp['d'] != 0 && $tmp['d'] != '') ? $tmp['d'].'d ' : null); + $uptime .= (($tmp['h'] != 0 && $tmp['h'] != '') ? $tmp['h'].'h ' : null); + $uptime .= (($tmp['m'] != 0 && $tmp['m'] != '') ? $tmp['m'].'m ' : null); + $uptime .= (($tmp['s'] != 0 && $tmp['s'] != '') ? $tmp['s'].'s' : null); + if ($uptime != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; } } - echo "
"; - echo "
".$text['label-item']."".$text['label-value']."
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + //memory usage (for available memory, use "free | awk 'FNR == 3 {print $4/($3+$4)*100}'" instead) + if (stristr(PHP_OS, 'Linux')) { + $free = shell_exec("/usr/bin/which free"); + $awk = shell_exec("/usr/bin/which awk"); + $percent_memory = round(shell_exec(escapeshellcmd($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'")), 1); + if ($percent_memory != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } - //pbx version + //memory available + if (stristr(PHP_OS, 'Linux')) { + $result = trim(shell_exec('free -hw | grep \'Mem:\' | cut -d\' \' -f 55-64')); + if ($result != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //disk usage + if (stristr(PHP_OS, 'Linux')) { + //calculated above + if ($percent_disk_usage != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //cpu usage + if (stristr(PHP_OS, 'Linux')) { + if ($percent_cpu != '') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } + } + + //db connections + switch ($db_type) { + case 'pgsql': + $sql = "select count(*) from pg_stat_activity"; + break; + case 'mysql': + $sql = "show status where `variable_name` = 'Threads_connected'"; + break; + default: + unset($sql); + if ($db_path != '' && $dbfilename != '') { + $tmp = shell_exec("lsof ".realpath($db_path).'/'.$dbfilename); + $tmp = explode("\n", $tmp); + $connections = sizeof($tmp) - 1; + } + } + if ($sql != '') { + $database = new database; + $connections = $database->select($sql, null, 'column'); + unset($sql); + } + if ($connections != '') { echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; $c = ($c) ? 0 : 1; + } - //os uptime - if (stristr(PHP_OS, 'Linux')) { - unset($tmp); - $cut = shell_exec("/usr/bin/which cut"); - $uptime = trim(shell_exec(escapeshellcmd($cut." -d. -f1 /proc/uptime"))); - $tmp['y'] = floor($uptime/60/60/24/365); - $tmp['d'] = $uptime/60/60/24%365; - $tmp['h'] = $uptime/60/60%24; - $tmp['m'] = $uptime/60%60; - $tmp['s'] = $uptime%60; - $uptime = (($tmp['y'] != 0 && $tmp['y'] != '') ? $tmp['y'].'y ' : null); - $uptime .= (($tmp['d'] != 0 && $tmp['d'] != '') ? $tmp['d'].'d ' : null); - $uptime .= (($tmp['h'] != 0 && $tmp['h'] != '') ? $tmp['h'].'h ' : null); - $uptime .= (($tmp['m'] != 0 && $tmp['m'] != '') ? $tmp['m'].'m ' : null); - $uptime .= (($tmp['s'] != 0 && $tmp['s'] != '') ? $tmp['s'].'s' : null); - if ($uptime != '') { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - } + //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; + $tr_link = "href='".PROJECT_PATH."/app/calls_active/calls_active.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } - //memory usage (for available memory, use "free | awk 'FNR == 3 {print $4/($3+$4)*100}'" instead) - if (stristr(PHP_OS, 'Linux')) { - $free = shell_exec("/usr/bin/which free"); - $awk = shell_exec("/usr/bin/which awk"); - $percent_memory = round(shell_exec(escapeshellcmd($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'")), 1); - if ($percent_memory != '') { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - } + //registration count + if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { + $registration = new registrations; + $registrations = $registration->count(); + $tr_link = "href='".PROJECT_PATH."/app/registrations/registrations.php'"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } - //memory available - if (stristr(PHP_OS, 'Linux')) { - $result = trim(shell_exec('free -hw | grep \'Mem:\' | cut -d\' \' -f 55-64')); - if ($result != '') { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - } - - //disk usage - if (stristr(PHP_OS, 'Linux')) { - //calculated above - if ($percent_disk_usage != '') { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - } - - //cpu usage - if (stristr(PHP_OS, 'Linux')) { - if ($percent_cpu != '') { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - } - - //db connections - switch ($db_type) { - case 'pgsql': - $sql = "select count(*) from pg_stat_activity"; - break; - case 'mysql': - $sql = "show status where `variable_name` = 'Threads_connected'"; - break; - default: - unset($sql); - if ($db_path != '' && $dbfilename != '') { - $tmp = shell_exec("lsof ".realpath($db_path).'/'.$dbfilename); - $tmp = explode("\n", $tmp); - $connections = sizeof($tmp) - 1; - } - } - if ($sql != '') { - $database = new database; - $connections = $database->select($sql, null, 'column'); - unset($sql); - } - if ($connections != '') { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - - //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; - $tr_link = "href='".PROJECT_PATH."/app/calls_active/calls_active.php'"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - - //registration count - if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { - $registration = new registrations; - $registrations = $registration->count(); - $tr_link = "href='".PROJECT_PATH."/app/registrations/registrations.php'"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - } - - echo "
".$text['label-item']."".$text['label-value']."
".$text['label-channels']."".$channels."
".$text['label-registrations']."".$registrations."
".$text['label-channels']."".$channels."
".$text['label-registrations']."".$registrations."
\n"; - echo "
"; - $n++; - //} - echo " "; + echo "\n"; + echo "
"; + $n++; + echo ""; + echo "\n"; ?>