Check the readability before acessing /proc/loadavg
This commit is contained in:
parent
e198edf652
commit
d43122c6d8
|
@ -442,10 +442,13 @@ class System
|
||||||
*/
|
*/
|
||||||
public static function getLoadAvg(): array
|
public static function getLoadAvg(): array
|
||||||
{
|
{
|
||||||
|
if (is_readable('/proc/loadavg')) {
|
||||||
$content = @file_get_contents('/proc/loadavg');
|
$content = @file_get_contents('/proc/loadavg');
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
$content = shell_exec('cat /proc/loadavg');
|
$content = shell_exec('cat /proc/loadavg');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($content) || !preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) {
|
if (empty($content) || !preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) {
|
||||||
$load_arr = sys_getloadavg();
|
$load_arr = sys_getloadavg();
|
||||||
if (empty($load_arr)) {
|
if (empty($load_arr)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user