1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the `tvi/monitor-bundle` project. |
5
|
|
|
* |
6
|
|
|
* (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Tvi\MonitorBundle\Check\rabbitmq\RabbitMQ; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
15
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
16
|
|
|
use Tvi\MonitorBundle\Check\CheckPluginAbstract; |
17
|
|
|
use Tvi\MonitorBundle\Exception\FeatureRequired; |
18
|
|
|
|
19
|
|
|
/** |
|
|
|
|
20
|
|
|
* @author Vladimir Turnaev <[email protected]> |
21
|
|
|
*/ |
|
|
|
|
22
|
|
|
class Plugin extends CheckPluginAbstract |
23
|
|
|
{ |
24
|
|
|
const DESCR = |
|
|
|
|
25
|
|
|
<<<'TXT' |
|
|
|
|
26
|
|
|
rabbit_mq description |
27
|
|
|
TXT; |
28
|
|
|
|
29
|
|
|
const PATH = __DIR__; |
30
|
|
|
|
31
|
|
|
const GROUP = 'rabbit_mq'; |
32
|
|
|
const CHECK_NAME = 'core:rabbit_mq'; |
33
|
|
|
|
34
|
|
|
/** |
|
|
|
|
35
|
|
|
* @throws FeatureRequired |
36
|
|
|
*/ |
|
|
|
|
37
|
1 |
|
public function checkRequirements(array $checkSettings) |
38
|
|
|
{ |
39
|
1 |
|
if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) { |
40
|
|
|
throw new FeatureRequired('PhpAmqpLib is not installed'); |
41
|
|
|
} |
42
|
1 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
|
|
|
|
45
|
|
|
* @param NodeDefinition|ArrayNodeDefinition $node |
|
|
|
|
46
|
|
|
* |
47
|
|
|
* @return NodeDefinition|ArrayNodeDefinition |
48
|
|
|
*/ |
49
|
56 |
|
protected function _check(NodeDefinition $node): NodeDefinition |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
$node = $node |
52
|
56 |
|
->children() |
53
|
56 |
|
->arrayNode('check') |
|
|
|
|
54
|
56 |
|
->beforeNormalization() |
|
|
|
|
55
|
56 |
|
->ifString() |
|
|
|
|
56
|
|
|
->then(static function ($v) { return ['dsn' => $v]; }) |
|
|
|
|
57
|
56 |
|
->end() |
58
|
56 |
|
->children() |
59
|
56 |
|
->scalarNode('host')->defaultValue('localhost')->end() |
60
|
56 |
|
->integerNode('port')->defaultValue(5672)->end() |
61
|
56 |
|
->scalarNode('user')->defaultValue('guest')->end() |
62
|
56 |
|
->scalarNode('password')->defaultValue('guest')->end() |
63
|
56 |
|
->scalarNode('vhost')->defaultValue('/')->end() |
64
|
56 |
|
->scalarNode('dsn')->defaultNull()->end() |
65
|
56 |
|
->end() |
66
|
56 |
|
->end() |
67
|
56 |
|
->end(); |
68
|
|
|
|
69
|
56 |
|
$this->_addition($node); |
70
|
|
|
|
71
|
56 |
|
return $node; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|