mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-12-27 07:31:09 +01:00
Merge pull request #1885 from RaspAP/feat/system-diskuse
Feature: System disk storage use
This commit is contained in:
@@ -91,10 +91,16 @@ function DisplaySystem(&$extraFooterScripts)
|
||||
|
||||
// memory use
|
||||
$memused = $system->usedMemory();
|
||||
$memStatus = getMemStatus($memused);
|
||||
$memStatus = getResourceStatus($memused);
|
||||
$memused_status = $memStatus['status'];
|
||||
$memused_led = $memStatus['led'];
|
||||
|
||||
// disk storage use
|
||||
$diskused = $system->usedDisk();
|
||||
$diskStatus = getResourceStatus($diskused);
|
||||
$diskused_status = $diskStatus['status'];
|
||||
$diskused_led = $diskStatus['led'];
|
||||
|
||||
// cpu load
|
||||
$cpuload = $system->systemLoadPercentage();
|
||||
$cpuload_status = getCPULoadStatus($cpuload);
|
||||
@@ -138,6 +144,9 @@ function DisplaySystem(&$extraFooterScripts)
|
||||
"memused",
|
||||
"memused_status",
|
||||
"memused_led",
|
||||
"diskused",
|
||||
"diskused_status",
|
||||
"diskused_led",
|
||||
"cpuload",
|
||||
"cpuload_status",
|
||||
"cputemp",
|
||||
@@ -150,25 +159,25 @@ function DisplaySystem(&$extraFooterScripts)
|
||||
));
|
||||
}
|
||||
|
||||
function getMemStatus($memused): array
|
||||
function getResourceStatus($used): array
|
||||
{
|
||||
$memused_status = "primary";
|
||||
$memused_led = "";
|
||||
$used_status = "primary";
|
||||
$used_led = "";
|
||||
|
||||
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";
|
||||
if ($used > 90) {
|
||||
$used_status = "danger";
|
||||
$used_led = "service-status-down";
|
||||
} elseif ($used > 75) {
|
||||
$used_status = "warning";
|
||||
$used_led = "service-status-warn";
|
||||
} elseif ($used > 0) {
|
||||
$used_status = "success";
|
||||
$used_led = "service-status-up";
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => $memused_status,
|
||||
'led' => $memused_led
|
||||
'status' => $used_status,
|
||||
'led' => $used_led
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1064,6 +1064,9 @@ msgstr "System Time"
|
||||
msgid "Memory Used"
|
||||
msgstr "Memory Used"
|
||||
|
||||
msgid "Storage Used"
|
||||
msgstr "Storage Used"
|
||||
|
||||
msgid "CPU Load"
|
||||
msgstr "CPU Load"
|
||||
|
||||
|
||||
@@ -46,12 +46,18 @@ class Sysinfo
|
||||
return $systime;
|
||||
}
|
||||
|
||||
public function usedMemory()
|
||||
public function usedMemory(): int
|
||||
{
|
||||
$used = shell_exec("free -m | awk 'NR==2{ total=$2 ; used=$3 } END { print used/total*100}'");
|
||||
return floor(intval($used));
|
||||
}
|
||||
|
||||
public function usedDisk(): int
|
||||
{
|
||||
$output = shell_exec("df -h / | awk 'NR==2 {print $5}'");
|
||||
return intval(str_replace('%', '', trim($output)));
|
||||
}
|
||||
|
||||
public function processorCount()
|
||||
{
|
||||
$procs = shell_exec("nproc --all");
|
||||
|
||||
@@ -40,6 +40,13 @@ include('includes/sysstats.php');
|
||||
style="width: <?php echo htmlspecialchars($memused, ENT_QUOTES); ?>%"><?php echo htmlspecialchars($memused, ENT_QUOTES); ?>%
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-1"><?php echo _("Storage Used"); ?></div>
|
||||
<div class="progress mb-2" style="height: 20px;">
|
||||
<div class="progress-bar bg-<?php echo htmlspecialchars($diskused_status, ENT_QUOTES); ?>"
|
||||
role="progressbar" aria-valuenow="<?php echo htmlspecialchars($diskused, ENT_QUOTES); ?>" aria-valuemin="0" aria-valuemax="100"
|
||||
style="width: <?php echo htmlspecialchars($diskused, ENT_QUOTES); ?>%"><?php echo htmlspecialchars($diskused, ENT_QUOTES); ?>%
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-1"><?php echo _("CPU Load"); ?></div>
|
||||
<div class="progress mb-2" style="height: 20px;">
|
||||
<div class="progress-bar bg-<?php echo htmlspecialchars($cpuload_status, ENT_QUOTES); ?>"
|
||||
|
||||
Reference in New Issue
Block a user