/** * Wait for your number to come up so you could send a request * * @return bool OK to send request, otherwise wait */ public function okToSendRequest(Position $pos) { if (MemoryData::getNumRequestsThisSecond() <= 9 && MemoryData::getNumRequestsToday() < 100000 && ($pos->getPrevPositionId() == MemoryData::getCurrentPosition() || MemoryData::getSecondsSinceLastRequest() > 30)) { MemoryData::registerSendingRequest($pos); return true; } else { return false; } }
<?php namespace CurrantPi; include 'content/memory/MemoryData.php'; $memory = new MemoryData(); $memory_data = $memory->getData(); ?> <h4><i class="demo-icon icon-sliders"></i> Memory</h4> <table class="table table-striped table-hover"> <tbody> <tr> <td colspan="4"> <div class="row row-memory"> <div class="col-xs-9"> <div class="progress"> <div class="progress-bar progress-bar-used" role="progressbar" aria-valuenow="<?php echo $memory_data->used->actual; ?> " aria-valuemin="0" aria-valuemax="<?php echo $memory_data->total->actual; ?> " style="width: <?php echo $memory_data->used->percentage;
<?php /** * READ THIS * to use this file for reporting, due to the fact APC is shared amongst apache processes and is not shared with CLI php * code, we need to ping this page via apache. * The cron job should do this * wget http://192.168.240.70/crawlerstrunk/cronjobs/googleproxyreporter.php * for every once in a while you want the data to be collected * */ $_home = '/home/eyezeek/crawlers/www/crawlerstrunk'; include_once "{$_home}/crawler/engine/classes/Config.php"; include_once "{$_home}/crawler/engine/classes/DBAdapter2.class.php"; include_once "{$_home}/googleproxy/MemoryData.php"; $conf = new Config("/home/eyezeek/db.conf", "ini"); $o_db = new DBAdapter2(array('host' => $conf->crawler->host, 'username' => 'proxyuser', 'password' => 'E.Z.2011', 'schema' => 'proxy_reports')); $_numRequests = MemoryData::getNumRequestsResetCounter(true); $_sql = "INSERT INTO reports (`hourofreport`, `requests`) VALUES (now(), {$_numRequests}) "; try { $tmpArr = array(); $o_db->executeSQL($_sql, $tmpresult, $tmpArr); // if successully updated the DB, reset the counter $_numRequests = MemoryData::getNumRequestsResetCounter(); } catch (DBAdapter2Exception $e) { echo $e->getMessage(); }
<?php include_once 'Position.php'; include_once 'RequestManager.php'; include_once 'MemoryData.php'; date_default_timezone_set('Asia/Jerusalem'); $pid = getmypid(); echo 'start :' . date('YmdHis') . 'pid: ' . $pid . " "; include_once 'Position.php'; include_once 'RequestManager.php'; //$_req = new ReqestsManager(); //$_pos = new Position(); //$_req->getPositionInLine($_pos); //zzzWhileObjectFunctionFalse($_req, "okToSendRequest", $_pos); //apc_store('test123', 'testing1234'); echo '########### ' . MemoryData::getNumRequestsToday() . ' ############'; echo 'end :' . date('YmdHis') . 'pid: ' . $pid . "\n";