mirror of https://github.com/MISP/MISP
Merge branch 'develop' into add_simple_background_jobs
commit
f49d2fde09
|
@ -1,5 +1,5 @@
|
|||
; Generated by RHash v1.4.2 on 2021-11-09 at 12:07.51
|
||||
; Generated by RHash v1.4.2 on 2021-11-09 at 12:08.58
|
||||
; Written by Kravchenko Aleksey (Akademgorodok) - http://rhash.sf.net/
|
||||
;
|
||||
; 160592 12:07.51 2021-11-09 INSTALL.sh
|
||||
; 160592 12:08.58 2021-11-09 INSTALL.sh
|
||||
INSTALL.sh 9645FCE5A2C4EC2130B5D08AB2676CEFB04A6D80 FD967530AD42883B1493305A873F86DFF04533D77DE021805B4CCDAE7C86392E BDE824E4A236D494AC0C834E7B23C1BF9A4DB799559245E79A481BA871B3B303D22782ACBE63AF37AECEC7541237E689 7B4D1EADFDCC4DD9B41F83869440013B0C6E1964401368F91A4AACA9D3FEA62DED7B1406B8DC520B80182D5F03D7646A4760E1A30A32EA19D1B7111BDA6EE8C3
|
||||
|
|
|
@ -3,6 +3,7 @@ App::uses('AppShell', 'Console/Command');
|
|||
|
||||
/**
|
||||
* @property Server $Server
|
||||
* @property Feed $Feed
|
||||
*/
|
||||
class AdminShell extends AppShell
|
||||
{
|
||||
|
@ -947,4 +948,89 @@ class AdminShell extends AppShell
|
|||
|
||||
$this->out(__('New encryption key "%s" saved into config file.', $new));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Redis $redis
|
||||
* @param string $prefix
|
||||
* @return array[int, int]
|
||||
*/
|
||||
private function redisSize($redis, $prefix)
|
||||
{
|
||||
$keyCount = 0;
|
||||
$size = 0;
|
||||
$it = null;
|
||||
while ($keys = $redis->scan($it, $prefix)) {
|
||||
$redis->pipeline();
|
||||
foreach ($keys as $key) {
|
||||
$redis->rawCommand("memory", "usage", $key);
|
||||
}
|
||||
$result = $redis->exec();
|
||||
$keyCount += count($keys);
|
||||
$size += array_sum($result);
|
||||
}
|
||||
return [$keyCount, $size];
|
||||
}
|
||||
|
||||
public function redisMemoryUsage()
|
||||
{
|
||||
$redis = $this->Server->setupRedisWithException();
|
||||
$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
|
||||
|
||||
$output = [];
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:feed_cache:*');
|
||||
$output['feed_cache_count'] = $count;
|
||||
$output['feed_cache_size'] = $size;
|
||||
|
||||
// Size of different feeds
|
||||
$feedIds = $this->Feed->find('column', [
|
||||
'fields' => ['id'],
|
||||
]);
|
||||
|
||||
$redis->pipeline();
|
||||
foreach ($feedIds as $feedId) {
|
||||
$redis->rawCommand("memory", "usage", 'misp:feed_cache:' . $feedId);
|
||||
}
|
||||
$feedSizes = $redis->exec();
|
||||
|
||||
foreach ($feedIds as $k => $feedId) {
|
||||
if ($feedSizes[$k]) {
|
||||
$output['cache_feed_size_' . $feedId] = $feedSizes[$k];
|
||||
}
|
||||
}
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:wlc:*');
|
||||
$output['warninglist_cache_count'] = $count;
|
||||
$output['warninglist_cache_size'] = $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:warninglist_entries_cache:*');
|
||||
$output['warninglist_entries_count'] = $count;
|
||||
$output['warninglist_entries_size'] = $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:top_correlation');
|
||||
$output['top_correlation_count'] = $count;
|
||||
$output['top_correlation_size'] = $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:correlation_exclusions');
|
||||
$output['correlation_exclusions_count'] = $count;
|
||||
$output['correlation_exclusions_size'] = $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:event_lock:*');
|
||||
$output['event_lock_count'] = $count;
|
||||
$output['event_lock_size'] = $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:user_ip:*');
|
||||
$output['user_ip_count'] = $count;
|
||||
$output['user_ip_size'] = $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:ip_user:*');
|
||||
$output['user_ip_count'] += $count;
|
||||
$output['user_ip_size'] += $size;
|
||||
|
||||
list($count, $size) = $this->redisSize($redis, 'misp:authkey_usage:*');
|
||||
$output['authkey_usage_count'] = $count;
|
||||
$output['authkey_usage_size'] = $size;
|
||||
|
||||
$this->json($output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,18 @@ App::uses('AppModel', 'Model');
|
|||
class AppShell extends Shell
|
||||
{
|
||||
public $tasks = array('ConfigLoad');
|
||||
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->ConfigLoad->execute();
|
||||
}
|
||||
|
||||
public function perform()
|
||||
{
|
||||
$this->{array_shift($this->args)}();
|
||||
}
|
||||
|
||||
protected function _welcome()
|
||||
{
|
||||
// disable welcome message
|
||||
|
|
|
@ -1793,7 +1793,7 @@ class UsersController extends AppController
|
|||
// Fetch user that contains also PGP or S/MIME keys for e-mail encryption
|
||||
$userForSendMail = $this->User->getUserById($user_id);
|
||||
$body = str_replace('\n', PHP_EOL, $body);
|
||||
$result = $this->User->sendEmail($userForSendMail, $body, false, "[MISP " . Configure::read('MISP.org') . "] Email OTP");
|
||||
$result = $this->User->sendEmail($userForSendMail, $body, false, "[" . Configure::read('MISP.org') . " MISP] Email OTP");
|
||||
|
||||
if ($result) {
|
||||
$this->Flash->success(__("An email containing a OTP has been sent."));
|
||||
|
|
Loading…
Reference in New Issue