glpi / src / plugins / vigilo / inc / hls.class.php @ 14b31af4
History | View | Annotate | Download (1.58 KB)
1 | 92b19eed | Francois POIROTTE | <?php
|
---|---|---|---|
2 | |||
3 | ea2027b6 | Francois POIROTTE | class PluginVigiloHls extends VigiloXml |
4 | 92b19eed | Francois POIROTTE | { |
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 | ea2027b6 | Francois POIROTTE | self::MESSAGE, |
20 | 1, // Seuil warning |
||
21 | 0 // Seuil critical |
||
22 | 92b19eed | Francois POIROTTE | ); |
23 | $nbServices = 0; |
||
24 | foreach ($host->getTests() as $test) { |
||
25 | foreach ($test->getNagiosNames() as $service) { |
||
26 | ea2027b6 | Francois POIROTTE | $this->hlsServices[] = new VigiloDepends($name, $service, 2, 1); |
27 | 92b19eed | Francois POIROTTE | $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 | ea2027b6 | Francois POIROTTE | self::MESSAGE, |
36 | 1, // Seuil warning |
||
37 | 0 // Seuil critical |
||
38 | 92b19eed | Francois POIROTTE | ); |
39 | ea2027b6 | Francois POIROTTE | $this->hlsHost[] = new VigiloDepends($name, null, 2); |
40 | $this->hlsHost[] = new VigiloDepends(null, "services:$name", 2, 1); |
||
41 | 92b19eed | Francois POIROTTE | $this->name = $name; |
42 | } |
||
43 | |||
44 | public function getName() |
||
45 | { |
||
46 | return $this->name; |
||
47 | } |
||
48 | |||
49 | public function __toString() |
||
50 | { |
||
51 | 420b5990 | Francois POIROTTE | return "<" . "?xml version=\"1.0\"?" . |
52 | "><hlservices>{$this->hlsServices}{$this->hlsHost}</hlservices>";
|
||
53 | 92b19eed | Francois POIROTTE | } |
54 | } |