$config = parse_ini_file('../config/indexer-xml-config.ini', TRUE); $process_limit = 1000; // records to process in each batch $process_maximum = 1; // number of processes to spawn $queue = 'queue:couch-sphinx-xml'; $script_name = $_SERVER['SCRIPT_NAME']; $log_file = 'sphinx-xml.log'; $pids = array(); $l = new locum(); $couch = new couchClient($l->couchserver, $l->couchdatabase, array('curl' => array(CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4))); // Remove current log file and xml docs unlink($log_file); exec('rm ../sphinx/xml/*'); // Count records to process $all_bibs = $couch->limit(0)->getAllDocs(); $record_total = $all_bibs->total_rows; echo "Processing {$record_total} records in groups of {$process_limit}\n"; // Build the processing queue offsets $l->redis->del($queue); $offsets = array(); for ($process_offset = 0; $process_offset < $record_total; $process_offset += $process_limit) { $offsets[] = $process_offset; } shuffle($offsets); // randomize order in which offsets are processed foreach ($offsets as $offset) { $l->redis->rpush($queue, $offset); } $process_count = 0; while ($process_count < $process_maximum) {
# If there are any overrides include them now if (!is_readable('./config.php')) { echo "<H2>WARNING: Configuration file config.php does not exist. Please\n notify your system administrator.</H2>"; } else { include_once './config.php'; } require_once 'lib/couch.php'; require_once 'lib/couchClient.php'; require_once 'lib/couchDocument.php'; // set a new connector to the CouchDB server $client = new couchClient('http://' . $couchdb_server . ':' . $couchdb_port, $couchdb_database); // view fetching, using the view option limit try { # $view = $client->limit(100)->asArray()->getView('cronview','by_host'); $client->key(-1); $view = $client->limit(100)->asArray()->getView('cronview', 'by_job_duration'); } catch (Exception $e) { echo "ERROR while getting view contents: " . $e->getMessage() . "<BR>\n"; } ############################################################## # Did we get any response for the key we were looking for ############################################################## if (sizeof($view["rows"]) > 0) { print "<h2>Currently Running Jobs</h2><p>\n <table cellspacing=1 class=tablesorter border=1>\n <thead>\n <tr><th>Start time</th><th>Has been running so far (secs)</th><th>Username</th><th>Hostname</th><th>Command</th></tr>\n </thead>\n <tbody>"; foreach ($view["rows"] as $key => $row) { $job_time = time() - strtotime($row["value"]["time"]); print "<tr><td>" . $row["value"]["time"] . "</td>" . "<td align=center>" . $job_time . "</td>" . "<td>" . $row["value"]["username"] . "</td>" . "<td>" . $row["value"]["hostname"] . "</td>" . "<td>" . $row["value"]["command_line"] . "</td>" . "</tr>\n"; } print "</tbody></table>"; } else { print "No jobs running";
/** * Rebuild the availcache:timestamps queue for processing. * Make sure every bib record has an entry in the queue. */ public function rebuild_status_timestamps($skip = 0) { $couch = new couchClient($this->couchserver, $this->couchdatabase); try { $batch_limit = 1000; $total_rows = 9999999; // first batch will give us the total rows $default_timestamp = time() - 60 * 60 * 24; // default time is 24 hours ago, should move to top of queue $batch_count = 0; $added_count = 0; while ($skip < $total_rows) { $bibs = $couch->limit($batch_limit)->skip($skip)->getView('bib', 'lastupdate'); // Check for total_rows if ($bibs->total_rows != $total_rows) { $total_rows = $bibs->total_rows; } // Update timestamps foreach ($bibs->rows as $bib) { $current = $this->redis->zscore('availcache:timestamps', $bib->id); if (empty($current)) { $this->redis->zadd('availcache:timestamps', $default_timestamp, $bib->id); $added_count++; } } // Check next batch $batch_count++; $skip = $batch_count * $batch_limit; } return $added_count; } catch (Exception $e) { return FALSE; } }
$langs->load("companies"); $langs->load("customers"); $langs->load("suppliers"); $langs->load("commercial"); /* Array of database columns which should be read and sent back to DataTables. Use a space where * you want to insert a non-database field (for example a counter or static image) */ $couchdb = new couchClient("http://"."Administrator:admin@".substr($conf->couchdb->host, 7).':'.$conf->couchdb->port.'/',$conf->couchdb->name); $flush=0; if($flush) { // reset old value $result = $couchdb->limit(50000)->getView('MenuTop','target_id'); $i=0; if(count($result->rows)==0) { print "Effacement terminé"; exit; } foreach ($result->rows AS $aRow) { $obj[$i]->_id=$aRow->value->_id; $obj[$i]->_rev=$aRow->value->_rev; $i++; }
function ajaxtopicsAction() { $this->_helper->layout->disableLayout(); define("PAGESIZE", 50); $config = Zend_Registry::get('config'); $topicsClient = new couchClient($config->couchdb->uri . ":" . $config->couchdb->port, $config->couchdb->topics); try { $key = $this->_request->getParam('key'); $page = $this->_request->getParam('page') | 0; $totalCount = $this->_request->getParam('totalCount') | 0; $this->view->page = $page; if ($key) { $endKey = array($key, array(0, 0, 0, 0, 0, 0)); $startKey = $this->_request->getParam('start_key'); if (empty($startKey)) { $startKey = array($key, array('{}', '{}', '{}', '{}', '{}', '{}')); } else { $startKey = array($key, array((int) $startKey[1][0], (int) $startKey[1][1], (int) $startKey[1][2], (int) $startKey[1][3], (int) $startKey[1][4], (int) $startKey[1][5])); } $startkey_docid = $this->_request->getParam('startkey_docid'); $view = $topicsClient->limit(PAGESIZE)->startkey_docid($startkey_docid)->reduce(FALSE)->startkey($startKey)->endkey($endKey)->stale("ok")->asArray()->descending(TRUE)->getView('bayers', 'topics-by-folder-and-postdate'); $this->view->key = $key; if ($totalCount > 0) { $this->view->totalPage = ceil($totalCount / PAGESIZE); } else { $this->view->totalPage = "-"; } $this->view->totalCount = $totalCount; $result = array(); $topics = array(); $topicIds = array(); foreach ($view['rows'] as $topic) { array_push($topicIds, $topic['id']); } $user = $this->_currentUser->id; $irrModel = new InboxReadRecord(); $readResult = $irrModel->findReadTopicByUserAndTopicIds($user, $topicIds); $irerModel = new InboxRepliedRecord(); $repliedResult = $irerModel->findRepliedTopicByUserAndTopicIds($user, $topicIds); foreach ($view['rows'] as $topic) { // if(!isset($topic['value']['title'])){ // $topic['value']['title'] = "-"; // } // if(isset($topic['value']['date_posted'])){ // list($pyear,$pmonth,$pday,$phour,$pminute,$psecond) = $topic['value']['date_posted']; // $pmonth+=1; // $pdate = date("Y-m-d H:i:s",mktime($phour,$pminute,$psecond,$pmonth,$pday,$pyear)); // $diff = time() - strtotime($pdate); // if($diff > 3600 * 24 *7){ // continue; // } // } if (isset($topic['key'][1])) { list($year, $month, $day, $hour, $minute, $second) = $topic['key'][1]; $month += 1; $date = date("Y-m-d H:i:s", mktime($hour, $minute, $second, $month, $day, $year)); } else { $date = "-"; } $topic['value']['date'] = $date; if (isset($topic['value']['body'])) { $body = $topic['value']['body']; } else { $body = "-"; } $topic['value']['body'] = $body; if (isset($topic['value']['tracker'])) { $lastestKey = false; foreach ($topic['value']['tracker'] as $k => $v) { if (!$lastestKey) { $lastestKey = $k; } else { if ($lastestKey < $k) { $lastestKey = $k; } } } $tracker = $topic['value']['tracker'][$lastestKey]; if (isset($tracker['views'])) { $views = $tracker['views']; } else { $views = "-"; } if (isset($tracker['comments'])) { $comments = $tracker['comments']; } else { $comments = "-"; } } else { $comments = "-"; $views = "-"; } $topic['value']['comments'] = $comments; $topic['value']['views'] = $views; if (in_array($topic['id'], $readResult)) { $topic['value']['read'] = true; } else { $topic['value']['read'] = false; } if (in_array($topic['id'], $repliedResult)) { $topic['value']['replied'] = true; } else { $topic['value']['replied'] = false; } $url = $topic['value']['site']; $site = getInfoBySiteUrl($url); $site['url'] = $url; $topic['value']['site'] = $site; array_push($topics, $topic); } $this->view->topics = $topics; $result['topics'] = $this->view->topics; $result['key'] = $this->view->key; $result['totalCount'] = $this->view->totalCount; $result['page'] = $this->view->page; $this->_helper->json($result); } } catch (Exception $e) { } }
* Paging */ //$sLimit = " LIMIT 3"; /* search basic */ $sWhere = ""; // If the user must only see his prospect, force searching by him if (!$user->rights->societe->client->voir && !$socid) { $search_sale = $user->id; } $flush=0; if($flush) { // reset old value $result = $couchdb->limit(50000)->getView('Societe','target_id'); $i=0; if(count($result->rows)==0) { print "Effacement terminé"; exit; } foreach ($result->rows AS $aRow) { $obj[$i]->_id=$aRow->value->_id; $obj[$i]->_rev=$aRow->value->_rev; $i++; }
require_once 'lib/couch.php'; require_once 'lib/couchClient.php'; require_once 'lib/couchDocument.php'; $couch_url = 'http://' . $couchdb_server . ':' . $couchdb_port; $couch_url_full = $couch_url . "/" . $couchdb_database; // set a new connector to the CouchDB server $client = new couchClient($couch_url, $couchdb_database); ?> <?php // view fetching, using the view option limit try { if (isset($_GET['command'])) { $client->key($_GET['command']); } $view = $client->limit(100)->asArray()->getView('cronview', 'by_commandline'); } catch (Exception $e) { echo "ERROR while getting view contents: " . $e->getMessage() . "<BR>\n"; } ############################################################## # Did we get any response for the key we were looking for ############################################################## if (sizeof($view["rows"]) > 0) { print "\n <table cellspacing=1 class=tablesorter border=1>\n <thead>\n <tr><th>Start time</th><th>Job duration</th><th>Return code</th>\n <th>Username</th><th>Hostname</th><th>Command</th>\n <th>StdOut (Bytes)</th><th>StdErr (Bytes)</th>\n </tr>\n </thead>\n <tbody>"; foreach ($view["rows"] as $key => $row) { if (!$row["value"]["_attachments"]["stderr"]["length"] > 0) { continue; } $docid = $row["value"]["_id"]; print "<tr><td>" . $row["value"]["time"] . "</td>" . "<td align=center>" . $row["value"]["job_duration"] . "</td>" . "<td align=center>" . $row["value"]["return_code"] . "</td>" . "<td class=centered>" . $row["value"]["username"] . "</td>" . "<td class=centered>" . $row["value"]["hostname"] . "</td>" . "<td> <a href='list_by_command.php?command=" . $row['value']['command_line'] . "'>" . $row["value"]["command_line"] . "</a></td>" . "<td class=centered><a href=get_attachment.php?docid=" . $docid . "&output=stdout>" . $row["value"]["_attachments"]["stdout"]["length"] . "</a></td>" . "<td class=centered><a href=get_attachment.php?docid=" . $docid . "&output=stderr>" . $row["value"]["_attachments"]["stderr"]["length"] . "</a></td>" . "</tr>\n"; }
----><a href="#" onclick='getJobsListing("<?php print $_GET['search_type'] . "\",\"" . $next_timeperiod; ?> "); return false;'><?php print $next_timeperiod; ?> </a> <?php // view fetching, using the view option limit try { $start_time = $unixtime; $end_time = $start_time + 86400; $client->startkey($start_time); $client->endkey($end_time); $view = $client->limit(100)->asArray()->getView('cronview', 'by_unixtime'); } catch (Exception $e) { echo "ERROR while getting view contents: " . $e->getMessage() . "<BR>\n"; } ############################################################## # Did we get any response for the key we were looking for ############################################################## if (sizeof($view["rows"]) > 0) { if (isset($_GET['search_type']) && $_GET['search_type'] == "errors") { print "<p><h2>Displaying jobs that ran on " . date("Y-m-d", $unixtime) . " and had errors</h2><p>"; } print "\n <table cellspacing=1 class=tablesorter border=1>\n <thead>\n <tr><th>Start time</th><th>Job duration</th><th>Return code</th>\n <th>Username</th><th>Hostname</th><th>Command</th>\n <th>StdOut (Bytes)</th><th>StdErr (Bytes)</th>\n </tr>\n </thead>\n <tbody>"; foreach ($view["rows"] as $key => $row) { if (isset($_GET['search_type']) && $_GET['search_type'] == "errors") { if (!$row["value"]["_attachments"]["stderr"]["length"] > 0) { continue;