glpi / Vigilo / VigiloTestSoftware.php @ 2ef80588
History | View | Annotate | Download (4.44 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 (strstr($softwareName, "vigilo-test")) |
28 |
{ |
29 |
$functionArray=array("addCustomTest", array($softwareName)); |
30 |
} |
31 |
else
|
32 |
{ |
33 |
if (!array_key_exists($softwareName, $this->softwareBase)) |
34 |
{ |
35 |
return;
|
36 |
} |
37 |
$functionArray=$this->softwareBase[$softwareName]; |
38 |
} |
39 |
$this->testTable[]=call_user_func_array(array($this,$functionArray[0]), $functionArray[1]); |
40 |
} |
41 |
|
42 |
protected function addCustomTest($softwareName) |
43 |
{ |
44 |
$software_name = str_replace('vigilo-test-', '', $softwareName); |
45 |
$explode_software_name = explode('-', $software_name, 2); |
46 |
$args=array(); |
47 |
switch(strtolower($explode_software_name[0])) |
48 |
{ |
49 |
case "process": |
50 |
$args[]=new VigiloArg('processname', $explode_software_name[1]); |
51 |
$explode_software_name[0] = "Process"; |
52 |
break;
|
53 |
case "service": |
54 |
$args[]=new VigiloArg('svcname', $explode_software_name[1]); |
55 |
$explode_software_name[0] = "Service"; |
56 |
break;
|
57 |
case "tcp": |
58 |
$args[]=new VigiloArg('port', $explode_software_name[1]); |
59 |
$explode_software_name[0] = "TCP"; |
60 |
break;
|
61 |
default: return; |
62 |
} |
63 |
|
64 |
return new VigiloTest($explode_software_name[0], $args); |
65 |
} |
66 |
|
67 |
protected function addNTPTest() |
68 |
{ |
69 |
$args=array(); |
70 |
//$address=0;
|
71 |
//$args[]=new VigiloArg('address',$address);
|
72 |
$args[]=new VigiloArg('crit', 0); |
73 |
$args[]=new VigiloArg('warn', 0); |
74 |
return new VigiloTest('NTP', $args); |
75 |
} |
76 |
|
77 |
protected function addNTPqTest() |
78 |
{ |
79 |
$args=array(); |
80 |
$args[]=new VigiloArg('crit', 2000); |
81 |
$args[]=new VigiloArg('warn', 5000); |
82 |
return new VigiloTest('NTPq', $args); |
83 |
} |
84 |
|
85 |
protected function addNTPSyncTest() // OK |
86 |
{ |
87 |
return new VigiloTest('NTPSync'); |
88 |
} |
89 |
|
90 |
protected function addHTTPTest() // OK |
91 |
{ |
92 |
return new VigiloTest('HTTP'); |
93 |
} |
94 |
|
95 |
protected function addMemcachedTest($computer) |
96 |
{ |
97 |
$args=array(); |
98 |
$args[]=new VigiloArg('port', 11211); |
99 |
return new VigiloTest('Memcached', $args); |
100 |
} |
101 |
|
102 |
protected function addNagiosTest() |
103 |
{ |
104 |
return new VigiloTest('Nagios'); |
105 |
} |
106 |
|
107 |
protected function addPGSQLTest($computer) |
108 |
{ |
109 |
$args=array(); |
110 |
$args[]=new VigiloArg('database',"postgres"); |
111 |
$args[]=new VigiloArg('port',5432); |
112 |
$args[]=new VigiloArg('user',"postgres"); |
113 |
return new VigiloTest('PostgreSQLConnection',$args); |
114 |
} |
115 |
|
116 |
protected function addProxyTest() |
117 |
{ |
118 |
$args=array(); |
119 |
$args[]=new VigiloArg('auth',"False"); |
120 |
$args[]=new VigiloArg('port',8080); |
121 |
$args[]=new VigiloArg('url',"http://www.google.fr"); |
122 |
return new VigiloTest('Proxy',$args); |
123 |
} |
124 |
|
125 |
protected function addRRDcachedTest($computer) |
126 |
{ |
127 |
$path="/var/lib/vigilo/connector-metro/rrdcached.sock"; |
128 |
$args=array(); |
129 |
$args[]=new VigiloArg('crit',0); |
130 |
$args[]=new VigiloArg('path',$path); |
131 |
$args[]=new VigiloArg('warn',0); |
132 |
return new VigiloTest('RRDcached',$args); |
133 |
} |
134 |
|
135 |
protected function addSSHTest() |
136 |
{ |
137 |
return new VigiloTest('SSH'); |
138 |
} |
139 |
|
140 |
protected function addVigiloConnectorTest($type) |
141 |
{ |
142 |
$args=array(); |
143 |
$args[]=new VigiloArg('type', $type); |
144 |
return new VigiloTest('VigiloConnector', $args); |
145 |
} |
146 |
|
147 |
protected function addVigiloCorrelatorTest() |
148 |
{ |
149 |
$args=array(); |
150 |
//$args[]=new VigiloArg('rules','');
|
151 |
$args[]=new VigiloArg('servicename','vigilo-correlator'); |
152 |
return new VigiloTest('VigiloCorrelator',$args); |
153 |
} |
154 |
|
155 |
protected function addTestService($computer, $service) |
156 |
{ |
157 |
$args=array(); |
158 |
$args[]=new VigiloArg('svcname',$service); |
159 |
return new VigiloTest('Service',$args); |
160 |
} |
161 |
|
162 |
public function __toString() |
163 |
{ |
164 |
return $this->child; |
165 |
} |
166 |
} |