Address system information and license review suggestions

This commit is contained in:
2026-11-25 22:16:38 +08:00
parent 080f146fef
commit df3722ae36
11 changed files with 78 additions and 39 deletions
+5 -2
View File
@@ -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) {