FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Load.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Rsi\Fred\Health\Check;
4 
5 class Load extends \Rsi\Fred\Health\Check{
6 
7  public $interval = 1; //!< Measurement interval (minutes; 1, 5, or 15).
8  public $limit = null; //!< Maximum load (empty = no warning; just register).
9  public $message = 'High server load [load] ([load1]/[load5]/[load15])'; //!< Message when over limit.
10 
11  public function check(&$message = null){
12  $message = null;
13  $load = array_combine([1,5,15],sys_getloadavg());
14  $value = $load[$this->interval] ?? null;
15  if($this->limit && ($value > $this->limit))
16  $message = strtr($this->message,['[load]' => $value] + array_combine(['[load1]','[load5]','[load15]'],$load));
17  return $value;
18  }
19 
20 }
Rsi\Fred\Health\Check\Load\$interval
$interval
Measurement interval (minutes; 1, 5, or 15).
Definition: Load.php:7
Rsi\Fred\Health\Check\Load\$message
$message
Message when over limit.
Definition: Load.php:9
Rsi\Fred\Health\Check\Load\check
check(&$message=null)
Definition: Load.php:11
Rsi\Fred\Health\Check
Definition: Disk.php:3
Rsi\Fred\Health\Check\Load\$limit
$limit
Maximum load (empty = no warning; just register).
Definition: Load.php:8
Rsi\Fred\Health\Check\Load
Definition: Load.php:5