auth->check_module_permissions('monitor'); /* Get the dataType to show */ $dataType = $_GET["type"]; /* Change the Server if needed */ if (isset($_GET['server'])){ $server = explode('|', $_GET['server'], 2); $_SESSION['monitor']['server_id'] = $server[0]; $_SESSION['monitor']['server_name'] = $server[1]; } $output = ''; switch($dataType) { case 'server_load': $template = 'templates/show_data.htm'; $output .= showServerLoad(); $title = $app->lng("Server Load").' (Server: ' . $_SESSION['monitor']['server_name'] . ')'; $description = ''; break; case 'disk_usage': $template = 'templates/show_data.htm'; $output .= showDiskUsage(); $title = $app->lng("Disk usage").' (Server: ' . $_SESSION['monitor']['server_name'] . ')'; $description = ''; break; case 'mem_usage': $template = 'templates/show_data.htm'; $output .= showMemUsage(); $title = $app->lng("Memory usage").' (Server: ' . $_SESSION['monitor']['server_name'] . ')'; $description = ''; break; case 'cpu_info': $template = 'templates/show_data.htm'; $output .= showCpuInfo(); $title = $app->lng("CPU info").' (Server: ' . $_SESSION['monitor']['server_name'] . ')'; $description = ''; break; case 'services': $template = 'templates/show_data.htm'; $output .= showServices(); $title = $app->lng("Status of services").' (Server: ' . $_SESSION['monitor']['server_name'] . ')'; $description = ''; break; case 'overview': $template = 'templates/show_data.htm'; $output .= showServerLoad(); $output .= ' '. showDiskUsage(); $output .= ' '.showServices(); $title = $app->lng("System Monitor").' (Server: ' . $_SESSION['monitor']['server_name'] . ')'; $description = ''; break; default: $template = ''; break; } // Loading the template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); $app->tpl->setInclude('content_tpl',$template); $app->tpl->setVar("output",$output); $app->tpl->setVar("title",$title); $app->tpl->setVar("description",$description); $app->tpl_defaults(); $app->tpl->pparse(); function showServerLoad(){ global $app; /* fetch the Data from the DB */ $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"); if(isset($record['data'])) { $data = unserialize($record['data']); /* Format the data */ $html .= '' . '
' . $app->lng("Server online since").': ' . $data['up_days'] . ' days, ' . $data['up_hours'] . ':' . $data['up_minutes'] . ' hours
' . $app->lng("Users online").': ' . $data['user_online'] . '
' . $app->lng("System load 1 minute") . ': ' . $data['load_1'] . '
' . $app->lng("System load 5 minutes") . ': ' . $data['load_5'] . '
'.$app->lng("System load 15 minutes").': ' . $data['load_15'] . '
'; } else { $html = '

'.$app->lng("no_data_serverload_txt").'

'; } return $html; } function showDiskUsage () { global $app; /* fetch the Data from the DB */ $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"); if(isset($record['data'])) { $data = unserialize($record['data']); /* Format the data */ $html .= ''; foreach($data as $line) { $html .= ''; foreach ($line as $item) { $html .= ''; } $html .= ''; } $html .= '
' . $item . '
'; } else { $html = '

'.$app->lng("no_data_diskusage_txt").'

'; } return $html; } function showMemUsage () { global $app; /* fetch the Data from the DB */ $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"); if(isset($record['data'])) { $data = unserialize($record['data']); /* Format the data */ $html .= ''; foreach($data as $key => $value){ if ($key != '') { $html .= ''; } } $html .= '
' . $key . ': ' . $value . '
'; } else { $html = '

'.$app->lng("no_data_memusage_txt").'

'; } return $html; } function showCpuInfo () { global $app; /* fetch the Data from the DB */ $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"); if(isset($record['data'])) { $data = unserialize($record['data']); /* Format the data */ $html .= ''; foreach($data as $key => $value){ if ($key != '') { $html .= ''; } } $html .= '
' . $key . ': ' . $value . '
'; } else { $html = '

'.$app->lng("no_data_cpuinfo_txt").'

'; } return $html; } function showServices () { global $app; /* fetch the Data from the DB */ $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); if(isset($record['data'])) { $data = unserialize($record['data']); /* Format the data */ $html .= ''; if($data['webserver'] == true) { $status = 'Online'; } else { $status = 'Offline'; } $html .= ''; if($data['ftpserver'] == true) { $status = 'Online'; } else { $status = 'Offline'; } $html .= ''; if($data['smtpserver'] == true) { $status = 'Online'; } else { $status = 'Offline'; } $html .= ''; if($data['pop3server'] == true) { $status = 'Online'; } else { $status = 'Offline'; } $html .= ''; if($data['bindserver'] == true) { $status = 'Online'; } else { $status = 'Offline'; } $html .= ''; if($data['mysqlserver'] == true) { $status = 'Online'; } else { $status = 'Offline'; } $html .= ''; $html .= '
Web-Server: '.$status.'
FTP-Server: '.$status.'
SMTP-Server: '.$status.'
POP3-Server: '.$status.'
DNS-Server: '.$status.'
mySQL-Server: '.$status.'
'; } else { $html = '

'.$app->lng("no_data_services_txt").'

'; } return $html; } ?>