glpi / src / plugins / vigilo / inc / hls.class.php @ cf9d65ba
History | View | Annotate | Download (1.56 KB)
1 |
<?php
|
---|---|
2 |
|
3 |
class PluginVigiloHls extends VigiloXml |
4 |
{ |
5 |
protected $name; |
6 |
protected $hlsHost; |
7 |
protected $hlsServices; |
8 |
|
9 |
const MESSAGE = "%(state)s: %(active_deps)r/%(total_deps)r active deps"; |
10 |
|
11 |
public function __construct(PluginVigiloAbstractMonitoredItem $host) |
12 |
{ |
13 |
$name = $host->getName(); |
14 |
|
15 |
// Création d'un HLS qui dépend de tous les services de l'hôte.
|
16 |
$this->hlsServices = new VigiloHlservice( |
17 |
"services:$name",
|
18 |
VigiloHlservice::OPERATOR_AND, |
19 |
self::MESSAGE, |
20 |
1, // Seuil warning |
21 |
0 // Seuil critical |
22 |
); |
23 |
$nbServices = 0; |
24 |
foreach ($host->getTests() as $test) { |
25 |
foreach ($test->getNagiosNames() as $service) { |
26 |
$this->hlsServices[] = new VigiloDepends($name, $service, 2, 1); |
27 |
$nbServices++;
|
28 |
} |
29 |
} |
30 |
|
31 |
// Création d'un HLS qui dépend de l'hôte et du HLS précédent.
|
32 |
$this->hlsHost = new VigiloHlservice( |
33 |
"machine:$name",
|
34 |
VigiloHlservice::OPERATOR_AND, |
35 |
self::MESSAGE, |
36 |
1, // Seuil warning |
37 |
0 // Seuil critical |
38 |
); |
39 |
$this->hlsHost[] = new VigiloDepends($name, null, 2); |
40 |
$this->hlsHost[] = new VigiloDepends(null, "services:$name", 2, 1); |
41 |
$this->name = $name; |
42 |
} |
43 |
|
44 |
public function getName() |
45 |
{ |
46 |
return $this->name; |
47 |
} |
48 |
|
49 |
public function __toString() |
50 |
{ |
51 |
return "<?xml version=\"1.0\"?><hlservices>{$this->hlsServices}{$this->hlsHost}</hlservices>"; |
52 |
} |
53 |
} |