1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace Drupal\mongodb_watchdog\Commands; |
6
|
|
|
|
7
|
|
|
use Drupal\mongodb_watchdog\Install\Sanitycheck; |
8
|
|
|
use Drush\Commands\DrushCommands; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Drush 9 commands service for the mongodb_watchdog module. |
12
|
|
|
*/ |
13
|
|
|
class MongoDbWatchdogCommands extends DrushCommands { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The mongodb.watchdog.sanity_check service. |
17
|
|
|
* |
18
|
|
|
* @var \Drupal\mongodb_watchdog\Install\Sanitycheck |
19
|
|
|
*/ |
20
|
|
|
protected $sanityCheck; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* MongodbWatchdogCommands constructor. |
24
|
|
|
* |
25
|
|
|
* @param \Drupal\mongodb_watchdog\Install\Sanitycheck $sanityCheck |
26
|
|
|
* The mongodb.watchdog.sanity_check service. |
27
|
|
|
*/ |
28
|
|
|
public function __construct(Sanitycheck $sanityCheck) { |
29
|
|
|
$this->sanityCheck = $sanityCheck; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Run a sanity check on the contents of the logger database in MongoDB. |
34
|
|
|
* |
35
|
|
|
* @param array $options |
36
|
|
|
* A Drush-magic parameter enabling Drush to choose the output format. |
37
|
|
|
* |
38
|
|
|
* @return array |
39
|
|
|
* An array of collection by document count range. A high number of single |
40
|
|
|
* document collections is a hint of a problem with the application code |
41
|
|
|
* using the logger subsystem. |
42
|
|
|
* |
43
|
|
|
* @usage mongodb:watchdog:sanitycheck |
44
|
|
|
* Report on the site of the event collections, per size bucket. |
45
|
|
|
* |
46
|
|
|
* The "unused" $options allows Drush to know the command should support the |
47
|
|
|
* --format option, with the chosen default. |
48
|
|
|
* |
49
|
|
|
* @command mongodb:watchdog:sanitycheck |
50
|
|
|
* @aliases mdbwsc,mowd-sc |
51
|
|
|
*/ |
52
|
|
|
public function sanityCheck(array $options = ['format' => 'yaml']): array { |
53
|
|
|
return $this->sanityCheck->buildCollectionstats(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
} |
57
|
|
|
|