Update ServerStatistic.php

This commit is contained in:
Bozhidar Slaveykov 2024-04-04 20:23:09 +03:00
parent bd72559ef7
commit 308a23e6ed

View file

@ -37,9 +37,33 @@ class ServerStatistic
}
$diskMemoryExec = shell_exec('df -h | grep /dev/sda1 | awk \'{print $2 " " $3 " " $4 " " $5 " " $6}\'');
$diskMemoryExp = explode(' ', $diskMemoryExec);
$diskMemory = [
'total' => 0,
'used' => 0,
'free' => 0,
'usedPercentage' => 0,
'mountedOn' => ''
];
if (isset($diskMemoryExp[0])) {
$diskMemory['total'] = $diskMemoryExp[0];
}
if (isset($diskMemoryExp[1])) {
$diskMemory['used'] = $diskMemoryExp[1];
}
if (isset($diskMemoryExp[2])) {
$diskMemory['free'] = $diskMemoryExp[2];
}
if (isset($diskMemoryExp[3])) {
$diskMemory['usedPercentage'] = $diskMemoryExp[3];
}
return $memory;
return [
'memory' => $memory,
'disk' => $diskMemory
];
}