auth->check_module_permissions('monitor'); /* 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]; } /* * Loading the template */ $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); $app->tpl->setInclude('content_tpl','templates/show_sys_state.htm'); /* Get some translations */ $monTransRefreshsq = $app->lng("monitor_settings_refreshsq_txt"); /* * setting the content */ if ($_GET['state'] == 'server') { $output = _getServerState($_SESSION['monitor']['server_id'], $_SESSION['monitor']['server_name'], true); $title = $app->lng("monitor_general_serverstate_txt"); $stateType = 'server'; } else { $output = _getSysState(); $title = $app->lng("monitor_general_systemstate_txt"); $stateType = 'system'; } $app->tpl->setVar("state_data",$output); $app->tpl->setVar("state_type",$stateType); $app->tpl->setVar("title",$title); $app->tpl->setVar("description",$description); $app->tpl->setVar("monTransRefreshsq", $monTransRefreshsq); /* Creating the array with the refresh intervals Attention: the core-module ist triggered every 5 minutes, so reload every 2 minutes is impossible! */ $refresh = (isset($_GET["refresh"]))?intval($_GET["refresh"]):0; $refresh_values = array('0' => '- '.$app->lng("No Refresh").' -','5' => '5 '.$app->lng("minutes"),'10' => '10 '.$app->lng("minutes"),'15' => '15 '.$app->lng("minutes"),'30' => '30 '.$app->lng("minutes"),'60' => '60 '.$app->lng("minutes")); $tmp = ''; foreach($refresh_values as $key => $val) { if($key == $refresh) { $tmp .= ""; } else { $tmp .= ""; } } $app->tpl->setVar("refresh",$tmp); /* * doing the output */ $app->tpl_defaults(); $app->tpl->pparse(); function _getSysState(){ global $app; /* * Get all Servers and calculate the state of them */ $html = ''; $servers = $app->db->queryAllRecords("SELECT server_id, server_name FROM server order by server_name"); foreach ($servers as $server) { $html .= _getServerState($server['server_id'], $server['server_name'], false); } return $html; } /* * Calculates the State of ONE Server */ function _getServerState($serverId, $serverName, $showAll) { global $app; /* The State of the server */ $serverState = 'ok'; /** The messages */ $messages = array(); /** The Result of the function */ $res = ''; /* * get all monitoring-data from the server als process then * (count them and set the server-state) */ $records = $app->db->queryAllRecords("SELECT DISTINCT type FROM monitor_data WHERE server_id = " . $serverId); foreach($records as $record){ _processDbState($record['type'], $serverId, &$serverState, &$messages); } $res .= '