<?php
/*
* throttle_heavy_program.php
*
* @(#) $Id: throttle_heavy_program.php,v 1.1 2010/10/25 06:04:01 mlemos Exp $
*
*/
require('system_monitor.php');
function stopped($arguments)
{
echo 'Process stopped due to cause '.$arguments['Cause'],"\n";
return true;
}
function continued($arguments)
{
echo 'Process continued',"\n";
return true;
}
$monitor = new system_monitor_class;
$monitor->cpu_load_limit = 2;
$monitor->temporary_directory = '/tmp/';
$command = 'php -q heavy_program.php';
$parameters = array(
'Command' => $command,
'PollInterval'=>5,
'OnStop' => 'stopped',
'OnContinue' => 'continued',
'CaptureOutput'=>'array',
);
if(!$monitor->ThrottleExecute($parameters))
{
echo 'Could not execute the heavy process: '.$monitor->error."\n";
exit;
}
var_dump($parameters['Status'], $parameters['Output']);
?>
|