mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Transfer template logic to includes, see #749 thx @mp035
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'config.php';
|
||||
require_once 'app/lib/system.php';
|
||||
|
||||
/**
|
||||
* Find the version of the Raspberry Pi
|
||||
@@ -151,5 +152,78 @@ function DisplaySystem()
|
||||
'vi_VN.UTF-8' => 'Tiếng Việt (Vietnamese)'
|
||||
);
|
||||
|
||||
echo renderTemplate("system", compact("arrLocales", "status", "serverPort", "serverBind"));
|
||||
#fetch system status variables.
|
||||
$system = new System();
|
||||
|
||||
$hostname = $system->hostname();
|
||||
$uptime = $system->uptime();
|
||||
$cores = $system->processorCount();
|
||||
|
||||
// mem used
|
||||
$memused = $system->usedMemory();
|
||||
$memused_status = "primary";
|
||||
if ($memused > 90) {
|
||||
$memused_status = "danger";
|
||||
$memused_led = "service-status-down";
|
||||
} elseif ($memused > 75) {
|
||||
$memused_status = "warning";
|
||||
$memused_led = "service-status-warn";
|
||||
} elseif ($memused > 0) {
|
||||
$memused_status = "success";
|
||||
$memused_led = "service-status-up";
|
||||
}
|
||||
|
||||
// cpu load
|
||||
$cpuload = $system->systemLoadPercentage();
|
||||
if ($cpuload > 90) {
|
||||
$cpuload_status = "danger";
|
||||
} elseif ($cpuload > 75) {
|
||||
$cpuload_status = "warning";
|
||||
} elseif ($cpuload >= 0) {
|
||||
$cpuload_status = "success";
|
||||
}
|
||||
|
||||
// cpu temp
|
||||
$cputemp = $system->systemTemperature();
|
||||
if ($cputemp > 70) {
|
||||
$cputemp_status = "danger";
|
||||
$cputemp_led = "service-status-down";
|
||||
} elseif ($cputemp > 50) {
|
||||
$cputemp_status = "warning";
|
||||
$cputemp_led = "service-status-warn";
|
||||
} else {
|
||||
$cputemp_status = "success";
|
||||
$cputemp_led = "service-status-up";
|
||||
}
|
||||
|
||||
// hostapd status
|
||||
$hostapd = $system->hostapdStatus();
|
||||
if ($hostapd[0] == 1) {
|
||||
$hostapd_status = "active";
|
||||
$hostapd_led = "service-status-up";
|
||||
} else {
|
||||
$hostapd_status = "inactive";
|
||||
$hostapd_led = "service-status-down";
|
||||
}
|
||||
|
||||
echo renderTemplate("system", compact(
|
||||
"arrLocales",
|
||||
"status",
|
||||
"serverPort",
|
||||
"serverBind",
|
||||
"hostname",
|
||||
"uptime",
|
||||
"cores",
|
||||
"memused",
|
||||
"memused_status",
|
||||
"memused_led",
|
||||
"cpuload",
|
||||
"cpuload_status",
|
||||
"cputemp",
|
||||
"cputemp_status",
|
||||
"cputemp_led",
|
||||
"hostapd",
|
||||
"hostapd_status",
|
||||
"hostapd_led"
|
||||
));
|
||||
}
|
||||
|
Reference in New Issue
Block a user