forked from laysense/laysite
Address system information and license review suggestions
This commit is contained in:
@@ -38,7 +38,7 @@ final class SystemInfo
|
||||
{
|
||||
return [
|
||||
'cpu' => PHP_OS_FAMILY === 'Linux' ? self::cpu() : null,
|
||||
'memory' => PHP_OS_FAMILY === 'Linux' ? self::memory() : null,
|
||||
'memory' => self::memory(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -58,8 +58,11 @@ final class SystemInfo
|
||||
return ['total' => array_sum(array_slice($fields, 1, 8)), 'idle' => $fields[4] + $fields[5]];
|
||||
}
|
||||
|
||||
private static function memory(): ?string
|
||||
public static function memory(): ?string
|
||||
{
|
||||
if (PHP_OS_FAMILY !== 'Linux') {
|
||||
return null;
|
||||
}
|
||||
$info = @file_get_contents('/proc/meminfo');
|
||||
if ($info === false || !preg_match('/^MemTotal:\s+(\d+) kB$/m', $info, $total)
|
||||
|| !preg_match('/^MemAvailable:\s+(\d+) kB$/m', $info, $available) || (int) $total[1] === 0) {
|
||||
|
||||
Reference in New Issue
Block a user