X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FSystem.php;h=b2da78f1b3509d9a2ff5f16d147d1efd42c45e3e;hb=da1c13368b55546a0a998abd8aedcc9849b44a09;hp=eb27fa351775b3e90ec6be9d230d42701f2acee0;hpb=934a3a6721ee40b8d658dc8a38a530642283bf47;p=friendica.git diff --git a/src/Core/System.php b/src/Core/System.php index eb27fa3517..b2da78f1b3 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -323,12 +323,12 @@ class System * After finishing the process is getting killed. * * @param string $content - * @param [type] $responce + * @param string $type * @param string|null $content_type * @return void */ - public static function httpExit(string $content, string $responce = Response::TYPE_HTML, ?string $content_type = null) { - DI::apiResponse()->setType($responce, $content_type); + public static function httpExit(string $content, string $type = Response::TYPE_HTML, ?string $content_type = null) { + DI::apiResponse()->setType($type, $content_type); DI::apiResponse()->addContent($content); DI::page()->exit(DI::apiResponse()->generate()); @@ -442,17 +442,27 @@ class System */ public static function getLoadAvg(): array { - $content = file_get_contents('/proc/loadavg'); - if (empty($content)) { - $content = shell_exec('cat /proc/loadavg'); - } - if (empty($content)) { - return []; + if (@is_readable('/proc/loadavg')) { + $content = @file_get_contents('/proc/loadavg'); + if (empty($content)) { + $content = shell_exec('cat /proc/loadavg'); + } } - if (!preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) { - return []; + if (empty($content) || !preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) { + $load_arr = sys_getloadavg(); + if (empty($load_arr)) { + return []; + } + return [ + 'average1' => $load_arr[0], + 'average5' => $load_arr[1], + 'average15' => $load_arr[2], + 'runnable' => 0, + 'scheduled' => 0 + ]; } + return [ 'average1' => (float)$matches[1], 'average5' => (float)$matches[2],