glpi / Vigilo / VigiloTestSoftware.php @ 18eae138
History | View | Annotate | Download (4.43 KB)
1 | a5c9df40 | Thibault Louet | <?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 | 79397eb3 | Romain CHOLLET | if (strstr($softwareName, "vigilo-test")) |
28 | 0e0753c8 | Romain CHOLLET | { |
29 | $functionArray=array("addCustomTest", array($softwareName)); |
||
30 | } |
||
31 | else
|
||
32 | { |
||
33 | 0d761a49 | Romain CHOLLET | if (!array_key_exists($softwareName, $this->softwareBase)) { |
34 | 2ef80588 | Romain CHOLLET | return;
|
35 | } |
||
36 | 0e0753c8 | Romain CHOLLET | $functionArray=$this->softwareBase[$softwareName]; |
37 | 2ef80588 | Romain CHOLLET | } |
38 | a5c9df40 | Thibault Louet | $this->testTable[]=call_user_func_array(array($this,$functionArray[0]), $functionArray[1]); |
39 | } |
||
40 | |||
41 | 0e0753c8 | Romain CHOLLET | protected function addCustomTest($softwareName) |
42 | { |
||
43 | b204adb9 | Romain CHOLLET | $software_name = str_replace('vigilo-test-', '', $softwareName); |
44 | 79397eb3 | Romain CHOLLET | $explode_software_name = explode('-', $software_name, 2); |
45 | b204adb9 | Romain CHOLLET | $args=array(); |
46 | 2ef80588 | Romain CHOLLET | switch(strtolower($explode_software_name[0])) |
47 | b204adb9 | Romain CHOLLET | { |
48 | 79397eb3 | Romain CHOLLET | case "process": |
49 | 2ef80588 | Romain CHOLLET | $args[]=new VigiloArg('processname', $explode_software_name[1]); |
50 | $explode_software_name[0] = "Process"; |
||
51 | break;
|
||
52 | 79397eb3 | Romain CHOLLET | case "service": |
53 | 2ef80588 | Romain CHOLLET | $args[]=new VigiloArg('svcname', $explode_software_name[1]); |
54 | $explode_software_name[0] = "Service"; |
||
55 | break;
|
||
56 | 79397eb3 | Romain CHOLLET | case "tcp": |
57 | $args[]=new VigiloArg('port', $explode_software_name[1]); |
||
58 | 2ef80588 | Romain CHOLLET | $explode_software_name[0] = "TCP"; |
59 | break;
|
||
60 | b204adb9 | Romain CHOLLET | default: return; |
61 | } |
||
62 | |||
63 | 79397eb3 | Romain CHOLLET | return new VigiloTest($explode_software_name[0], $args); |
64 | 0e0753c8 | Romain CHOLLET | } |
65 | |||
66 | a5c9df40 | Thibault Louet | protected function addNTPTest() |
67 | { |
||
68 | 0e0753c8 | Romain CHOLLET | $args=array(); |
69 | a5c9df40 | Thibault Louet | //$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 | 0e0753c8 | Romain CHOLLET | $args[]=new VigiloArg('crit', 2000); |
80 | $args[]=new VigiloArg('warn', 5000); |
||
81 | a5c9df40 | Thibault Louet | return new VigiloTest('NTPq', $args); |
82 | } |
||
83 | |||
84 | 0e0753c8 | Romain CHOLLET | protected function addNTPSyncTest() // OK |
85 | a5c9df40 | Thibault Louet | { |
86 | return new VigiloTest('NTPSync'); |
||
87 | } |
||
88 | |||
89 | 0e0753c8 | Romain CHOLLET | protected function addHTTPTest() // OK |
90 | a5c9df40 | Thibault Louet | { |
91 | return new VigiloTest('HTTP'); |
||
92 | } |
||
93 | |||
94 | protected function addMemcachedTest($computer) |
||
95 | { |
||
96 | $args=array(); |
||
97 | 0e0753c8 | Romain CHOLLET | $args[]=new VigiloArg('port', 11211); |
98 | a5c9df40 | Thibault Louet | 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 | 0e0753c8 | Romain CHOLLET | $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 | a5c9df40 | Thibault Louet | } |
114 | |||
115 | protected function addProxyTest() |
||
116 | { |
||
117 | 0e0753c8 | Romain CHOLLET | $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 | a5c9df40 | Thibault Louet | } |
123 | |||
124 | protected function addRRDcachedTest($computer) |
||
125 | { |
||
126 | 0e0753c8 | Romain CHOLLET | $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 | a5c9df40 | Thibault Louet | } |
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 | 0e0753c8 | Romain CHOLLET | $args=array(); |
149 | //$args[]=new VigiloArg('rules','');
|
||
150 | $args[]=new VigiloArg('servicename','vigilo-correlator'); |
||
151 | return new VigiloTest('VigiloCorrelator',$args); |
||
152 | a5c9df40 | Thibault Louet | } |
153 | |||
154 | b204adb9 | Romain CHOLLET | protected function addTestService($computer, $service) |
155 | a5c9df40 | Thibault Louet | { |
156 | 0e0753c8 | Romain CHOLLET | $args=array(); |
157 | $args[]=new VigiloArg('svcname',$service); |
||
158 | return new VigiloTest('Service',$args); |
||
159 | a5c9df40 | Thibault Louet | } |
160 | |||
161 | public function __toString() |
||
162 | { |
||
163 | return $this->child; |
||
164 | } |
||
165 | } |