Revision ea2027b6
Diverses corrections + seuils pour les HLS
Définit les seuils warning/critical pour les HLS de sorte que chaque HLS
représente effectivement le pire état parmi ses dépendances.
Change-Id: Iac6093a2c41c3cb27ec158aaea6af6b86b10e788
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2401
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
src/plugins/vigilo/Vigilo/VigiloDepends.php | ||
---|---|---|
4 | 4 |
{ |
5 | 5 |
protected $host; |
6 | 6 |
protected $service; |
7 |
protected $weight; |
|
8 |
protected $warningWeight; |
|
7 | 9 |
|
8 |
public function __construct($host = null, $service = null) |
|
10 |
public function __construct($host = null, $service = null, $weight = 1, $warningWeight = null)
|
|
9 | 11 |
{ |
10 | 12 |
if (null === $host && null === $service) { |
11 | 13 |
throw new Exception('Invalid dependency'); |
12 | 14 |
} |
13 | 15 |
|
14 |
if ('' === $host || '' === $service || !is_string($host) || !is_string($service)) {
|
|
16 |
if ('' === $host || '' === $service) { |
|
15 | 17 |
throw new Exception('Invalid dependency'); |
16 | 18 |
} |
17 | 19 |
|
18 |
$this->host = $host; |
|
19 |
$this->service = $service; |
|
20 |
if ((null !== $host && !is_string($host)) || |
|
21 |
(null !== $service && !is_string($service))) { |
|
22 |
throw new Exception('Invalid dependency'); |
|
23 |
} |
|
24 |
|
|
25 |
if (null !== $host && null !== $warningWeight) { |
|
26 |
// L'état "warning" n'existe pas pour les hôtes. |
|
27 |
throw new Exception('Invalid dependency'); |
|
28 |
} |
|
29 |
|
|
30 |
if (null === $warningWeight) { |
|
31 |
$warningWeight = $weight; |
|
32 |
} |
|
33 |
|
|
34 |
$this->host = $host; |
|
35 |
$this->service = $service; |
|
36 |
$this->weight = (int) $weight; |
|
37 |
$this->warningWeight = (int) $warningWeight; |
|
20 | 38 |
} |
21 | 39 |
|
22 | 40 |
public function __toString() |
23 | 41 |
{ |
24 | 42 |
if (null === $this->host) { |
25 |
return "<depends service=\"{$this->service}\"/>"; |
|
43 |
return "<depends service=\"{$this->service}\" " . |
|
44 |
"weight=\"{$this->weight}\" " . |
|
45 |
"warning_weight=\"{$this->warningWeight}\"/>"; |
|
26 | 46 |
} |
27 | 47 |
|
28 | 48 |
if (null === $this->service) { |
29 |
return "<depends host=\"{$this->host}\"/>"; |
|
49 |
return "<depends host=\"{$this->host}\" weight=\"{$this->weight}\"/>";
|
|
30 | 50 |
} |
31 | 51 |
|
32 |
return "<depends host=\"{$this->host}\" service=\"{$this->service}\"/>"; |
|
52 |
return "<depends host=\"{$this->host}\" " . |
|
53 |
"service=\"{$this->service}\" " . |
|
54 |
"weight=\"{$this->weight}\" " . |
|
55 |
"warning_weight=\"{$this->warningWeight}\"/>"; |
|
33 | 56 |
} |
34 | 57 |
} |
src/plugins/vigilo/Vigilo/VigiloHlservice.php | ||
---|---|---|
17 | 17 |
|
18 | 18 |
public function __construct($name, $operator, $message, $warnThreshold = 0, $critThreshold = 0) |
19 | 19 |
{ |
20 |
if (!in_array($operator, array(self::OP_AND, self::OP_OR, self::OP_PLUS))) {
|
|
20 |
if (!in_array($operator, array(self::OPERATOR_AND, self::OPERATOR_OR, self::OPERATOR_PLUS))) {
|
|
21 | 21 |
throw new Exception('Invalid operator'); |
22 | 22 |
} |
23 | 23 |
|
src/plugins/vigilo/inc/abstractmonitoreditem.class.php | ||
---|---|---|
33 | 33 |
return $this->item->getName(); |
34 | 34 |
} |
35 | 35 |
|
36 |
protected function filterTests($value)
|
|
36 |
public function filterTests($value)
|
|
37 | 37 |
{ |
38 | 38 |
return is_object($value) && ($value instanceof VigiloTest); |
39 | 39 |
} |
src/plugins/vigilo/inc/hls.class.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
class PluginVigiloAbstractMonitoredItem extends VigiloXml
|
|
3 |
class PluginVigiloHls extends VigiloXml
|
|
4 | 4 |
{ |
5 | 5 |
protected $name; |
6 | 6 |
protected $hlsHost; |
... | ... | |
16 | 16 |
$this->hlsServices = new VigiloHlservice( |
17 | 17 |
"services:$name", |
18 | 18 |
VigiloHlservice::OPERATOR_AND, |
19 |
self::MESSAGE |
|
19 |
self::MESSAGE, |
|
20 |
1, // Seuil warning |
|
21 |
0 // Seuil critical |
|
20 | 22 |
); |
21 | 23 |
$nbServices = 0; |
22 | 24 |
foreach ($host->getTests() as $test) { |
23 | 25 |
foreach ($test->getNagiosNames() as $service) { |
24 |
$this->hlsServices[] = new VigiloDepends($name, $service); |
|
26 |
$this->hlsServices[] = new VigiloDepends($name, $service, 2, 1);
|
|
25 | 27 |
$nbServices++; |
26 | 28 |
} |
27 | 29 |
} |
... | ... | |
30 | 32 |
$this->hlsHost = new VigiloHlservice( |
31 | 33 |
"machine:$name", |
32 | 34 |
VigiloHlservice::OPERATOR_AND, |
33 |
self::MESSAGE |
|
35 |
self::MESSAGE, |
|
36 |
1, // Seuil warning |
|
37 |
0 // Seuil critical |
|
34 | 38 |
); |
35 |
$this->hlsHost[] = new VigiloDepends($host);
|
|
36 |
$this->hlsHost[] = new VigiloDepends(null, "services:$name"); |
|
39 |
$this->hlsHost[] = new VigiloDepends($name, null, 2);
|
|
40 |
$this->hlsHost[] = new VigiloDepends(null, "services:$name", 2, 1);
|
|
37 | 41 |
$this->name = $name; |
38 | 42 |
} |
39 | 43 |
|
... | ... | |
44 | 48 |
|
45 | 49 |
public function __toString() |
46 | 50 |
{ |
47 |
return "<?xml version="1.0"?><hlservices>{$this->hlsHost}{$this->hlsServices}</hlservices>";
|
|
51 |
return "<?xml version=\"1.0\"?><hlservices>{$this->hlsHost}{$this->hlsServices}</hlservices>";
|
|
48 | 52 |
} |
49 | 53 |
} |
Also available in: Unified diff