new: Simple diagnostic tool for the modules added

pull/1482/head
iglocska 2016-08-25 17:42:46 +02:00
parent 873b201eb0
commit e013d6429d
4 changed files with 50 additions and 4 deletions

View File

@ -582,6 +582,7 @@ class ServersController extends AppController {
$stixVersion = array(0 => 'Incorrect STIX version installed, found $current, expecting $expected', 1 => 'OK');
$cyboxVersion = array(0 => 'Incorrect CyBox version installed, found $current, expecting $expected', 1 => 'OK');
$sessionErrors = array(0 => 'OK', 1 => 'High', 2 => 'Alternative setting used', 3 => 'Test failed');
$moduleErrors = array(0 => 'OK', 1 => 'System not enabled', 2 => 'No modules found');
$finalSettings = $this->Server->serverSettingsRead();
$issues = array(
@ -679,12 +680,17 @@ class ServersController extends AppController {
// if Proxy is set up in the settings, try to connect to a test URL
$proxyStatus = $this->Server->proxyDiagnostics($diagnostic_errors);
$moduleTypes = array('Enrichment', 'Import', 'Export');
foreach ($moduleTypes as $type) {
$moduleStatus[$type] = $this->Server->moduleDiagnostics($diagnostic_errors, $type);
}
// check the size of the session table
$sessionCount = 0;
$sessionStatus = $this->Server->sessionDiagnostics($diagnostic_errors, $sessionCount);
$this->set('sessionCount', $sessionCount);
$additionalViewVars = array('gpgStatus', 'sessionErrors', 'proxyStatus', 'sessionStatus', 'zmqStatus', 'stixVersion', 'cyboxVersion','gpgErrors', 'proxyErrors', 'zmqErrors', 'stixOperational', 'stix');
$additionalViewVars = array('gpgStatus', 'sessionErrors', 'proxyStatus', 'sessionStatus', 'zmqStatus', 'stixVersion', 'cyboxVersion', 'moduleStatus', 'gpgErrors', 'proxyErrors', 'zmqErrors', 'stixOperational', 'stix', 'moduleErrors', 'moduleTypes');
}
// check whether the files are writeable
$writeableDirs = $this->Server->writeableDirsDiagnostics($diagnostic_errors);

View File

@ -70,8 +70,8 @@ class Module extends AppModel {
}
public function getModules($type = false, $moduleFamily = 'Enrichment') {
$modules = $this->queryModuleServer('/modules', false, false, $moduleFamily);
public function getModules($type = false, $moduleFamily = 'Enrichment', &$exception = false) {
$modules = $this->queryModuleServer('/modules', false, false, $moduleFamily, $exception);
if (!$modules) return 'Module service not reachable.';
if (!empty($modules)) {
$result = array('modules' => $modules);
@ -132,7 +132,7 @@ class Module extends AppModel {
return $url . ':' . $port;
}
public function queryModuleServer($uri, $post = false, $hover = false, $moduleFamily = 'Enrichment') {
public function queryModuleServer($uri, $post = false, $hover = false, $moduleFamily = 'Enrichment', &$exception = false) {
$url = $this->__getModuleServer($moduleFamily);
if (!$url) return false;
App::uses('HttpSocket', 'Network/Http');
@ -146,6 +146,7 @@ class Module extends AppModel {
else $response = $httpSocket->get($url . $uri);
return json_decode($response->body, true);
} catch (Exception $e) {
$exception = $e->getMessage();
return false;
}
}

View File

@ -2525,6 +2525,21 @@ class Server extends AppModel {
return 3;
}
public function moduleDiagnostics(&$diagnostic_errors, $type = 'Enrichment') {
$this->Module = ClassRegistry::init('Module');
$types = array('Enrichment', 'Import', 'Export');
$diagnostic_errors++;
if (Configure::read('Plugin.' . $type . '_services_enable')) {
$exception = false;
$result = $this->Module->getModules(false, $type, $exception);
if ($exception) return $exception;
if (empty($result)) return 2;
$diagnostic_errors--;
return 0;
}
return 1;
}
public function proxyDiagnostics(&$diagnostic_errors) {
$proxyStatus = 0;
$proxy = Configure::read('Proxy');

View File

@ -168,6 +168,30 @@
?>
</div>
<h3>
Module System
</h3>
<p>This tool tests the various module systems and whether they are reachable based on the module settings.</p>
<?php
foreach ($moduleTypes as $type):
?>
<div style="background-color:#f7f7f9;width:300px;">
<?php
$colour = 'green';
if (isset($moduleErrors[$moduleStatus[$type]])) {
$message = $moduleErrors[$moduleStatus[$type]];
} else {
$message = h($moduleStatus[$type]);
}
if ($moduleStatus[$type] > 0) {
$colour = 'red';
}
echo $type . ' module system....<span style="color:' . $colour . ';">' . $message . '</span>';
?>
</div>
<?php
endforeach;
?>
<h3>
Session table
</h3>
<p>This tool checks how large your database's session table is. <br />Sessions in CakePHP rely on PHP's garbage collection for cleanup and in certain distributions this can be disabled by default resulting in an ever growing cake session table. <br />If you are affected by this, just click the clean session table button below.</p>