Update ServerStatistic.php
This commit is contained in:
parent
bd72559ef7
commit
308a23e6ed
1 changed files with 25 additions and 1 deletions
|
@ -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
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue