PHP function sys_getloadavg()

Version availability: PHP 5.1.3

Gets the average system load. Same values as you know from the htop tool in Linux.

Example:

php
$load = sys_getloadavg();
if ($load[0] > 0.80) { // is the load greater than 80%?
header('HTTP/1.1 503 Too busy, try again later');
die('Server is overloaded, try again later.');
}

Parameters

The function has no input parameters.

Return values

array

Array with three samples (last 1 minute, 5 minutes and 15 minutes).

Other resources

Official sys-getloadavg documentation

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.