glpi / Vigilo / VigiloTestSoftware.php @ 0e0753c8
History | View | Annotate | Download (3.54 KB)
1 |
<?php
|
---|---|
2 |
|
3 |
include 'VigiloSoftwareList.php'; |
4 |
|
5 |
class VigiloTestSoftware |
6 |
{ |
7 |
protected $testTable; |
8 |
protected $softwareBase; |
9 |
protected $computer; |
10 |
protected $addedTests; |
11 |
|
12 |
public function __construct($computer) |
13 |
{ |
14 |
$this->computer=$computer; |
15 |
$this->softwareBase = getSoftwareList($this->computer); |
16 |
$this->testTable=array(); |
17 |
$this->addedTests=array(); |
18 |
} |
19 |
|
20 |
public function getTable() |
21 |
{ |
22 |
return $this->testTable; |
23 |
} |
24 |
|
25 |
public function addRelevantTestWith($softwareName) |
26 |
{ |
27 |
if (substr($softwareName, 0, 20) === "vigilo-test-process-") |
28 |
{ |
29 |
$functionArray=array("addCustomTest", array($softwareName)); |
30 |
} |
31 |
else
|
32 |
{ |
33 |
$functionArray=$this->softwareBase[$softwareName]; |
34 |
} |
35 |
$this->testTable[]=call_user_func_array(array($this,$functionArray[0]), $functionArray[1]); |
36 |
} |
37 |
|
38 |
protected function addCustomTest($softwareName) |
39 |
{ |
40 |
return new VigiloTest(substr($softwareName, 20)); |
41 |
} |
42 |
|
43 |
protected function addNTPTest() |
44 |
{ |
45 |
$args=array(); |
46 |
//$address=0;
|
47 |
//$args[]=new VigiloArg('address',$address);
|
48 |
$args[]=new VigiloArg('crit', 0); |
49 |
$args[]=new VigiloArg('warn', 0); |
50 |
return new VigiloTest('NTP', $args); |
51 |
} |
52 |
|
53 |
protected function addNTPqTest() |
54 |
{ |
55 |
$args=array(); |
56 |
$args[]=new VigiloArg('crit', 2000); |
57 |
$args[]=new VigiloArg('warn', 5000); |
58 |
return new VigiloTest('NTPq', $args); |
59 |
} |
60 |
|
61 |
protected function addNTPSyncTest() // OK |
62 |
{ |
63 |
return new VigiloTest('NTPSync'); |
64 |
} |
65 |
|
66 |
protected function addHTTPTest() // OK |
67 |
{ |
68 |
return new VigiloTest('HTTP'); |
69 |
} |
70 |
|
71 |
protected function addMemcachedTest($computer) |
72 |
{ |
73 |
$args=array(); |
74 |
$args[]=new VigiloArg('port', 11211); |
75 |
return new VigiloTest('Memcached', $args); |
76 |
} |
77 |
|
78 |
protected function addNagiosTest() |
79 |
{ |
80 |
return new VigiloTest('Nagios'); |
81 |
} |
82 |
|
83 |
protected function addPGSQLTest($computer) |
84 |
{ |
85 |
$args=array(); |
86 |
$args[]=new VigiloArg('database',"postgres"); |
87 |
$args[]=new VigiloArg('port',5432); |
88 |
$args[]=new VigiloArg('user',"postgres"); |
89 |
return new VigiloTest('PostgreSQLConnection',$args); |
90 |
} |
91 |
|
92 |
protected function addProxyTest() |
93 |
{ |
94 |
$args=array(); |
95 |
$args[]=new VigiloArg('auth',"False"); |
96 |
$args[]=new VigiloArg('port',8080); |
97 |
$args[]=new VigiloArg('url',"http://www.google.fr"); |
98 |
return new VigiloTest('Proxy',$args); |
99 |
} |
100 |
|
101 |
protected function addRRDcachedTest($computer) |
102 |
{ |
103 |
$path="/var/lib/vigilo/connector-metro/rrdcached.sock"; |
104 |
$args=array(); |
105 |
$args[]=new VigiloArg('crit',0); |
106 |
$args[]=new VigiloArg('path',$path); |
107 |
$args[]=new VigiloArg('warn',0); |
108 |
return new VigiloTest('RRDcached',$args); |
109 |
} |
110 |
|
111 |
protected function addSSHTest() |
112 |
{ |
113 |
return new VigiloTest('SSH'); |
114 |
} |
115 |
|
116 |
protected function addVigiloConnectorTest($type) |
117 |
{ |
118 |
$args=array(); |
119 |
$args[]=new VigiloArg('type', $type); |
120 |
return new VigiloTest('VigiloConnector', $args); |
121 |
} |
122 |
|
123 |
protected function addVigiloCorrelatorTest() |
124 |
{ |
125 |
$args=array(); |
126 |
//$args[]=new VigiloArg('rules','');
|
127 |
$args[]=new VigiloArg('servicename','vigilo-correlator'); |
128 |
return new VigiloTest('VigiloCorrelator',$args); |
129 |
} |
130 |
|
131 |
protected function TestService($computer, $service) |
132 |
{ |
133 |
$args=array(); |
134 |
$args[]=new VigiloArg('svcname',$service); |
135 |
return new VigiloTest('Service',$args); |
136 |
} |
137 |
|
138 |
public function __toString() |
139 |
{ |
140 |
return $this->child; |
141 |
} |
142 |
} |