glpi / src / plugins / vigilo / inc / hls.class.php @ 92b19eed
History | View | Annotate | Download (1.43 KB)
1 |
<?php
|
---|---|
2 |
|
3 |
class PluginVigiloAbstractMonitoredItem 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 |
); |
21 |
$nbServices = 0; |
22 |
foreach ($host->getTests() as $test) { |
23 |
foreach ($test->getNagiosNames() as $service) { |
24 |
$this->hlsServices[] = new VigiloDepends($name, $service); |
25 |
$nbServices++;
|
26 |
} |
27 |
} |
28 |
|
29 |
// Création d'un HLS qui dépend de l'hôte et du HLS précédent.
|
30 |
$this->hlsHost = new VigiloHlservice( |
31 |
"machine:$name",
|
32 |
VigiloHlservice::OPERATOR_AND, |
33 |
self::MESSAGE |
34 |
); |
35 |
$this->hlsHost[] = new VigiloDepends($host); |
36 |
$this->hlsHost[] = new VigiloDepends(null, "services:$name"); |
37 |
$this->name = $name; |
38 |
} |
39 |
|
40 |
public function getName() |
41 |
{ |
42 |
return $this->name; |
43 |
} |
44 |
|
45 |
public function __toString() |
46 |
{ |
47 |
return "<?xml version="1.0"?><hlservices>{$this->hlsHost}{$this->hlsServices}</hlservices>"; |
48 |
} |
49 |
} |