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']); |
|
418 |
$html .= nl2br($data['output']); |
|
419 |
} |
|
420 |
$html .= '</div></div>'; |
31f6ce
|
421 |
|
b1a6a5
|
422 |
} else { |
MC |
423 |
$html = '<p>'.$app->lng("no_data_raid_txt").'</p>'; |
|
424 |
} |
31f6ce
|
425 |
|
b1a6a5
|
426 |
return $html; |
MC |
427 |
} |
31f6ce
|
428 |
|
b1a6a5
|
429 |
function showRKHunter() { |
MC |
430 |
global $app; |
31f6ce
|
431 |
|
b1a6a5
|
432 |
/* fetch the Data from the DB */ |
MC |
433 |
$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
|
434 |
|
b1a6a5
|
435 |
if(isset($record['data'])) { |
MC |
436 |
$html = |
|
437 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
438 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
M |
439 |
|
b1a6a5
|
440 |
/* |
31f6ce
|
441 |
* First, we have to detect, if there is any monitoring-data. |
M |
442 |
* If not (because rkhunter is not installed) show this. |
|
443 |
*/ |
b1a6a5
|
444 |
$data = unserialize($record['data']); |
MC |
445 |
if ($data['output'] == '') { |
|
446 |
$html .= '<p>'.$app->lng("monitor_norkhunter_txt").'</p>'; |
|
447 |
} |
|
448 |
else { |
|
449 |
$html .= nl2br($data['output']); |
|
450 |
} |
|
451 |
$html .= '</div></div>'; |
31f6ce
|
452 |
|
b1a6a5
|
453 |
} else { |
MC |
454 |
$html = '<p>'.$app->lng("no_data_rkhunter_txt").'</p>'; |
|
455 |
} |
31f6ce
|
456 |
|
b1a6a5
|
457 |
return $html; |
MC |
458 |
} |
31f6ce
|
459 |
|
b1a6a5
|
460 |
function showFail2ban() { |
MC |
461 |
global $app; |
31f6ce
|
462 |
|
b1a6a5
|
463 |
/* fetch the Data from the DB */ |
MC |
464 |
$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
|
465 |
|
b1a6a5
|
466 |
if(isset($record['data'])) { |
MC |
467 |
$html = |
|
468 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
469 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
M |
470 |
|
b1a6a5
|
471 |
/* |
31f6ce
|
472 |
* First, we have to detect, if there is any monitoring-data. |
M |
473 |
* If not (because fail2ban is not installed) show this. |
|
474 |
*/ |
b1a6a5
|
475 |
$data = unserialize($record['data']); |
MC |
476 |
if ($data == '') { |
|
477 |
$html .= '<p>'. |
|
478 |
'fail2ban is not installed at this server.<br />' . |
|
479 |
'See more (for debian) <a href="http://www.howtoforge.com/fail2ban_debian_etch" target="htf">here...</a>'. |
|
480 |
'</p>'; |
|
481 |
} |
|
482 |
else { |
|
483 |
$html .= nl2br($data); |
|
484 |
} |
|
485 |
$html .= '</div></div>'; |
31f6ce
|
486 |
|
b1a6a5
|
487 |
} else { |
MC |
488 |
$html = '<p>There is no data available at the moment.</p>'; |
|
489 |
} |
31f6ce
|
490 |
|
b1a6a5
|
491 |
return $html; |
MC |
492 |
} |
31f6ce
|
493 |
|
b1a6a5
|
494 |
function showMongoDB() { |
MC |
495 |
global $app; |
bd68aa
|
496 |
|
b1a6a5
|
497 |
/* fetch the Data from the DB */ |
MC |
498 |
$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
|
499 |
|
b1a6a5
|
500 |
if(isset($record['data'])) { |
MC |
501 |
$html = |
|
502 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
bd68aa
|
503 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
MC |
504 |
|
b1a6a5
|
505 |
/* |
bd68aa
|
506 |
* First, we have to detect, if there is any monitoring-data. |
MC |
507 |
* If not (because mongodb is not installed) show this. |
|
508 |
*/ |
b1a6a5
|
509 |
$data = unserialize($record['data']); |
MC |
510 |
if ($data == '') { |
|
511 |
$html .= '<p>'. |
|
512 |
'MongoDB is not installed at this server.<br />' . |
|
513 |
'See more (for debian) <a href="http://www.howtoforge.com/fail2ban_debian_etch" target="htf">here...</a>'. |
|
514 |
'</p>'; |
|
515 |
} |
|
516 |
else { |
|
517 |
$html .= nl2br($data); |
|
518 |
} |
|
519 |
$html .= '</div></div>'; |
bd68aa
|
520 |
|
b1a6a5
|
521 |
} else { |
MC |
522 |
$html = '<p>There is no data available at the moment.</p>'; |
|
523 |
} |
bd68aa
|
524 |
|
b1a6a5
|
525 |
return $html; |
MC |
526 |
} |
bd68aa
|
527 |
|
b1a6a5
|
528 |
function showIPTables() { |
MC |
529 |
global $app; |
|
530 |
$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"); |
|
531 |
if(isset($record['data'])) { |
|
532 |
$html = |
|
533 |
'<div class="systemmonitor-state state-'.$record['state'].'"> |
31f6ce
|
534 |
<div class="systemmonitor-content icons32 ico-'.$record['state'].'">'; |
b1a6a5
|
535 |
$data = unserialize($record['data']); |
MC |
536 |
if ($data == '') { |
|
537 |
$html .= '<p>Problem, there are no rules listed for the server</p>'; |
|
538 |
} |
|
539 |
else { |
|
540 |
$html .= nl2br($data['output']); |
|
541 |
} |
|
542 |
$html .= '</div></div>'; |
|
543 |
} else { |
|
544 |
$html = '<p>There is no data available at the moment.</p>'; |
|
545 |
} |
|
546 |
return $html; |
|
547 |
} |
31f6ce
|
548 |
|
M |
549 |
|
b1a6a5
|
550 |
function showMailq() { |
MC |
551 |
global $app; |
31f6ce
|
552 |
|
b1a6a5
|
553 |
/* fetch the Data from the DB */ |
MC |
554 |
$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
|
555 |
|
b1a6a5
|
556 |
if(isset($record['data'])) { |
MC |
557 |
$data = unserialize($record['data']); |
|
558 |
$html = nl2br($data['output']); |
|
559 |
} else { |
|
560 |
$html = '<p>'.$app->lng("no_data_mailq_txt").'</p>'; |
|
561 |
} |
31f6ce
|
562 |
|
b1a6a5
|
563 |
return $html; |
MC |
564 |
} |
31f6ce
|
565 |
|
b1a6a5
|
566 |
function getDataTime($type) { |
MC |
567 |
global $app; |
31f6ce
|
568 |
|
b1a6a5
|
569 |
/* fetch the Data from the DB */ |
MC |
570 |
$record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); |
31f6ce
|
571 |
|
b1a6a5
|
572 |
/* TODO: datetimeformat should be set somewhat other way */ |
MC |
573 |
$dateTimeFormat = $app->lng("monitor_settings_datetimeformat_txt"); |
31f6ce
|
574 |
|
b1a6a5
|
575 |
if(isset($record['created'])) { |
MC |
576 |
// $res = date('Y-m-d H:i', $record['created']); |
|
577 |
$res = date($dateTimeFormat, $record['created']); |
|
578 |
} else { |
|
579 |
$res = '????-??-?? ??:??'; |
|
580 |
} |
|
581 |
return $res; |
|
582 |
} |
|
583 |
|
31f6ce
|
584 |
} |
b1a6a5
|
585 |
|
31f6ce
|
586 |
?> |