get($_SESSION['domain']['language']['code'], 'core/user_settings');
//system status
echo "
\n";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//get the CPU details
if (stristr(PHP_OS, 'BSD') || 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; }
}
if (stristr(PHP_OS, 'BSD')) {
$result = shell_exec("dmesg | grep -i --max-count 1 CPUs | sed 's/[^0-9]*//g'");
$cpu_cores = trim($result);
}
if (stristr(PHP_OS, 'Linux')) {
$result = @trim(shell_exec("grep -P '^processor' /proc/cpuinfo"));
$cpu_cores = count(explode("\n", $result));
}
if ($cpu_cores > 1) { $percent_cpu = $percent_cpu / $cpu_cores; }
$percent_cpu = round($percent_cpu, 2);
//uptime
$result = shell_exec('uptime');
$load_average = sys_getloadavg();
}
//get memory details
$memory_details = get_memory_details();
//disk usage
if (PHP_OS == 'FreeBSD' || PHP_OS == 'Linux') {
$tmp = shell_exec("df -h / 2>&1"); // Added -h for human-readable sizes
$tmp = explode("\n", $tmp);
$tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space
$tmp = explode(' ', $tmp);
// Extract values (columns may vary slightly by OS)
$used_space = $tmp[2] ?? '-';
$total_space = $tmp[1] ?? '-';
$percent_disk_usage = '';
foreach ($tmp as $stat) {
if (substr_count($stat, '%') > 0) { $percent_disk_usage = rtrim($stat,'%'); break; }
}
}
//include websocket real-time updates
$token = (new token())->create($_SERVER['PHP_SELF']);
echo "
\n";
subscriber::save_token($token, [system_dashboard_service::get_service_name()]);
?>
\n";
echo "
".$text['label-system_status']." \n";
if ($widget_chart_type == "doughnut") {
?>
".round($percent_disk_usage)."%";
}
if (!isset($widget_chart_type) || $widget_chart_type == "progress_bar") {
//cpu usage
if ($widget_row_span > 1) {
echo "
".$text['label-processor_usage']." \n";
echo "
\n";
echo "
get('theme', 'dashboard_cpu_usage_chart_main_color') ?? '#03c04a')."; transition: 1.5s;'>".($percent_cpu > 100 ? 100 : round($percent_cpu))."%
\n";
echo "
\n";
echo "
\n";
}
//disk usage
if ($widget_row_span >= 1) {
echo "
".$text['label-disk_usage']." \n";
echo "
\n";
echo "
get('theme', 'dashboard_disk_usage_chart_main_color') ?? '#03c04a').";'>".round($percent_disk_usage)."%
\n";
echo "
\n";
echo "
\n";
}
//percent memory
if ($widget_row_span > 1) {
echo "
".$text['label-memory_usage']." \n";
echo "
\n";
echo "
get('theme', 'dashboard_disk_usage_chart_main_color') ?? '#03c04a').";'>".round((int)$memory_details['memory_percent'])."%
\n";
echo "
\n";
}
}
echo "
\n";
if ($widget_details_state != 'disabled') {
echo "