/** * @brief Log the server load while crons are running * * @access public * * @return float the 1 min load average if found, -1 if not */ public function logServerLoad() { $load = serverLoad(false); if (!isset($this->memoryUsage['start']['load'])) { $this->memoryUsage['start']['load'] = $load[0]; } $this->_loadLog[] = $load[0]; return $load[0]; }
/** * @brief updates the cron row to show the process as complete * * When the cron run is done this method is called to mark the end of the * process, along with recording some stats on the system that can * later be used for analysys. * * @param int $tasksRan the number of events that did something * @param string $memAverage average memory usage for the run * @param string $loadAverage system load average for the run * @access public * * @return AppModel::save() */ public function end($tasksRan = 0, $memAverage = 0, $loadAverage = 0) { if (!$this->_currentProcess) { trigger_error(__('Cron not yet started'), E_USER_WARNING); return false; } $data = null; $memUsage = memoryUsage(false, false); $serverLoad = serverLoad(false); $serverLoad[0] = $serverLoad[0] >= 0 ? $serverLoad[0] : 0; $data['Cron'] = array('id' => $this->_currentProcess, 'end_time' => date('H:i:s'), 'end_mem' => $memUsage['current'], 'end_load' => $serverLoad[0], 'mem_ave' => $memAverage, 'load_ave' => $loadAverage, 'tasks_ran' => $tasksRan, 'done' => 1); unset($memUsage, $serverLoad); $this->_currentProcess = null; return $this->save($data); }
public function __construct($request = null, $response = null) { $this->serverLoad = serverLoad(false); $this->memoryUsage = memoryUsage(false, false); parent::__construct($request, $response); }