get($_SESSION['domain']['language']['code'], 'core/user_settings');
//system status
echo "
\n";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//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 (!empty($percent_disk_usage)) {
//add half doughnut chart
echo "
\n";
echo "
".$text['label-disk_usage']."\n";
if ($dashboard_chart_type == "doughnut") {
?>
".round($percent_disk_usage)."%";
}
echo "
\n";
}
}
echo "
";
echo "
\n";
echo "\n";
echo "| ".$text['label-item']." | \n";
echo "".$text['label-value']." | \n";
echo "
\n";
//pbx version
echo "\n";
echo "| ".(isset($_SESSION['theme']['title']['text'])?$_SESSION['theme']['title']['text']:'FusionPBX')." | \n";
echo "".software::version()." | \n";
echo "
\n";
$c = ($c) ? 0 : 1;
//os uptime
if (stristr(PHP_OS, 'Linux')) {
$prefix = 'up ';
$linux_uptime = shell_exec('uptime -p');
$uptime = substr($linux_uptime, strlen($prefix));
if (!empty($uptime)) {
echo "\n";
echo "| ".$text['label-system_uptime']." | \n";
echo "".$uptime." | \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((float)shell_exec(escapeshellcmd($free." | ".$awk." 'FNR == 3 {print $3/($3+$4)*100}'")), 1);
if (!empty($percent_memory)) {
echo "\n";
echo "| ".$text['label-memory_usage']." | \n";
echo "".$percent_memory."% | \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 (!empty($result)) {
echo "\n";
echo "| ".$text['label-memory_available']." | \n";
echo "".$result." | \n";
echo "
\n";
$c = ($c) ? 0 : 1;
}
}
//disk usage
if (stristr(PHP_OS, 'Linux')) {
//calculated above
if (!empty($percent_disk_usage)) {
echo "\n";
echo "| ".$text['label-disk_usage']." | \n";
echo "".$percent_disk_usage."% | \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 (!empty($db_path) && !empty($dbfilename)) {
$tmp = shell_exec("lsof ".realpath($db_path).'/'.$dbfilename);
$tmp = explode("\n", $tmp);
$connections = sizeof($tmp) - 1;
}
}
if (!empty($sql)) {
if (!isset($database)) { $database = new database; }
$connections = $database->select($sql, null, 'column');
unset($sql);
}
if (!empty($connections)) {
echo "\n";
echo "| ".$text['label-database_connections']." | \n";
echo "".$connections." | \n";
echo "
\n";
$c = ($c) ? 0 : 1;
}
//channel count
$esl = event_socket::create();
if ($esl->is_connected()) {
$tmp = event_socket::api('status');
$matches = Array();
preg_match("/(\d+)\s+session\(s\)\s+\-\speak/", $tmp, $matches);
$channels = !empty($matches[1]) ? $matches[1] : 0;
$tr_link = "href='".PROJECT_PATH."/app/calls_active/calls_active.php'";
echo "\n";
echo "| ".$text['label-channels']." | \n";
echo "".$channels." | \n";
echo "
\n";
$c = ($c) ? 0 : 1;
}
//registration count
if ($esl->is_connected() && 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 "| ".$text['label-registrations']." | \n";
echo "".$registrations." | \n";
echo "
\n";
$c = ($c) ? 0 : 1;
}
echo "
\n";
echo "
";
//$n++;
echo "
";
echo "
\n";
?>