new: [Statistics shell] Added new statistics shell

- (R)etrieval (o)f (m)etrics (m)atrix (e)xtended (f)or (s)tatistics

- run it via /var/www/MISP/app/Console/cake Statistics rommelfs
pull/6783/head
iglocska 2020-12-18 12:15:57 +01:00
parent 8b318320f7
commit db2c92b591
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 25 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<?php
class StatisticsShell extends AppShell {
public $uses = array('Event', 'User', 'Organisation', 'Log');
public $uses = array('Event', 'User', 'Organisation', 'Log', 'Correlation');
public function contributors()
{
@ -251,4 +251,28 @@ class StatisticsShell extends AppShell {
}
echo str_repeat('-', 63) . PHP_EOL;
}
// (R)etrieval (o)f (m)etrics (m)atrix (e)xtended (f)or (s)tatistics
public function rommelfs()
{
$this->out(json_encode([
'events' => $this->Event->find('count'),
'attributes' => $this->Event->Attribute->find('count',
['conditions' => ['Attribute.deleted' => 0], 'recursive' => -1]
),
'objects' => $this->Event->Object->find('count',
['conditions' => ['Object.deleted' => 0], 'recursive' => -1]
),
'correlations' => $this->Correlation->find('count') / 2,
'users' => $this->User->find('count',
['conditions' => ['User.disabled' => 0], 'recursive' => -1]
),
'local_organisations' => $this->Organisation->find('count',
['conditions' => ['Organisation.local' => 0], 'recursive' => -1]
),
'external_organisations' => $this->Organisation->find('count',
['conditions' => ['Organisation.local' => 0], 'recursive' => -1]
)
], JSON_PRETTY_PRINT));
}
}