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