From d43122c6d8eb7ef59b36299f1e1296c81f6a2799 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 18 Oct 2022 08:02:55 +0000 Subject: [PATCH] Check the readability before acessing /proc/loadavg --- src/Core/System.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Core/System.php b/src/Core/System.php index 0c1e499d9..8a8f273a8 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -442,10 +442,13 @@ class System */ public static function getLoadAvg(): array { - $content = @file_get_contents('/proc/loadavg'); - if (empty($content)) { - $content = shell_exec('cat /proc/loadavg'); + if (is_readable('/proc/loadavg')) { + $content = @file_get_contents('/proc/loadavg'); + if (empty($content)) { + $content = shell_exec('cat /proc/loadavg'); + } } + if (empty($content) || !preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) { $load_arr = sys_getloadavg(); if (empty($load_arr)) {