Location: PHPKode > projects > Monyet > scripts/randomdata.php
<?php

$sitepath = system('pwd');
require $sitepath.'/../includes/startup.php';

$msg = '';
$ping = new Ping();
$servmondef = new ServiceMon();

$arraymondef = $ping->select();

//refine the 5minutes
$minutes = date('i');
$minutes-=$minutes%5;

//calculate how much we will be iterate. 300 = 5 minutes

for($i=0;$i<sizeof($arraymondef);$i++){
	$tbl = 'p_'.$arraymondef[$i]->agent_id;
	
	$starttime = mktime(date('G'),$minutes,rand(1,9),date('m'),date('d'),date('y')-1);
	$finishtime = mktime(date('G'),$minutes,rand(1,9),date('m'),date('d'),date('y'));
	
	$mon = HolderFactory::create($tbl);
	echo 'populationg table '.$tbl."\n";
	$mon->truncate();
	$date = '';
	for($j=$starttime;$j<$finishtime;$j+=300){
		$date = date('Y-m-d G:i:',$starttime).'0'.rand(1,9);
		$mon->add(array($date,rand(0,300).'.'.rand(0,99)));
		$starttime+=300;
	}	
}
$arraymondef = $servmondef->select();
for($i=0;$i<sizeof($arraymondef);$i++){
	$tbl = 's_'.$arraymondef[$i]->service_id.'_'.$arraymondef[$i]->agent_id;
	
	$starttime = mktime(date('G'),$minutes,rand(1,9),date('m'),date('d'),date('y')-1);
	$finishtime = mktime(date('G'),$minutes,rand(1,9),date('m'),date('d'),date('y'));
	
	$mon = HolderFactory::create($tbl);
	echo 'populationg table '.$tbl."\n";
	$mon->truncate();
	$date = '';
	for($j=$starttime;$j<$finishtime;$j+=300){
		$date = date('Y-m-d G:i:',$starttime).'0'.rand(1,9);
		$mon->add(array($date,rand(0,300).'.'.rand(0,99)));
		$starttime+=300;
	}	
}
?>
Return current item: Monyet