Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
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 */
cc7a82 36         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'server_load' AND server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
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 */
cc7a82 83         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'disk_usage' AND server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
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'].'">
89e432 94                 <table class="table">
MC 95                 <thead class="dark">
31f6ce 96                 <tr>
89e432 97                 <th>'.$app->lng("monitor_diskusage_filesystem_txt").'</th>
MC 98             <th class="small-col">'.$app->lng("monitor_diskusage_type_txt").'</th>
99                 <th class="tiny-col">'.$app->lng("monitor_diskusage_size_txt").'</th>
100                 <th class="tiny-col">'.$app->lng("monitor_diskusage_used_txt").'</th>
101                 <th class="tiny-col">'.$app->lng("monitor_diskusage_available_txt").'</th>
102                 <th class="tiny-col">'.$app->lng("monitor_diskusage_usage_txt").'</th>
103                 <th>'.$app->lng("monitor_diskusage_mounted_txt").'</th>
104                 </tr></thead>
105                 <tbody>';
b1a6a5 106             foreach($data as $line) {
MC 107                 $html .= '<tr>';
108                 foreach ($line as $item) {
109                     $html .= '<td>' . $item . '</td>';
110                 }
111                 $html .= '</tr>';
112             }
89e432 113             $html .= '</tbody></table>';
b1a6a5 114             $html .= '</div></div>';
MC 115         } else {
116             $html = '<p>'.$app->lng("no_data_diskusage_txt").'</p>';
117         }
31f6ce 118
M 119
b1a6a5 120         return $html;
MC 121     }
31f6ce 122
b1a6a5 123     function showDatabaseSize () {
MC 124         global $app;
125         /* fetch the Data from the DB */
cc7a82 126         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' AND server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
b1a6a5 127         if(isset($record['data'])) {
MC 128             $data = unserialize($record['data']);
0543b2 129             //* format the data
b1a6a5 130             $html =
MC 131                 '<div class="systemmonitor-state state-'.$record['state'].'">
71accc 132                     <div class="systemmonitor-content icons32 ico-'.$record['state'].'">
89e432 133                     <table class="table"><thead class="dark"><tr>
MC 134                     <th>'.$app->lng("monitor_database_name_txt").'</th>
135                     <th class="tiny-col">'.$app->lng("monitor_database_size_txt").'</th>
136                     <th>'.$app->lng("monitor_database_client_txt").'</th>
137                     <th>'.$app->lng("monitor_database_domain_txt").'</th>
138                     </tr></thead>
139                     <tbody>';
b1a6a5 140             foreach($data as $line) {
MC 141                 $html .= '<tr>';
142                 if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']);
0543b2 143
F 144                 //* get the client
cc7a82 145                 $tmp = $app->db->queryOneRecord("SELECT client.username FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name=?", $line['database_name']);
MC 146                 $line['client'] = $tmp['username'];
0543b2 147
F 148                 //* get the domain
cc7a82 149                 $tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id=(SELECT parent_domain_id FROM web_database WHERE database_name=?", $line['database_name']);
MC 150                 $line['domain'] = $tmp['domain'];
0543b2 151
F 152                 //* remove the sys_groupid from output
153                 unset($line['sys_groupid']);
154
b1a6a5 155                 foreach ($line as $item) {
MC 156                     $html .= '<td>' . $item . '</td>';
157                 }
89e432 158                 $html .= '</tr>';
b1a6a5 159             }
0543b2 160             $html .= '</tbody></table></div></div>';
b1a6a5 161         } else {
MC 162             $html = '<p>'.$app->lng("no_data_database_size_txt").'</p>';
163         }
164         return $html;
165     }
71accc 166
b1a6a5 167     function showMemUsage () {
MC 168         global $app;
31f6ce 169
b1a6a5 170         /* fetch the Data from the DB */
cc7a82 171         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mem_usage' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 172
b1a6a5 173         if(isset($record['data'])) {
MC 174             $data = unserialize($record['data']);
31f6ce 175
b1a6a5 176             /*
31f6ce 177             Format the data
M 178             */
b1a6a5 179             $html =
MC 180                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 181                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">
89e432 182                 <table class="table">
MC 183                 <tbody>';
31f6ce 184
b1a6a5 185             foreach($data as $key => $value) {
MC 186                 if ($key != '') {
187                     $html .= '<tr>
31f6ce 188                         <td>' . $key . ':</td>
M 189                         <td>' . $value . '</td>
190                         </tr>';
b1a6a5 191                 }
MC 192             }
89e432 193             $html .= '</tbody></table>';
b1a6a5 194             $html .= '</div></div>';
31f6ce 195
b1a6a5 196         } else {
MC 197             $html = '<p>'.$app->lng("no_data_memusage_txt").'</p>';
198         }
31f6ce 199
b1a6a5 200         return $html;
MC 201     }
31f6ce 202
b1a6a5 203     function showCpuInfo () {
MC 204         global $app;
31f6ce 205
b1a6a5 206         /* fetch the Data from the DB */
cc7a82 207         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'cpu_info' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 208
b1a6a5 209         if(isset($record['data'])) {
MC 210             $data = unserialize($record['data']);
31f6ce 211
b1a6a5 212             /*
31f6ce 213             Format the data
M 214             */
b1a6a5 215             $html =
MC 216                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 217                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">
89e432 218                 <table class="table">
MC 219                 <tbody>';
b1a6a5 220             foreach($data as $key => $value) {
MC 221                 if ($key != '') {
222                     $html .= '<tr>
31f6ce 223                         <td>' . $key . ':</td>
M 224                         <td>' . $value . '</td>
225                         </tr>';
b1a6a5 226                 }
MC 227             }
89e432 228             $html .= '</tbody></table>';
b1a6a5 229             $html .= '</div></div>';
MC 230         } else {
231             $html = '<p>'.$app->lng("no_data_cpuinfo_txt").'</p>';
232         }
31f6ce 233
b1a6a5 234         return $html;
MC 235     }
31f6ce 236
b1a6a5 237     function showServices () {
MC 238         global $app;
31f6ce 239
b1a6a5 240         /* fetch the Data from the DB */
cc7a82 241         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 242
b1a6a5 243         if(isset($record['data'])) {
MC 244             $data = unserialize($record['data']);
31f6ce 245
b1a6a5 246             /*
31f6ce 247             Format the data
M 248             */
b1a6a5 249             $html =
MC 250                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 251                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">
89e432 252                 <table class="table">
MC 253                 <tbody>';
31f6ce 254
b1a6a5 255             if($data['webserver'] != -1) {
MC 256                 if($data['webserver'] == 1) {
257                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
258                 } else {
259                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
260                 }
261                 $html .= '<tr>
31f6ce 262                 <td>'.$app->lng("monitor_services_web_txt").'</td>
M 263                 <td>'.$status.'</td>
264                 </tr>';
b1a6a5 265             }
31f6ce 266
M 267
b1a6a5 268             if($data['ftpserver'] != -1) {
MC 269                 if($data['ftpserver'] == 1) {
270                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
271                 } else {
272                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
273                 }
274                 $html .= '<tr>
31f6ce 275                 <td>'.$app->lng("monitor_services_ftp_txt").'</td>
M 276                 <td>'.$status.'</td>
277                 </tr>';
b1a6a5 278             }
31f6ce 279
b1a6a5 280             if($data['smtpserver'] != -1) {
MC 281                 if($data['smtpserver'] == 1) {
282                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
283                 } else {
284                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
285                 }
286                 $html .= '<tr>
31f6ce 287                 <td>'.$app->lng("monitor_services_smtp_txt").'</td>
M 288                 <td>'.$status.'</td>
289                 </tr>';
b1a6a5 290             }
31f6ce 291
b1a6a5 292             if($data['pop3server'] != -1) {
MC 293                 if($data['pop3server'] == 1) {
294                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
295                 } else {
296                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
297                 }
298                 $html .= '<tr>
31f6ce 299                 <td>'.$app->lng("monitor_services_pop_txt").'</td>
M 300                 <td>'.$status.'</td>
301                 </tr>';
b1a6a5 302             }
31f6ce 303
b1a6a5 304             if($data['imapserver'] != -1) {
MC 305                 if($data['imapserver'] == 1) {
306                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
307                 } else {
308                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
309                 }
310                 $html .= '<tr>
31f6ce 311                 <td>'.$app->lng("monitor_services_imap_txt").'</td>
M 312                 <td>'.$status.'</td>
313                 </tr>';
b1a6a5 314             }
31f6ce 315
b1a6a5 316             if($data['bindserver'] != -1) {
MC 317                 if($data['bindserver'] == 1) {
318                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
319                 } else {
320                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
321                 }
322                 $html .= '<tr>
31f6ce 323                 <td>'.$app->lng("monitor_services_mydns_txt").'</td>
M 324                 <td>'.$status.'</td>
325                 </tr>';
b1a6a5 326             }
31f6ce 327
b1a6a5 328             if($data['mysqlserver'] != -1) {
MC 329                 if($data['mysqlserver'] == 1) {
330                     $status = '<span class="online">'.$app->lng("monitor_services_online_txt").'</span>';
331                 } else {
332                     $status = '<span class="offline">'.$app->lng("monitor_services_offline_txt").'</span>';
333                 }
334                 $html .= '<tr>
31f6ce 335                 <td>'.$app->lng("monitor_services_mysql_txt").'</td>
M 336                 <td>'.$status.'</td>
337                 </tr>';
b1a6a5 338             }
31f6ce 339
M 340
89e432 341             $html .= '</tbody></table></div></div>';
b1a6a5 342         } else {
MC 343             $html = '<p>'.$app->lng("no_data_services_txt").'</p>';
344         }
31f6ce 345
M 346
b1a6a5 347         return $html;
MC 348     }
31f6ce 349
b1a6a5 350     function showSystemUpdate() {
MC 351         global $app;
31f6ce 352
b1a6a5 353         /* fetch the Data from the DB */
cc7a82 354         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'system_update' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 355
b1a6a5 356         if(isset($record['data'])) {
MC 357             $html =
358                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 359                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
b1a6a5 360             /*
31f6ce 361              * First, we have to detect, if there is any monitoring-data.
M 362              * If not (because the destribution is not supported) show this.
363             */
b1a6a5 364             if ($record['state'] == 'no_state') {
MC 365                 $html .= '<p>'.$app->lng("monitor_updates_nosupport_txt").'</p>';
366             }
367             else {
368                 $data = unserialize($record['data']);
369                 $html .= nl2br(html_entity_decode($data['output']));
370             }
371             $html .= '</div></div>';
372         } else {
373             $html = '<p>'.$app->lng("no_data_updates_txt").'</p>';
374         }
31f6ce 375
b1a6a5 376         return $html;
MC 377     }
31f6ce 378
M 379
b1a6a5 380     function showOpenVzBeancounter() {
MC 381         global $app;
31f6ce 382
b1a6a5 383         /* fetch the Data from the DB */
cc7a82 384         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'openvz_beancounter' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 385
b1a6a5 386         if(isset($record['data'])) {
MC 387             $html =
388                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 389                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
b1a6a5 390             /*
31f6ce 391              * First, we have to detect, if there is any monitoring-data.
M 392              * If not (because the server is not a VE) show this.
393             */
b1a6a5 394             $data = unserialize($record['data']);
MC 395             if ((!isset($data)) || ($data == '')) {
396                 $html .= '<p>'.$app->lng("monitor_beancounter_nosupport_txt").'</p>';
397             }
398             else {
399                 $html .= '<pre>' . nl2br($data) . '</pre>';
400             }
401             $html .= '</div></div>';
402         } else {
403             $html = '<p>'.$app->lng("no_data_updates_txt").'</p>';
404         }
31f6ce 405
b1a6a5 406         return $html;
MC 407     }
31f6ce 408
b1a6a5 409     function showRaidState() {
MC 410         global $app;
31f6ce 411
b1a6a5 412         /* fetch the Data from the DB */
cc7a82 413         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'raid_state' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 414
b1a6a5 415         if(isset($record['data'])) {
MC 416             $html =
417                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 418                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
M 419
b1a6a5 420             /*
31f6ce 421              * First, we have to detect, if there is any monitoring-data.
M 422              * If not (because the RAID-Controler is not supported yet) show this.
423             */
b1a6a5 424             if ($record['state'] == 'no_state') {
MC 425                 $html .= '<p>'.$app->lng("monitor_nosupportedraid1_txt").'</p>';
426             }
427             else {
428                 $data = unserialize($record['data']);
5fc730 429                 // improve view @Author <info@typoworx.de>
TB 430                 //-- $html .= nl2br($data['output']);
431                 $html .= '<xmp>' . $data['output'] . '</xmp>';
b1a6a5 432             }
MC 433             $html .= '</div></div>';
31f6ce 434
b1a6a5 435         } else {
MC 436             $html = '<p>'.$app->lng("no_data_raid_txt").'</p>';
437         }
31f6ce 438
b1a6a5 439         return $html;
MC 440     }
31f6ce 441
b1a6a5 442     function showRKHunter() {
MC 443         global $app;
31f6ce 444
b1a6a5 445         /* fetch the Data from the DB */
cc7a82 446         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'rkhunter' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 447
b1a6a5 448         if(isset($record['data'])) {
MC 449             $html =
450                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 451                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
M 452
b1a6a5 453             /*
31f6ce 454              * First, we have to detect, if there is any monitoring-data.
M 455              * If not (because rkhunter is not installed) show this.
456             */
b1a6a5 457             $data = unserialize($record['data']);
MC 458             if ($data['output'] == '') {
459                 $html .= '<p>'.$app->lng("monitor_norkhunter_txt").'</p>';
460             }
461             else {
462                 $html .= nl2br($data['output']);
463             }
464             $html .= '</div></div>';
31f6ce 465
b1a6a5 466         } else {
MC 467             $html = '<p>'.$app->lng("no_data_rkhunter_txt").'</p>';
468         }
31f6ce 469
b1a6a5 470         return $html;
MC 471     }
31f6ce 472
b1a6a5 473     function showFail2ban() {
MC 474         global $app;
31f6ce 475
b1a6a5 476         /* fetch the Data from the DB */
cc7a82 477         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_fail2ban' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 478
b1a6a5 479         if(isset($record['data'])) {
MC 480             $html =
481                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 482                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
M 483
b1a6a5 484             /*
31f6ce 485              * First, we have to detect, if there is any monitoring-data.
M 486              * If not (because fail2ban is not installed) show this.
487             */
b1a6a5 488             $data = unserialize($record['data']);
MC 489             if ($data == '') {
490                 $html .= '<p>'.
d5f2d5 491                     'fail2ban is not installed on this server.<br />' .
b1a6a5 492                     'See more (for debian) <a href="http://www.howtoforge.com/fail2ban_debian_etch" target="htf">here...</a>'.
MC 493                     '</p>';
494             }
495             else {
496                 $html .= nl2br($data);
497             }
498             $html .= '</div></div>';
31f6ce 499
b1a6a5 500         } else {
MC 501             $html = '<p>There is no data available at the moment.</p>';
502         }
31f6ce 503
b1a6a5 504         return $html;
MC 505     }
31f6ce 506
b1a6a5 507     function showMongoDB() {
MC 508         global $app;
bd68aa 509
b1a6a5 510         /* fetch the Data from the DB */
cc7a82 511         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_mongodb' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
bd68aa 512
b1a6a5 513         if(isset($record['data'])) {
MC 514             $html =
515                 '<div class="systemmonitor-state state-'.$record['state'].'">
bd68aa 516                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
MC 517
b1a6a5 518             /*
bd68aa 519              * First, we have to detect, if there is any monitoring-data.
MC 520              * If not (because mongodb is not installed) show this.
521             */
b1a6a5 522             $data = unserialize($record['data']);
MC 523             if ($data == '') {
524                 $html .= '<p>'.
d5f2d5 525                     'MongoDB is not installed on this server.<br />' .
b1a6a5 526                     '</p>';
MC 527             }
528             else {
529                 $html .= nl2br($data);
530             }
531             $html .= '</div></div>';
bd68aa 532
b1a6a5 533         } else {
MC 534             $html = '<p>There is no data available at the moment.</p>';
535         }
bd68aa 536
b1a6a5 537         return $html;
MC 538     }
bd68aa 539
b1a6a5 540     function showIPTables() {
MC 541         global $app;
cc7a82 542         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'iptables_rules' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
b1a6a5 543         if(isset($record['data'])) {
MC 544             $html =
545                 '<div class="systemmonitor-state state-'.$record['state'].'">
31f6ce 546                 <div class="systemmonitor-content icons32 ico-'.$record['state'].'">';
b1a6a5 547             $data = unserialize($record['data']);
MC 548             if ($data == '') {
549                 $html .= '<p>Problem, there are no rules listed for the server</p>';
550             }
551             else {
552                 $html .= nl2br($data['output']);
553             }
554             $html .= '</div></div>';
555         } else {
556             $html = '<p>There is no data available at the moment.</p>';
557         }
558         return $html;
559     }
31f6ce 560
M 561
b1a6a5 562     function showMailq() {
MC 563         global $app;
31f6ce 564
b1a6a5 565         /* fetch the Data from the DB */
cc7a82 566         $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mailq' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']);
31f6ce 567
b1a6a5 568         if(isset($record['data'])) {
MC 569             $data = unserialize($record['data']);
570             $html = nl2br($data['output']);
571         } else {
572             $html = '<p>'.$app->lng("no_data_mailq_txt").'</p>';
573         }
31f6ce 574
b1a6a5 575         return $html;
MC 576     }
31f6ce 577
b1a6a5 578     function getDataTime($type) {
MC 579         global $app;
31f6ce 580
b1a6a5 581         /* fetch the Data from the DB */
cc7a82 582         $record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = ? and server_id = ? ORDER BY created DESC", $type, $_SESSION['monitor']['server_id']);
31f6ce 583
b1a6a5 584         /* TODO: datetimeformat should be set somewhat other way */
MC 585         $dateTimeFormat = $app->lng("monitor_settings_datetimeformat_txt");
31f6ce 586
b1a6a5 587         if(isset($record['created'])) {
MC 588             //        $res = date('Y-m-d H:i', $record['created']);
589             $res = date($dateTimeFormat, $record['created']);
590         } else {
591             $res = '????-??-?? ??:??';
592         }
593         return $res;
594     }
595
31f6ce 596 }
b1a6a5 597
31f6ce 598 ?>