commit | author | age
|
31f6ce
|
1 |
<?php |
M |
2 |
/* |
|
3 |
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
class tools_monitor { |
|
31 |
|
b1a6a5
|
32 |
function showServerLoad() { |
MC |
33 |
global $app; |
31f6ce
|
34 |
|
b1a6a5
|
35 |
/* fetch the Data from the DB */ |
MC |
36 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'server_load' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
37 |
|
b1a6a5
|
38 |
if(isset($record['data'])) { |
MC |
39 |
$data = unserialize($record['data']); |
31f6ce
|
40 |
|
b1a6a5
|
41 |
/* |
31f6ce
|
42 |
Format the data |
M |
43 |
*/ |
b1a6a5
|
44 |
if (strlen($data['up_minutes']) == "1") $data['up_minutes'] = "0".$data['up_minutes']; |
MC |
45 |
$html = |
|
46 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
47 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'"> |
M |
48 |
<table> |
|
49 |
<tr> |
|
50 |
<td>' . $app->lng("Server online since").':</td> |
|
51 |
<td>' . $data['up_days'] . ' days, ' . $data['up_hours'] . ':' . $data['up_minutes'] . ' hours</center></td> |
|
52 |
</tr> |
|
53 |
<tr> |
|
54 |
<td>' . $app->lng("Users online").':</td> |
|
55 |
<td>' . $data['user_online'] . '</td> |
|
56 |
</tr>' . |
b1a6a5
|
57 |
'<tr> |
31f6ce
|
58 |
<td>' . $app->lng("System load 1 minute") . ':</td> |
M |
59 |
<td>' . $data['load_1'] . '</td> |
|
60 |
</tr> |
|
61 |
<tr> |
|
62 |
<td>' . $app->lng("System load 5 minutes") . ':</td> |
|
63 |
<td>' . $data['load_5'] . '</td> |
|
64 |
</tr> |
|
65 |
<tr> |
|
66 |
<td>'.$app->lng("System load 15 minutes").':</td> |
|
67 |
<td>' . $data['load_15'] . '</td> |
|
68 |
</tr> |
|
69 |
</table> |
|
70 |
</div> |
|
71 |
</div>'; |
b1a6a5
|
72 |
} else { |
MC |
73 |
$html = '<p>'.$app->lng("no_data_serverload_txt").'</p>'; |
|
74 |
} |
31f6ce
|
75 |
|
b1a6a5
|
76 |
return $html; |
MC |
77 |
} |
31f6ce
|
78 |
|
b1a6a5
|
79 |
function showDiskUsage () { |
MC |
80 |
global $app; |
31f6ce
|
81 |
|
b1a6a5
|
82 |
/* fetch the Data from the DB */ |
MC |
83 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'disk_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
84 |
|
b1a6a5
|
85 |
if(isset($record['data'])) { |
MC |
86 |
$data = unserialize($record['data']); |
31f6ce
|
87 |
|
b1a6a5
|
88 |
/* |
31f6ce
|
89 |
Format the data |
M |
90 |
*/ |
b1a6a5
|
91 |
$html = |
MC |
92 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
93 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'"> |
M |
94 |
<table> |
|
95 |
<tr> |
|
96 |
<td>'.$app->lng("monitor_diskusage_filesystem_txt").'</td> |
|
97 |
<td>'.$app->lng("monitor_diskusage_type_txt").'</td> |
|
98 |
<td>'.$app->lng("monitor_diskusage_size_txt").'</td> |
|
99 |
<td>'.$app->lng("monitor_diskusage_used_txt").'</td> |
|
100 |
<td>'.$app->lng("monitor_diskusage_available_txt").'</td> |
|
101 |
<td>'.$app->lng("monitor_diskusage_usage_txt").'</td> |
|
102 |
<td>'.$app->lng("monitor_diskusage_mounted_txt").'</td> |
|
103 |
</tr>'; |
b1a6a5
|
104 |
foreach($data as $line) { |
MC |
105 |
$html .= '<tr>'; |
|
106 |
foreach ($line as $item) { |
|
107 |
$html .= '<td>' . $item . '</td>'; |
|
108 |
} |
|
109 |
$html .= '</tr>'; |
|
110 |
} |
|
111 |
$html .= '</table>'; |
|
112 |
$html .= '</div></div>'; |
|
113 |
} else { |
|
114 |
$html = '<p>'.$app->lng("no_data_diskusage_txt").'</p>'; |
|
115 |
} |
31f6ce
|
116 |
|
M |
117 |
|
b1a6a5
|
118 |
return $html; |
MC |
119 |
} |
31f6ce
|
120 |
|
b1a6a5
|
121 |
function showDatabaseSize () { |
MC |
122 |
global $app; |
|
123 |
/* fetch the Data from the DB */ |
|
124 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
|
125 |
if(isset($record['data'])) { |
|
126 |
$data = unserialize($record['data']); |
|
127 |
/* |
71accc
|
128 |
Format the data |
T |
129 |
*/ |
b1a6a5
|
130 |
$html = |
MC |
131 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
71accc
|
132 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'"> |
T |
133 |
<table> |
|
134 |
<thead> |
|
135 |
<tr> |
|
136 |
<td>'.$app->lng("monitor_database_name_txt").'</td> |
|
137 |
<td>'.$app->lng("monitor_database_size_txt").'</td> |
|
138 |
<td>'.$app->lng("monitor_database_client_txt").'</td> |
|
139 |
</tr>'; |
b1a6a5
|
140 |
foreach($data as $line) { |
MC |
141 |
$html .= '<tr>'; |
|
142 |
if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']); |
|
143 |
$t=$app->db->queryOneRecord("SELECT username FROM client WHERE sys_groupid = ".$line['client_id']); |
|
144 |
$line['client_id']=$t['username']; |
|
145 |
unset($t); |
|
146 |
foreach ($line as $item) { |
|
147 |
$html .= '<td>' . $item . '</td>'; |
|
148 |
} |
|
149 |
$html .= '</tr></tmpl loop>'; |
|
150 |
} |
|
151 |
$html .= '</tbody></table>'; |
|
152 |
$html .= '</div></div>'; |
|
153 |
} else { |
|
154 |
$html = '<p>'.$app->lng("no_data_database_size_txt").'</p>'; |
|
155 |
} |
|
156 |
return $html; |
|
157 |
} |
71accc
|
158 |
|
b1a6a5
|
159 |
function showMemUsage () { |
MC |
160 |
global $app; |
31f6ce
|
161 |
|
b1a6a5
|
162 |
/* fetch the Data from the DB */ |
MC |
163 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mem_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
164 |
|
b1a6a5
|
165 |
if(isset($record['data'])) { |
MC |
166 |
$data = unserialize($record['data']); |
31f6ce
|
167 |
|
b1a6a5
|
168 |
/* |
31f6ce
|
169 |
Format the data |
M |
170 |
*/ |
b1a6a5
|
171 |
$html = |
MC |
172 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
173 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'"> |
M |
174 |
<table>'; |
|
175 |
|
b1a6a5
|
176 |
foreach($data as $key => $value) { |
MC |
177 |
if ($key != '') { |
|
178 |
$html .= '<tr> |
31f6ce
|
179 |
<td>' . $key . ':</td> |
M |
180 |
<td>' . $value . '</td> |
|
181 |
</tr>'; |
b1a6a5
|
182 |
} |
MC |
183 |
} |
|
184 |
$html .= '</table>'; |
|
185 |
$html .= '</div></div>'; |
31f6ce
|
186 |
|
b1a6a5
|
187 |
} else { |
MC |
188 |
$html = '<p>'.$app->lng("no_data_memusage_txt").'</p>'; |
|
189 |
} |
31f6ce
|
190 |
|
b1a6a5
|
191 |
return $html; |
MC |
192 |
} |
31f6ce
|
193 |
|
b1a6a5
|
194 |
function showCpuInfo () { |
MC |
195 |
global $app; |
31f6ce
|
196 |
|
b1a6a5
|
197 |
/* fetch the Data from the DB */ |
MC |
198 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'cpu_info' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
199 |
|
b1a6a5
|
200 |
if(isset($record['data'])) { |
MC |
201 |
$data = unserialize($record['data']); |
31f6ce
|
202 |
|
b1a6a5
|
203 |
/* |
31f6ce
|
204 |
Format the data |
M |
205 |
*/ |
b1a6a5
|
206 |
$html = |
MC |
207 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
208 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'"> |
M |
209 |
<table>'; |
b1a6a5
|
210 |
foreach($data as $key => $value) { |
MC |
211 |
if ($key != '') { |
|
212 |
$html .= '<tr> |
31f6ce
|
213 |
<td>' . $key . ':</td> |
M |
214 |
<td>' . $value . '</td> |
|
215 |
</tr>'; |
b1a6a5
|
216 |
} |
MC |
217 |
} |
|
218 |
$html .= '</table>'; |
|
219 |
$html .= '</div></div>'; |
|
220 |
} else { |
|
221 |
$html = '<p>'.$app->lng("no_data_cpuinfo_txt").'</p>'; |
|
222 |
} |
31f6ce
|
223 |
|
b1a6a5
|
224 |
return $html; |
MC |
225 |
} |
31f6ce
|
226 |
|
b1a6a5
|
227 |
function showServices () { |
MC |
228 |
global $app; |
31f6ce
|
229 |
|
b1a6a5
|
230 |
/* fetch the Data from the DB */ |
MC |
231 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
232 |
|
b1a6a5
|
233 |
if(isset($record['data'])) { |
MC |
234 |
$data = unserialize($record['data']); |
31f6ce
|
235 |
|
b1a6a5
|
236 |
/* |
31f6ce
|
237 |
Format the data |
M |
238 |
*/ |
b1a6a5
|
239 |
$html = |
MC |
240 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
241 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'"> |
M |
242 |
<table>'; |
|
243 |
|
b1a6a5
|
244 |
if($data['webserver'] != -1) { |
MC |
245 |
if($data['webserver'] == 1) { |
|
246 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
247 |
} else { |
|
248 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
249 |
} |
|
250 |
$html .= '<tr> |
31f6ce
|
251 |
<td>'.$app->lng("monitor_services_web_txt").'</td> |
M |
252 |
<td>'.$status.'</td> |
|
253 |
</tr>'; |
b1a6a5
|
254 |
} |
31f6ce
|
255 |
|
M |
256 |
|
b1a6a5
|
257 |
if($data['ftpserver'] != -1) { |
MC |
258 |
if($data['ftpserver'] == 1) { |
|
259 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
260 |
} else { |
|
261 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
262 |
} |
|
263 |
$html .= '<tr> |
31f6ce
|
264 |
<td>'.$app->lng("monitor_services_ftp_txt").'</td> |
M |
265 |
<td>'.$status.'</td> |
|
266 |
</tr>'; |
b1a6a5
|
267 |
} |
31f6ce
|
268 |
|
b1a6a5
|
269 |
if($data['smtpserver'] != -1) { |
MC |
270 |
if($data['smtpserver'] == 1) { |
|
271 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
272 |
} else { |
|
273 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
274 |
} |
|
275 |
$html .= '<tr> |
31f6ce
|
276 |
<td>'.$app->lng("monitor_services_smtp_txt").'</td> |
M |
277 |
<td>'.$status.'</td> |
|
278 |
</tr>'; |
b1a6a5
|
279 |
} |
31f6ce
|
280 |
|
b1a6a5
|
281 |
if($data['pop3server'] != -1) { |
MC |
282 |
if($data['pop3server'] == 1) { |
|
283 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
284 |
} else { |
|
285 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
286 |
} |
|
287 |
$html .= '<tr> |
31f6ce
|
288 |
<td>'.$app->lng("monitor_services_pop_txt").'</td> |
M |
289 |
<td>'.$status.'</td> |
|
290 |
</tr>'; |
b1a6a5
|
291 |
} |
31f6ce
|
292 |
|
b1a6a5
|
293 |
if($data['imapserver'] != -1) { |
MC |
294 |
if($data['imapserver'] == 1) { |
|
295 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
296 |
} else { |
|
297 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
298 |
} |
|
299 |
$html .= '<tr> |
31f6ce
|
300 |
<td>'.$app->lng("monitor_services_imap_txt").'</td> |
M |
301 |
<td>'.$status.'</td> |
|
302 |
</tr>'; |
b1a6a5
|
303 |
} |
31f6ce
|
304 |
|
b1a6a5
|
305 |
if($data['bindserver'] != -1) { |
MC |
306 |
if($data['bindserver'] == 1) { |
|
307 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
308 |
} else { |
|
309 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
310 |
} |
|
311 |
$html .= '<tr> |
31f6ce
|
312 |
<td>'.$app->lng("monitor_services_mydns_txt").'</td> |
M |
313 |
<td>'.$status.'</td> |
|
314 |
</tr>'; |
b1a6a5
|
315 |
} |
31f6ce
|
316 |
|
b1a6a5
|
317 |
if($data['mysqlserver'] != -1) { |
MC |
318 |
if($data['mysqlserver'] == 1) { |
|
319 |
$status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>'; |
|
320 |
} else { |
|
321 |
$status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>'; |
|
322 |
} |
|
323 |
$html .= '<tr> |
31f6ce
|
324 |
<td>'.$app->lng("monitor_services_mysql_txt").'</td> |
M |
325 |
<td>'.$status.'</td> |
|
326 |
</tr>'; |
b1a6a5
|
327 |
} |
31f6ce
|
328 |
|
M |
329 |
|
b1a6a5
|
330 |
$html .= '</table></div></div>'; |
MC |
331 |
} else { |
|
332 |
$html = '<p>'.$app->lng("no_data_services_txt").'</p>'; |
|
333 |
} |
31f6ce
|
334 |
|
M |
335 |
|
b1a6a5
|
336 |
return $html; |
MC |
337 |
} |
31f6ce
|
338 |
|
b1a6a5
|
339 |
function showSystemUpdate() { |
MC |
340 |
global $app; |
31f6ce
|
341 |
|
b1a6a5
|
342 |
/* fetch the Data from the DB */ |
MC |
343 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'system_update' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
344 |
|
b1a6a5
|
345 |
if(isset($record['data'])) { |
MC |
346 |
$html = |
|
347 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
348 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
b1a6a5
|
349 |
/* |
31f6ce
|
350 |
* First, we have to detect, if there is any monitoring-data. |
M |
351 |
* If not (because the destribution is not supported) show this. |
|
352 |
*/ |
b1a6a5
|
353 |
if ($record['state'] == 'no_state') { |
MC |
354 |
$html .= '<p>'.$app->lng("monitor_updates_nosupport_txt").'</p>'; |
|
355 |
} |
|
356 |
else { |
|
357 |
$data = unserialize($record['data']); |
|
358 |
$html .= nl2br(html_entity_decode($data['output'])); |
|
359 |
} |
|
360 |
$html .= '</div></div>'; |
|
361 |
} else { |
|
362 |
$html = '<p>'.$app->lng("no_data_updates_txt").'</p>'; |
|
363 |
} |
31f6ce
|
364 |
|
b1a6a5
|
365 |
return $html; |
MC |
366 |
} |
31f6ce
|
367 |
|
M |
368 |
|
b1a6a5
|
369 |
function showOpenVzBeancounter() { |
MC |
370 |
global $app; |
31f6ce
|
371 |
|
b1a6a5
|
372 |
/* fetch the Data from the DB */ |
MC |
373 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'openvz_beancounter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
374 |
|
b1a6a5
|
375 |
if(isset($record['data'])) { |
MC |
376 |
$html = |
|
377 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
378 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
b1a6a5
|
379 |
/* |
31f6ce
|
380 |
* First, we have to detect, if there is any monitoring-data. |
M |
381 |
* If not (because the server is not a VE) show this. |
|
382 |
*/ |
b1a6a5
|
383 |
$data = unserialize($record['data']); |
MC |
384 |
if ((!isset($data)) || ($data == '')) { |
|
385 |
$html .= '<p>'.$app->lng("monitor_beancounter_nosupport_txt").'</p>'; |
|
386 |
} |
|
387 |
else { |
|
388 |
$html .= '<pre>' . nl2br($data) . '</pre>'; |
|
389 |
} |
|
390 |
$html .= '</div></div>'; |
|
391 |
} else { |
|
392 |
$html = '<p>'.$app->lng("no_data_updates_txt").'</p>'; |
|
393 |
} |
31f6ce
|
394 |
|
b1a6a5
|
395 |
return $html; |
MC |
396 |
} |
31f6ce
|
397 |
|
b1a6a5
|
398 |
function showRaidState() { |
MC |
399 |
global $app; |
31f6ce
|
400 |
|
b1a6a5
|
401 |
/* fetch the Data from the DB */ |
MC |
402 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'raid_state' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
403 |
|
b1a6a5
|
404 |
if(isset($record['data'])) { |
MC |
405 |
$html = |
|
406 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
407 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
M |
408 |
|
b1a6a5
|
409 |
/* |
31f6ce
|
410 |
* First, we have to detect, if there is any monitoring-data. |
M |
411 |
* If not (because the RAID-Controler is not supported yet) show this. |
|
412 |
*/ |
b1a6a5
|
413 |
if ($record['state'] == 'no_state') { |
MC |
414 |
$html .= '<p>'.$app->lng("monitor_nosupportedraid1_txt").'</p>'; |
|
415 |
} |
|
416 |
else { |
|
417 |
$data = unserialize($record['data']); |
5fc730
|
418 |
// improve view @Author <info@typoworx.de> |
TB |
419 |
//-- $html .= nl2br($data['output']); |
|
420 |
$html .= '<xmp>' . $data['output'] . '</xmp>'; |
b1a6a5
|
421 |
} |
MC |
422 |
$html .= '</div></div>'; |
31f6ce
|
423 |
|
b1a6a5
|
424 |
} else { |
MC |
425 |
$html = '<p>'.$app->lng("no_data_raid_txt").'</p>'; |
|
426 |
} |
31f6ce
|
427 |
|
b1a6a5
|
428 |
return $html; |
MC |
429 |
} |
31f6ce
|
430 |
|
b1a6a5
|
431 |
function showRKHunter() { |
MC |
432 |
global $app; |
31f6ce
|
433 |
|
b1a6a5
|
434 |
/* fetch the Data from the DB */ |
MC |
435 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'rkhunter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
436 |
|
b1a6a5
|
437 |
if(isset($record['data'])) { |
MC |
438 |
$html = |
|
439 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
440 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
M |
441 |
|
b1a6a5
|
442 |
/* |
31f6ce
|
443 |
* First, we have to detect, if there is any monitoring-data. |
M |
444 |
* If not (because rkhunter is not installed) show this. |
|
445 |
*/ |
b1a6a5
|
446 |
$data = unserialize($record['data']); |
MC |
447 |
if ($data['output'] == '') { |
|
448 |
$html .= '<p>'.$app->lng("monitor_norkhunter_txt").'</p>'; |
|
449 |
} |
|
450 |
else { |
|
451 |
$html .= nl2br($data['output']); |
|
452 |
} |
|
453 |
$html .= '</div></div>'; |
31f6ce
|
454 |
|
b1a6a5
|
455 |
} else { |
MC |
456 |
$html = '<p>'.$app->lng("no_data_rkhunter_txt").'</p>'; |
|
457 |
} |
31f6ce
|
458 |
|
b1a6a5
|
459 |
return $html; |
MC |
460 |
} |
31f6ce
|
461 |
|
b1a6a5
|
462 |
function showFail2ban() { |
MC |
463 |
global $app; |
31f6ce
|
464 |
|
b1a6a5
|
465 |
/* fetch the Data from the DB */ |
MC |
466 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_fail2ban' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
467 |
|
b1a6a5
|
468 |
if(isset($record['data'])) { |
MC |
469 |
$html = |
|
470 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
471 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
M |
472 |
|
b1a6a5
|
473 |
/* |
31f6ce
|
474 |
* First, we have to detect, if there is any monitoring-data. |
M |
475 |
* If not (because fail2ban is not installed) show this. |
|
476 |
*/ |
b1a6a5
|
477 |
$data = unserialize($record['data']); |
MC |
478 |
if ($data == '') { |
|
479 |
$html .= '<p>'. |
|
480 |
'fail2ban is not installed at this server.<br />' . |
|
481 |
'See more (for debian) <a href="http://www.howtoforge.com/fail2ban_debian_etch" target="htf">here...</a>'. |
|
482 |
'</p>'; |
|
483 |
} |
|
484 |
else { |
|
485 |
$html .= nl2br($data); |
|
486 |
} |
|
487 |
$html .= '</div></div>'; |
31f6ce
|
488 |
|
b1a6a5
|
489 |
} else { |
MC |
490 |
$html = '<p>There is no data available at the moment.</p>'; |
|
491 |
} |
31f6ce
|
492 |
|
b1a6a5
|
493 |
return $html; |
MC |
494 |
} |
31f6ce
|
495 |
|
b1a6a5
|
496 |
function showMongoDB() { |
MC |
497 |
global $app; |
bd68aa
|
498 |
|
b1a6a5
|
499 |
/* fetch the Data from the DB */ |
MC |
500 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_mongodb' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
bd68aa
|
501 |
|
b1a6a5
|
502 |
if(isset($record['data'])) { |
MC |
503 |
$html = |
|
504 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
bd68aa
|
505 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
MC |
506 |
|
b1a6a5
|
507 |
/* |
bd68aa
|
508 |
* First, we have to detect, if there is any monitoring-data. |
MC |
509 |
* If not (because mongodb is not installed) show this. |
|
510 |
*/ |
b1a6a5
|
511 |
$data = unserialize($record['data']); |
MC |
512 |
if ($data == '') { |
|
513 |
$html .= '<p>'. |
|
514 |
'MongoDB is not installed at this server.<br />' . |
|
515 |
'See more (for debian) <a href="http://www.howtoforge.com/fail2ban_debian_etch" target="htf">here...</a>'. |
|
516 |
'</p>'; |
|
517 |
} |
|
518 |
else { |
|
519 |
$html .= nl2br($data); |
|
520 |
} |
|
521 |
$html .= '</div></div>'; |
bd68aa
|
522 |
|
b1a6a5
|
523 |
} else { |
MC |
524 |
$html = '<p>There is no data available at the moment.</p>'; |
|
525 |
} |
bd68aa
|
526 |
|
b1a6a5
|
527 |
return $html; |
MC |
528 |
} |
bd68aa
|
529 |
|
b1a6a5
|
530 |
function showIPTables() { |
MC |
531 |
global $app; |
|
532 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'iptables_rules' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
|
533 |
if(isset($record['data'])) { |
|
534 |
$html = |
|
535 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
536 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
b1a6a5
|
537 |
$data = unserialize($record['data']); |
MC |
538 |
if ($data == '') { |
|
539 |
$html .= '<p>Problem, there are no rules listed for the server</p>'; |
|
540 |
} |
|
541 |
else { |
|
542 |
$html .= nl2br($data['output']); |
|
543 |
} |
|
544 |
$html .= '</div></div>'; |
|
545 |
} else { |
|
546 |
$html = '<p>There is no data available at the moment.</p>'; |
|
547 |
} |
|
548 |
return $html; |
|
549 |
} |
31f6ce
|
550 |
|
M |
551 |
|
b1a6a5
|
552 |
function showMailq() { |
MC |
553 |
global $app; |
31f6ce
|
554 |
|
b1a6a5
|
555 |
/* fetch the Data from the DB */ |
MC |
556 |
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mailq' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
557 |
|
b1a6a5
|
558 |
if(isset($record['data'])) { |
MC |
559 |
$data = unserialize($record['data']); |
|
560 |
$html = nl2br($data['output']); |
|
561 |
} else { |
|
562 |
$html = '<p>'.$app->lng("no_data_mailq_txt").'</p>'; |
|
563 |
} |
31f6ce
|
564 |
|
b1a6a5
|
565 |
return $html; |
MC |
566 |
} |
31f6ce
|
567 |
|
b1a6a5
|
568 |
function getDataTime($type) { |
MC |
569 |
global $app; |
31f6ce
|
570 |
|
b1a6a5
|
571 |
/* fetch the Data from the DB */ |
MC |
572 |
$record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
573 |
|
b1a6a5
|
574 |
/* TODO: datetimeformat should be set somewhat other way */ |
MC |
575 |
$dateTimeFormat = $app->lng("monitor_settings_datetimeformat_txt"); |
31f6ce
|
576 |
|
b1a6a5
|
577 |
if(isset($record['created'])) { |
MC |
578 |
// $res = date('Y-m-d H:i', $record['created']); |
|
579 |
$res = date($dateTimeFormat, $record['created']); |
|
580 |
} else { |
|
581 |
$res = '????-??-?? ??:??'; |
|
582 |
} |
|
583 |
return $res; |
|
584 |
} |
|
585 |
|
31f6ce
|
586 |
} |
b1a6a5
|
587 |
|
31f6ce
|
588 |
?> |