Commit 7b824728a14d832f15f6a56d19f92c3545a3e5dc
1 parent
7e938a2d
KTS-3434
"Background task can test Document Indexer diagnostics and cache results" Fixed Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8669 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
10 changed files
with
404 additions
and
223 deletions
plugins/search2/ExternalDashlet.php
| ... | ... | @@ -7,31 +7,31 @@ |
| 7 | 7 | * Document Management Made Simple |
| 8 | 8 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 9 | 9 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 10 | - * | |
| 10 | + * | |
| 11 | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | 13 | * Free Software Foundation. |
| 14 | - * | |
| 14 | + * | |
| 15 | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | 18 | * details. |
| 19 | - * | |
| 19 | + * | |
| 20 | 20 | * You should have received a copy of the GNU General Public License |
| 21 | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | |
| 23 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | 24 | * California 94120-7775, or email info@knowledgetree.com. |
| 25 | - * | |
| 25 | + * | |
| 26 | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | 35 | * copyright notice. |
| 36 | 36 | * Contributor( s): ______________________________________ |
| 37 | 37 | * |
| ... | ... | @@ -47,74 +47,6 @@ class ExternalResourceStatusDashlet extends KTBaseDashlet |
| 47 | 47 | $this->sClass = 'ktError'; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - function addIssue($resource, $status) | |
| 51 | - { | |
| 52 | - $this->resources[] = array( | |
| 53 | - 'name'=>$resource, | |
| 54 | - 'status'=>str_replace( | |
| 55 | - | |
| 56 | - array("\n",_kt('Administrator Guide')), | |
| 57 | - array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $status)); | |
| 58 | - } | |
| 59 | - | |
| 60 | - function checkResources() | |
| 61 | - { | |
| 62 | - $check = true; | |
| 63 | - // check if we have a cached result | |
| 64 | - if (isset($_SESSION['ExternalResourceStatus'])) | |
| 65 | - { | |
| 66 | - // we will only do the check every 5 minutes | |
| 67 | - if (time() - $_SESSION['ExternalResourceStatus']['time'] < 5 * 60) | |
| 68 | - { | |
| 69 | - $check = false; | |
| 70 | - $this->resources = $_SESSION['ExternalResourceStatus']['resources']; | |
| 71 | - } | |
| 72 | - } | |
| 73 | - | |
| 74 | - // we will only check if the result is not cached, or after 5 minutes | |
| 75 | - if ($check) | |
| 76 | - { | |
| 77 | - $this->checkOpenOffice(); | |
| 78 | - $this->checkLucene(); | |
| 79 | - $this->checkDF(); | |
| 80 | - $_SESSION['ExternalResourceStatus']['time'] = time(); | |
| 81 | - $_SESSION['ExternalResourceStatus']['resources'] = $this->resources; | |
| 82 | - } | |
| 83 | - | |
| 84 | - return (count($this->resources) > 0); | |
| 85 | - } | |
| 86 | - | |
| 87 | - function checkOpenOffice() | |
| 88 | - { | |
| 89 | - $diagnose = SearchHelper::checkOpenOfficeAvailablity(); | |
| 90 | - if (!is_null($diagnose)) | |
| 91 | - { | |
| 92 | - $this->addIssue(_kt('Open Office Server'), $diagnose); | |
| 93 | - } | |
| 94 | - } | |
| 95 | - | |
| 96 | - function checkLucene() | |
| 97 | - { | |
| 98 | - $indexer = Indexer::get(); | |
| 99 | - $diagnose = $indexer->diagnose(); | |
| 100 | - if (!is_null($diagnose)) | |
| 101 | - { | |
| 102 | - $this->addIssue(_kt('Document Indexer'), $diagnose); | |
| 103 | - } | |
| 104 | - } | |
| 105 | - | |
| 106 | - function checkDF() | |
| 107 | - { | |
| 108 | - $df = KTUtil::findCommand('externalBinary/df','df'); | |
| 109 | - | |
| 110 | - if (false === $df) | |
| 111 | - { | |
| 112 | - $this->addIssue(_kt('Storage Utilization'), _kt('Could not locate the <i>df</i> binary.')); | |
| 113 | - } | |
| 114 | - } | |
| 115 | - | |
| 116 | - | |
| 117 | - | |
| 118 | 50 | function is_active($oUser) |
| 119 | 51 | { |
| 120 | 52 | if (!Permission::userIsSystemAdministrator()) |
| ... | ... | @@ -122,7 +54,14 @@ class ExternalResourceStatusDashlet extends KTBaseDashlet |
| 122 | 54 | return false; |
| 123 | 55 | } |
| 124 | 56 | |
| 125 | - return $this->checkResources() > 0; | |
| 57 | + $this->resources = KTUtil::getSystemSetting('externalResourceIssues'); | |
| 58 | + if (empty($this->resources)) | |
| 59 | + { | |
| 60 | + return false; | |
| 61 | + } | |
| 62 | + $this->resources = unserialize($this->resources); | |
| 63 | + | |
| 64 | + return count($this->resources) > 0; | |
| 126 | 65 | } |
| 127 | 66 | |
| 128 | 67 | function render() |
| ... | ... | @@ -131,6 +70,12 @@ class ExternalResourceStatusDashlet extends KTBaseDashlet |
| 131 | 70 | $oTemplate = $oTemplating->loadTemplate('ktcore/search2/external_resources'); |
| 132 | 71 | |
| 133 | 72 | $sUrl = KTUtil::kt_url(); |
| 73 | + foreach($this->resources as $k=>$v) | |
| 74 | + { | |
| 75 | + $this->resources[$k]['status'] = str_replace( | |
| 76 | + array("\n",_kt('Administrator Guide')), | |
| 77 | + array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $v['status']); | |
| 78 | + } | |
| 134 | 79 | |
| 135 | 80 | $aTemplateData = array( |
| 136 | 81 | 'context' => $this, |
| ... | ... | @@ -142,4 +87,4 @@ class ExternalResourceStatusDashlet extends KTBaseDashlet |
| 142 | 87 | } |
| 143 | 88 | } |
| 144 | 89 | |
| 145 | 90 | -?> |
| 91 | +?> | |
| 146 | 92 | \ No newline at end of file | ... | ... |
plugins/search2/IndexingStatusDashlet.php
| ... | ... | @@ -7,31 +7,31 @@ |
| 7 | 7 | * Document Management Made Simple |
| 8 | 8 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 9 | 9 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 10 | - * | |
| 10 | + * | |
| 11 | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | 13 | * Free Software Foundation. |
| 14 | - * | |
| 14 | + * | |
| 15 | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | 18 | * details. |
| 19 | - * | |
| 19 | + * | |
| 20 | 20 | * You should have received a copy of the GNU General Public License |
| 21 | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | |
| 23 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | 24 | * California 94120-7775, or email info@knowledgetree.com. |
| 25 | - * | |
| 25 | + * | |
| 26 | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | 35 | * copyright notice. |
| 36 | 36 | * Contributor( s): ______________________________________ |
| 37 | 37 | * |
| ... | ... | @@ -54,20 +54,17 @@ class IndexingStatusDashlet extends KTBaseDashlet |
| 54 | 54 | return false; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (isset($_SESSION['IndexingStatus'])) | |
| 57 | + $indexerDiagnosis = KTUtil::getSystemSetting('indexerDiagnostics'); | |
| 58 | + $extractorDiagnosis = KTUtil::getSystemSetting('extractorDiagnostics'); | |
| 59 | + if (!empty($indexerDiagnosis)) $indexerDiagnosis = unserialize($indexerDiagnosis); | |
| 60 | + if (!empty($extractorDiagnosis)) $extractorDiagnosis = unserialize($extractorDiagnosis); | |
| 61 | + | |
| 62 | + if (empty($indexerDiagnosis) && empty($extractorDiagnosis)) | |
| 58 | 63 | { |
| 59 | - $this->indexerName = $_SESSION['IndexingStatus']['indexerName']; | |
| 60 | - $this->indexerDiagnosis = $_SESSION['IndexingStatus']['indexerDiagnosis']; | |
| 61 | - $this->extractorDiagnosis = $_SESSION['IndexingStatus']['extractorDiagnosis']; | |
| 64 | + return false; | |
| 62 | 65 | } |
| 63 | - else | |
| 64 | - { | |
| 65 | - $indexer = Indexer::get(); | |
| 66 | - $this->indexerName = $indexer->getDisplayName(); | |
| 67 | - $this->indexerDiagnosis = $indexer->diagnose(); | |
| 66 | + $this->indexerDiagnosis = $indexerDiagnosis; | |
| 68 | 67 | $this->extractorDiagnosis = array(); |
| 69 | - $extractorDiagnosis = $indexer->diagnoseExtractors(); | |
| 70 | - | |
| 71 | 68 | |
| 72 | 69 | $result = array(); |
| 73 | 70 | foreach($extractorDiagnosis as $class=>$diagnosis) |
| ... | ... | @@ -85,19 +82,9 @@ class IndexingStatusDashlet extends KTBaseDashlet |
| 85 | 82 | |
| 86 | 83 | $this->indexerDiagnosis = str_replace( |
| 87 | 84 | |
| 88 | - array("\n",_kt('Administrator Guide')), | |
| 85 | + array("\n",'Administrator Guide'), | |
| 89 | 86 | array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $this->indexerDiagnosis); |
| 90 | 87 | |
| 91 | - $_SESSION['IndexingStatus']['indexerName'] = $this->indexerName; | |
| 92 | - $_SESSION['IndexingStatus']['indexerDiagnosis'] = $this->indexerDiagnosis; | |
| 93 | - $_SESSION['IndexingStatus']['extractorDiagnosis'] = $this->extractorDiagnosis; | |
| 94 | - } | |
| 95 | - | |
| 96 | - if (empty($this->indexerDiagnosis) && empty($this->extractorDiagnosis)) | |
| 97 | - { | |
| 98 | - return false; | |
| 99 | - } | |
| 100 | - | |
| 101 | 88 | return true; |
| 102 | 89 | } |
| 103 | 90 | |
| ... | ... | @@ -107,7 +94,7 @@ class IndexingStatusDashlet extends KTBaseDashlet |
| 107 | 94 | $oTemplate = $oTemplating->loadTemplate('ktcore/search2/indexing_status'); |
| 108 | 95 | |
| 109 | 96 | $url = KTUtil::kt_url(); |
| 110 | - | |
| 97 | + | |
| 111 | 98 | $aTemplateData = array( |
| 112 | 99 | 'context' => $this, |
| 113 | 100 | 'indexerName' => $this->indexerName, | ... | ... |
plugins/search2/LuceneStatisticsDashlet.php
| ... | ... | @@ -7,31 +7,31 @@ |
| 7 | 7 | * Document Management Made Simple |
| 8 | 8 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 9 | 9 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 10 | - * | |
| 10 | + * | |
| 11 | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | 13 | * Free Software Foundation. |
| 14 | - * | |
| 14 | + * | |
| 15 | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | 18 | * details. |
| 19 | - * | |
| 19 | + * | |
| 20 | 20 | * You should have received a copy of the GNU General Public License |
| 21 | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | |
| 23 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | 24 | * California 94120-7775, or email info@knowledgetree.com. |
| 25 | - * | |
| 25 | + * | |
| 26 | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | 35 | * copyright notice. |
| 36 | 36 | * Contributor( s): ______________________________________ |
| 37 | 37 | * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | |
| 40 | 40 | class LuceneStatisticsDashlet extends KTBaseDashlet |
| 41 | 41 | { |
| 42 | + private $stats; | |
| 43 | + | |
| 44 | + | |
| 42 | 45 | function LuceneStatisticsDashlet() |
| 43 | 46 | { |
| 44 | 47 | $this->sTitle = _kt('Document Indexer Statistics'); |
| ... | ... | @@ -46,6 +49,12 @@ class LuceneStatisticsDashlet extends KTBaseDashlet |
| 46 | 49 | |
| 47 | 50 | function is_active($oUser) |
| 48 | 51 | { |
| 52 | + $stats = KTUtil::getSystemSetting('indexerStats'); | |
| 53 | + if (empty($stats)) | |
| 54 | + { | |
| 55 | + return false; | |
| 56 | + } | |
| 57 | + $this->stats = unserialize($stats); | |
| 49 | 58 | return Permission::userIsSystemAdministrator(); |
| 50 | 59 | } |
| 51 | 60 | |
| ... | ... | @@ -54,108 +63,9 @@ class LuceneStatisticsDashlet extends KTBaseDashlet |
| 54 | 63 | $oTemplating =& KTTemplating::getSingleton(); |
| 55 | 64 | $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_statistics'); |
| 56 | 65 | |
| 57 | - | |
| 58 | - $check = true; | |
| 59 | - // check if we have a cached result | |
| 60 | - if (isset($_SESSION['LuceneStats'])) | |
| 61 | - { | |
| 62 | - // we will only do the check every 5 minutes | |
| 63 | - if (time() - $_SESSION['LuceneStats']['time'] < 5 * 60) | |
| 64 | - { | |
| 65 | - $check = false; | |
| 66 | - $stats = $_SESSION['LuceneStats']['stats']; | |
| 67 | - } | |
| 68 | - } | |
| 69 | - | |
| 70 | - // we will only check if the result is not cached, or after 5 minutes | |
| 71 | - if ($check) | |
| 72 | - { | |
| 73 | - $optimisationDate = KTUtil::getSystemSetting('luceneOptimisationDate', ''); | |
| 74 | - | |
| 75 | - $noOptimisation = false; | |
| 76 | - if ($optimisationDate == '') | |
| 77 | - { | |
| 78 | - $optimisationDate = _kt('N/A'); | |
| 79 | - $optimisationPeriod = $optimisationDate; | |
| 80 | - } | |
| 81 | - else | |
| 82 | - { | |
| 83 | - $optimisationPeriod = KTUtil::computePeriodToDate($optimisationDate, null, true); | |
| 84 | - $noOptimisation = $optimisationPeriod['days'] > 2; | |
| 85 | - $optimisationPeriod = $optimisationPeriod['str']; | |
| 86 | - $optimisationDate = date('Y-m-d H:i:s', $optimisationDate); | |
| 87 | - } | |
| 88 | - | |
| 89 | - $indexingDate = KTUtil::getSystemSetting('luceneIndexingDate', ''); | |
| 90 | - if ($indexingDate == '') | |
| 91 | - { | |
| 92 | - $indexingDate = _kt('N/A'); | |
| 93 | - $indexingPeriod = $indexingDate; | |
| 94 | - } | |
| 95 | - else | |
| 96 | - { | |
| 97 | - $indexingPeriod = KTUtil::computePeriodToDate($indexingDate); | |
| 98 | - $indexingDate = date('Y-m-d H:i:s', $indexingDate); | |
| 99 | - } | |
| 100 | - | |
| 101 | - $index = Indexer::get(); | |
| 102 | - $docsInIndex = $index->getDocumentsInIndex(); | |
| 103 | - | |
| 104 | - // we are only interested in documents that are active | |
| 105 | - $docsInQueue = $index->getIndexingQueue(false); | |
| 106 | - $docsInQueue = count($docsInQueue); | |
| 107 | - | |
| 108 | - $errorsInQueue = $index->getIndexingQueue(true); | |
| 109 | - $errorsInQueue = count($errorsInQueue); | |
| 110 | - | |
| 111 | - $sql = "SELECT count(*) as docsInRepository FROM documents"; | |
| 112 | - $docsInRepository = DBUtil::getOneResultKey($sql, 'docsInRepository'); | |
| 113 | - | |
| 114 | - if ($docsInRepository == 0) | |
| 115 | - { | |
| 116 | - $indexingCoverage = '0.00%'; | |
| 117 | - $queueCoverage = $indexingCoverage; | |
| 118 | - } | |
| 119 | - else | |
| 120 | - { | |
| 121 | - // compute indexing coverage | |
| 122 | - $indexingCoverage = _kt('Not Available'); | |
| 123 | - if (is_numeric($docsInIndex)) | |
| 124 | - { | |
| 125 | - $indexingCoverage = ($docsInIndex * 100) / $docsInRepository; | |
| 126 | - $indexingCoverage = number_format($indexingCoverage, 2, '.',',') . '%'; | |
| 127 | - } | |
| 128 | - | |
| 129 | - // compute queue coverage | |
| 130 | - $queueCoverage = _kt('Not Available'); | |
| 131 | - if (is_numeric($docsInQueue)) | |
| 132 | - { | |
| 133 | - $queueCoverage = ($docsInQueue * 100) / $docsInRepository; | |
| 134 | - $queueCoverage = number_format($queueCoverage, 2, '.',',') . '%'; | |
| 135 | - } | |
| 136 | - } | |
| 137 | - | |
| 138 | - $stats = array( | |
| 139 | - 'optimisationDate'=>$optimisationDate, | |
| 140 | - 'optimisationPeriod'=>$optimisationPeriod, | |
| 141 | - 'indexingDate'=>$indexingDate, | |
| 142 | - 'indexingPeriod'=>$indexingPeriod, | |
| 143 | - 'docsInIndex'=>$docsInIndex, | |
| 144 | - 'docsInQueue'=>$docsInQueue, | |
| 145 | - 'errorsInQueue'=>$errorsInQueue, | |
| 146 | - 'docsInRepository'=>$docsInRepository, | |
| 147 | - 'indexingCoverage'=>$indexingCoverage, | |
| 148 | - 'queueCoverage'=>$queueCoverage, | |
| 149 | - 'noOptimisation'=>$noOptimisation | |
| 150 | - ); | |
| 151 | - | |
| 152 | - $_SESSION['LuceneStats']['time'] = time(); | |
| 153 | - $_SESSION['LuceneStats']['stats'] = $stats; | |
| 154 | - } | |
| 155 | - | |
| 156 | 66 | $aTemplateData = array( |
| 157 | 67 | 'context' => $this, |
| 158 | - 'stats'=>$stats | |
| 68 | + 'stats'=>$this->stats | |
| 159 | 69 | |
| 160 | 70 | ); |
| 161 | 71 | ... | ... |
search2/bin/cronIndexStats.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id:$ | |
| 5 | + * | |
| 6 | + * KnowledgeTree Community Edition | |
| 7 | + * Document Management Made Simple | |
| 8 | + * Copyright (C) 2008 KnowledgeTree Inc. | |
| 9 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 10 | + * | |
| 11 | + * This program is free software; you can redistribute it and/or modify it under | |
| 12 | + * the terms of the GNU General Public License version 3 as published by the | |
| 13 | + * Free Software Foundation. | |
| 14 | + * | |
| 15 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 16 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 17 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 18 | + * details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU General Public License | |
| 21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 25 | + * | |
| 26 | + * The interactive user interfaces in modified source and object code versions | |
| 27 | + * of this program must display Appropriate Legal Notices, as required under | |
| 28 | + * Section 5 of the GNU General Public License version 3. | |
| 29 | + * | |
| 30 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 31 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | + * Contributor( s): ______________________________________ | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + | |
| 40 | +chdir(dirname(__FILE__)); | |
| 41 | +require_once(realpath('../../config/dmsDefaults.php')); | |
| 42 | +require_once('indexing/indexerCore.inc.php'); | |
| 43 | + | |
| 44 | +$verbose = false; | |
| 45 | + | |
| 46 | +if (is_array($argv) && in_array('verbose', $argv)) $verbose = true; | |
| 47 | + | |
| 48 | +if ($verbose) print _kt("Cache index stats and diagnostics") . "...\n"; | |
| 49 | + | |
| 50 | +$indexer = Indexer::get(); | |
| 51 | +$indexer->updateIndexStats(); | |
| 0 | 52 | \ No newline at end of file | ... | ... |
search2/bin/cronOptimize.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id:$ | |
| 5 | + * | |
| 6 | + * KnowledgeTree Community Edition | |
| 7 | + * Document Management Made Simple | |
| 8 | + * Copyright (C) 2008 KnowledgeTree Inc. | |
| 9 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 10 | + * | |
| 11 | + * This program is free software; you can redistribute it and/or modify it under | |
| 12 | + * the terms of the GNU General Public License version 3 as published by the | |
| 13 | + * Free Software Foundation. | |
| 14 | + * | |
| 15 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 16 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 17 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 18 | + * details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU General Public License | |
| 21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 25 | + * | |
| 26 | + * The interactive user interfaces in modified source and object code versions | |
| 27 | + * of this program must display Appropriate Legal Notices, as required under | |
| 28 | + * Section 5 of the GNU General Public License version 3. | |
| 29 | + * | |
| 30 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 31 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | + * Contributor( s): ______________________________________ | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + | |
| 40 | +require_once('optimise.php'); | |
| 41 | + | |
| 42 | + | |
| 43 | +?> | |
| 0 | 44 | \ No newline at end of file | ... | ... |
search2/bin/cronResources.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id:$ | |
| 5 | + * | |
| 6 | + * KnowledgeTree Community Edition | |
| 7 | + * Document Management Made Simple | |
| 8 | + * Copyright (C) 2008 KnowledgeTree Inc. | |
| 9 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 10 | + * | |
| 11 | + * This program is free software; you can redistribute it and/or modify it under | |
| 12 | + * the terms of the GNU General Public License version 3 as published by the | |
| 13 | + * Free Software Foundation. | |
| 14 | + * | |
| 15 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 16 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 17 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 18 | + * details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU General Public License | |
| 21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 25 | + * | |
| 26 | + * The interactive user interfaces in modified source and object code versions | |
| 27 | + * of this program must display Appropriate Legal Notices, as required under | |
| 28 | + * Section 5 of the GNU General Public License version 3. | |
| 29 | + * | |
| 30 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 31 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | + * Contributor( s): ______________________________________ | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + | |
| 40 | +chdir(dirname(__FILE__)); | |
| 41 | +require_once(realpath('../../config/dmsDefaults.php')); | |
| 42 | + | |
| 43 | +class ResourceChecker | |
| 44 | +{ | |
| 45 | + var $resources; | |
| 46 | + | |
| 47 | + function addIssue($resource, $status) | |
| 48 | + { | |
| 49 | + $this->resources[] = array( | |
| 50 | + 'name'=>$resource, | |
| 51 | + 'status'=>$status); | |
| 52 | + } | |
| 53 | + | |
| 54 | + | |
| 55 | + function checkOpenOffice() | |
| 56 | + { | |
| 57 | + $diagnose = SearchHelper::checkOpenOfficeAvailablity(); | |
| 58 | + if (!is_null($diagnose)) | |
| 59 | + { | |
| 60 | + $this->addIssue('Open Office Server', $diagnose); | |
| 61 | + } | |
| 62 | + } | |
| 63 | + | |
| 64 | + function checkLucene() | |
| 65 | + { | |
| 66 | + $indexer = Indexer::get(); | |
| 67 | + $diagnose = $indexer->diagnose(); | |
| 68 | + if (!is_null($diagnose)) | |
| 69 | + { | |
| 70 | + $this->addIssue('Document Indexer', $diagnose); | |
| 71 | + } | |
| 72 | + } | |
| 73 | + | |
| 74 | + function checkDF() | |
| 75 | + { | |
| 76 | + $df = KTUtil::findCommand('externalBinary/df','df'); | |
| 77 | + | |
| 78 | + if (false === $df) | |
| 79 | + { | |
| 80 | + $this->addIssue('Storage Utilization', 'Could not locate the <i>df</i> binary.'); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + | |
| 84 | + | |
| 85 | + function check() | |
| 86 | + { | |
| 87 | + $this->checkOpenOffice(); | |
| 88 | + $this->checkLucene(); | |
| 89 | + $this->checkDF(); | |
| 90 | + | |
| 91 | + KTUtil::setSystemSetting('externalResourceIssues', serialize($this->resources)); | |
| 92 | + } | |
| 93 | +} | |
| 94 | + | |
| 95 | +$checker = new ResourceChecker(); | |
| 96 | +$checker->check(); | |
| 97 | + | |
| 98 | +?> | |
| 0 | 99 | \ No newline at end of file | ... | ... |
search2/indexing/bin/cronOptimize.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id:$ | |
| 5 | + * | |
| 6 | + * KnowledgeTree Community Edition | |
| 7 | + * Document Management Made Simple | |
| 8 | + * Copyright (C) 2008 KnowledgeTree Inc. | |
| 9 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 10 | + * | |
| 11 | + * This program is free software; you can redistribute it and/or modify it under | |
| 12 | + * the terms of the GNU General Public License version 3 as published by the | |
| 13 | + * Free Software Foundation. | |
| 14 | + * | |
| 15 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 16 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 17 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 18 | + * details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU General Public License | |
| 21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 25 | + * | |
| 26 | + * The interactive user interfaces in modified source and object code versions | |
| 27 | + * of this program must display Appropriate Legal Notices, as required under | |
| 28 | + * Section 5 of the GNU General Public License version 3. | |
| 29 | + * | |
| 30 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 31 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | + * Contributor( s): ______________________________________ | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + | |
| 40 | +require_once('optimise.php'); | |
| 41 | + | |
| 42 | +?> | |
| 0 | 43 | \ No newline at end of file | ... | ... |
search2/indexing/indexerCore.inc.php
| ... | ... | @@ -899,6 +899,100 @@ abstract class Indexer |
| 899 | 899 | return Indexer::getIndexingQueue(false); |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | + public function updateIndexStats() | |
| 903 | + { | |
| 904 | + $optimisationDate = KTUtil::getSystemSetting('luceneOptimisationDate', ''); | |
| 905 | + | |
| 906 | + $noOptimisation = false; | |
| 907 | + if ($optimisationDate == '') | |
| 908 | + { | |
| 909 | + $optimisationDate = _kt('N/A'); | |
| 910 | + $optimisationPeriod = $optimisationDate; | |
| 911 | + } | |
| 912 | + else | |
| 913 | + { | |
| 914 | + $optimisationPeriod = KTUtil::computePeriodToDate($optimisationDate, null, true); | |
| 915 | + $noOptimisation = $optimisationPeriod['days'] > 2; | |
| 916 | + $optimisationPeriod = $optimisationPeriod['str']; | |
| 917 | + $optimisationDate = date('Y-m-d H:i:s', $optimisationDate); | |
| 918 | + } | |
| 919 | + | |
| 920 | + $indexingDate = KTUtil::getSystemSetting('luceneIndexingDate', ''); | |
| 921 | + if ($indexingDate == '') | |
| 922 | + { | |
| 923 | + $indexingDate = _kt('N/A'); | |
| 924 | + $indexingPeriod = $indexingDate; | |
| 925 | + } | |
| 926 | + else | |
| 927 | + { | |
| 928 | + $indexingPeriod = KTUtil::computePeriodToDate($indexingDate); | |
| 929 | + $indexingDate = date('Y-m-d H:i:s', $indexingDate); | |
| 930 | + } | |
| 931 | + | |
| 932 | + $index = Indexer::get(); | |
| 933 | + $docsInIndex = $index->getDocumentsInIndex(); | |
| 934 | + | |
| 935 | + // we are only interested in documents that are active | |
| 936 | + $docsInQueue = $index->getIndexingQueue(false); | |
| 937 | + $docsInQueue = count($docsInQueue); | |
| 938 | + | |
| 939 | + $errorsInQueue = $index->getIndexingQueue(true); | |
| 940 | + $errorsInQueue = count($errorsInQueue); | |
| 941 | + | |
| 942 | + $sql = "SELECT count(*) as docsInRepository FROM documents"; | |
| 943 | + $docsInRepository = DBUtil::getOneResultKey($sql, 'docsInRepository'); | |
| 944 | + | |
| 945 | + if ($docsInRepository == 0) | |
| 946 | + { | |
| 947 | + $indexingCoverage = '0.00%'; | |
| 948 | + $queueCoverage = $indexingCoverage; | |
| 949 | + } | |
| 950 | + else | |
| 951 | + { | |
| 952 | + // compute indexing coverage | |
| 953 | + $indexingCoverage = _kt('Not Available'); | |
| 954 | + if (is_numeric($docsInIndex)) | |
| 955 | + { | |
| 956 | + $indexingCoverage = ($docsInIndex * 100) / $docsInRepository; | |
| 957 | + $indexingCoverage = number_format($indexingCoverage, 2, '.',',') . '%'; | |
| 958 | + } | |
| 959 | + | |
| 960 | + // compute queue coverage | |
| 961 | + $queueCoverage = _kt('Not Available'); | |
| 962 | + if (is_numeric($docsInQueue)) | |
| 963 | + { | |
| 964 | + $queueCoverage = ($docsInQueue * 100) / $docsInRepository; | |
| 965 | + $queueCoverage = number_format($queueCoverage, 2, '.',',') . '%'; | |
| 966 | + } | |
| 967 | + } | |
| 968 | + | |
| 969 | + | |
| 970 | + $stats = array( | |
| 971 | + 'optimisationDate'=>$optimisationDate, | |
| 972 | + 'optimisationPeriod'=>$optimisationPeriod, | |
| 973 | + 'indexingDate'=>$indexingDate, | |
| 974 | + 'indexingPeriod'=>$indexingPeriod, | |
| 975 | + 'docsInIndex'=>$docsInIndex, | |
| 976 | + 'docsInQueue'=>$docsInQueue, | |
| 977 | + 'errorsInQueue'=>$errorsInQueue, | |
| 978 | + 'docsInRepository'=>$docsInRepository, | |
| 979 | + 'indexingCoverage'=>$indexingCoverage, | |
| 980 | + 'queueCoverage'=>$queueCoverage, | |
| 981 | + 'noOptimisation'=>$noOptimisation | |
| 982 | + ); | |
| 983 | + | |
| 984 | + KTUtil::setSystemSetting('indexerStats', serialize($stats)); | |
| 985 | + | |
| 986 | + $indexer = Indexer::get(); | |
| 987 | + | |
| 988 | + $diagnosis = $indexer->diagnose(); | |
| 989 | + KTUtil::setSystemSetting('indexerDiagnostics', serialize($diagnosis)); | |
| 990 | + | |
| 991 | + $extractorDiagnosis = $indexer->diagnoseExtractors(); | |
| 992 | + | |
| 993 | + KTUtil::setSystemSetting('extractorDiagnostics', serialize($extractorDiagnosis)); | |
| 994 | + } | |
| 995 | + | |
| 902 | 996 | /** |
| 903 | 997 | * The main function that may be called repeatedly to index documents. |
| 904 | 998 | * | ... | ... |
sql/mysql/install/data.sql
| ... | ... | @@ -1090,13 +1090,15 @@ LOCK TABLES `scheduler_tasks` WRITE; |
| 1090 | 1090 | INSERT INTO `scheduler_tasks` VALUES |
| 1091 | 1091 | (1,'Indexing','search2/bin/cronIndexer.php','',0,'1min','2007-10-01',NULL,0,'system'), |
| 1092 | 1092 | (2,'Index Migration','search2/bin/cronMigration.php','',0,'5mins','2007-10-01',NULL,0,'system'), |
| 1093 | -(3,'Index Optimisation','search2/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0,'system'), | |
| 1093 | +(3,'Index Optimization','search2/bin/cronOptimize.php','',0,'weekly','2007-10-01',NULL,0,'system'), | |
| 1094 | 1094 | (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'), |
| 1095 | 1095 | (5,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled'), |
| 1096 | 1096 | (6,'Open Office test','bin/checkopenoffice.php','',0,'1min','2007-10-01',NULL,0,'enabled'), |
| 1097 | 1097 | (7,'Cleanup Temporary Directory','search2/bin/cronCleanup.php','',0,'1min','2007-10-01',NULL,0,'enabled'), |
| 1098 | 1098 | (8,'Disk Usage and Folder Utilisation Statistics','plugins/housekeeper/bin/UpdateStats.php','',0,'5mins','2007-10-01',NULL,0,'enabled'), |
| 1099 | -(9,'Check Latest Version','plugins/ktstandard/AdminVersionPlugin/bin/UpdateNewVersion.php','',0,'daily','2007-10-01',NULL,0,'enabled'); | |
| 1099 | +(9,'Check Latest Version','plugins/ktstandard/AdminVersionPlugin/bin/UpdateNewVersion.php','',0,'daily','2007-10-01',NULL,0,'enabled'), | |
| 1100 | +(10,'Refresh Index Statistics','search2/bin/cronIndexStats.php','',0,'daily','2007-10-01',NULL,0,'enabled'), | |
| 1101 | +(11,'Refresh Resource Dependancies','search2/bin/cronResources.php','',0,'daily','2007-10-01',NULL,0,'enabled'); | |
| 1100 | 1102 | /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; |
| 1101 | 1103 | UNLOCK TABLES; |
| 1102 | 1104 | |
| ... | ... | @@ -2013,7 +2015,7 @@ UNLOCK TABLES; |
| 2013 | 2015 | |
| 2014 | 2016 | LOCK TABLES `zseq_scheduler_tasks` WRITE; |
| 2015 | 2017 | /*!40000 ALTER TABLE `zseq_scheduler_tasks` DISABLE KEYS */; |
| 2016 | -INSERT INTO `zseq_scheduler_tasks` VALUES (9); | |
| 2018 | +INSERT INTO `zseq_scheduler_tasks` VALUES (11); | |
| 2017 | 2019 | /*!40000 ALTER TABLE `zseq_scheduler_tasks` ENABLE KEYS */; |
| 2018 | 2020 | UNLOCK TABLES; |
| 2019 | 2021 | ... | ... |
sql/mysql/upgrade/3.5.2/zdashboard_tasks2.sql
0 → 100644
| 1 | +select @id:=max(id)+1 from scheduler_tasks; | |
| 2 | +INSERT INTO `scheduler_tasks` VALUES (@id,'Refresh Index Statistics','search2/bin/cronIndexStats.php','',0,'1min','2007-10-01',NULL,0,'enabled'); | |
| 3 | + | |
| 4 | +select @id:=max(id)+1 from scheduler_tasks; | |
| 5 | +INSERT INTO `scheduler_tasks` VALUES (@id,'Refresh Resource Dependancies','search2/bin/cronResources.php','',0,'1min','2007-10-01',NULL,0,'enabled'); | |
| 6 | + | |
| 7 | +UPDATE zseq_scheduler_tasks set id=@id; | |
| 8 | + | |
| 9 | +UPDATE scheduler_tasks set task='Index Optimization', script_url = 'search2/bin/cronOptimize.php' where script_url = 'search2/bin/optimise.php'; | |
| 0 | 10 | \ No newline at end of file | ... | ... |