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