From d9bcf68e395d6156645a7974b1a992aa6e6c00aa Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Mon, 14 Oct 2013 08:57:25 -0400 Subject: [PATCH] Added missing empty directories from svn import --- interface/web/monitor/show_sys_state.php | 165 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 101 insertions(+), 64 deletions(-) diff --git a/interface/web/monitor/show_sys_state.php b/interface/web/monitor/show_sys_state.php index 8391862..d251cdc 100644 --- a/interface/web/monitor/show_sys_state.php +++ b/interface/web/monitor/show_sys_state.php @@ -29,7 +29,6 @@ require_once('../../lib/config.inc.php'); require_once('../../lib/app.inc.php'); -require_once('tools.inc.php'); /* Check permissions for module */ $app->auth->check_module_permissions('monitor'); @@ -69,7 +68,7 @@ $app->tpl->setVar("state_data",$output); $app->tpl->setVar("state_type",$stateType); $app->tpl->setVar("list_head_txt",$title); -$app->tpl->setVar("list_desc_txt",$description); +$app->tpl->setVar("list_desc_txt",(isset($description) ? $description : '')); $app->tpl->setVar("monTransRefreshsq", $monTransRefreshsq); /* @@ -77,7 +76,7 @@ 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 = (isset($_GET["refresh"]))?$app->functions->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 = ''; @@ -138,7 +137,7 @@ } } } - + /* * Now we have to output all "normal" server or all OpenVZ-Hosts (or all OpenVZ-VE's without * a OpenVZ-Host managed by ISPConfig). The OpenVz-VE's are then included in them... @@ -149,7 +148,7 @@ if (!isset($data['is_ve'])) { /* * it is NOT a Ve, so do the output of this server and off all VE's included in them - */ + */ $html .= $data['html_server']; /* get all VE's of this server */ $veInfo = $data['ve_info']; @@ -193,12 +192,20 @@ $records = $app->db->queryAllRecords("SELECT DISTINCT type, data FROM monitor_data WHERE server_id = " . $serverId); $osData = null; $veInfo = null; + $ispcData = null; foreach($records as $record) { /* get the state from the db-data */ - _processDbState($record['type'], $serverId, &$serverState, &$messages); + $tmp = _processDbState($record['type'], $serverId, $serverState, $messages); + $serverState = $tmp['serverState']; + $messages = $tmp['messages']; + /* if we have the os-info, get it */ if ($record['type'] == 'os_info') { $osData = unserialize($record['data']); + } + /* if we have the ISPConfig-info, get it */ + if ($record['type'] == 'ispc_info') { + $ispcData = unserialize($record['data']); } /* if we have the ve-info, get it */ if ($record['type'] == 'openvz_veinfo') { @@ -214,46 +221,64 @@ /* * Info of a VE inside a OpenVz-Host */ - $html_ve = '<div class="systemmonitor-state state-' . $serverState . '-ve">'; - $html_ve .= '<div class="systemmonitor-device device-ve">'; - $html_ve .= '<div class="systemmonitor-content icons32 ico-' . $serverState . '">'; - $html_ve .= $serverName . '<br>'; + $html_ve = '<div class="systemmonitor-ve state-' . $serverState . '-ve os-' . $osData['name'] . '">'; + if ($osData != null) { + $html_ve .= '<div class="icoDevice"><p class="status"></p></div>'; + } + else { + $html_ve .= '<div class="icoDevice"><p class="status"></p></div>'; + } + $html_ve .= '<div class="statusDevice"><p>' . $serverName; if ($osData != null) { - $html_ve .= $osData['name'] . ' ' . $osData['version'] . '<br>'; + $html_ve .= ' (' . $osData['name'] . ' ' . $osData['version'] . ') '; } - $html_ve .= $app->lng("monitor_serverstate_state_txt") . ': ' . $serverState . '<br>'; + if ($ispcData != null) { + $html_ve .= $ispcData['name'] . ' ' . $ispcData['version'] . '</p>'; + } + else { + $html_ve .= '</p>'; + } + $html_ve .= '<p>' . $app->lng("monitor_serverstate_state_txt") . ': ' . $serverState . '</p>'; /* * Info of a "normal" Server or a OpenVz-Host */ - $html_server .= '<div class="systemmonitor-state state-' . $serverState . '">'; - $html_server .= '<div class="systemmonitor-device device-server">'; - $html_server .= '<div class="systemmonitor-content icons32 ico-' . $serverState . '">'; - $html_server .= $app->lng("monitor_serverstate_server_txt") . ': ' . $serverName; + $html_server = '<div class="systemmonitor-server state-' . $serverState . ' os-' . $osData['name'] . '">'; if ($osData != null) { - $html_server .= ' (' . $osData['name'] . ' ' . $osData['version'] . ')'; + $html_server .= '<div class="icoDevice"><p class="status"></p></div>'; + } + else { + $html_server .= '<div class="icoDevice"><p class="status"></p></div>'; + } + $html_server .= '<div class="statusDevice"><p>' . $app->lng("monitor_serverstate_server_txt") . ': ' . $serverName; + if ($osData != null) { + $html_server .= ' (' . $osData['name'] . ' ' . $osData['version'] . ') '; } + if ($ispcData != null) { + $html_server .= $ispcData['name'] . ' ' . $ispcData['version'] . '</p>'; + } + else { + $html_server .= '</p>'; + } - $html_server .= '<br />'; - $html_server .= $app->lng("monitor_serverstate_state_txt") . ': ' . $serverState . ' ('; - $html_server .= sizeof($messages[$app->lng("monitor_serverstate_listunknown_txt")]) . ' ' . $app->lng("monitor_serverstate_unknown_txt") . ', '; - $html_server .= sizeof($messages[$app->lng("monitor_serverstate_listinfo_txt")]) . ' ' . $app->lng("monitor_serverstate_info_txt") . ', '; - $html_server .= sizeof($messages[$app->lng("monitor_serverstate_listwarning_txt")]) . ' ' . $app->lng("monitor_serverstate_warning_txt") . ', '; - $html_server .= sizeof($messages[$app->lng("monitor_serverstate_listcritical_txt")]) . ' ' . $app->lng("monitor_serverstate_critical_txt") . ', '; - $html_server .= sizeof($messages[$app->lng("monitor_serverstate_listerror_txt")]) . ' ' . $app->lng("monitor_serverstate_error_txt") . ''; - $html_server .= ')<br />'; + $html_server .= '<p>' . $app->lng("monitor_serverstate_state_txt") . ': ' . $serverState . ' ('; + $html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listunknown_txt")]) ? $messages[$app->lng("monitor_serverstate_listunknown_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_unknown_txt") . ', '; + $html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listinfo_txt")]) ? $messages[$app->lng("monitor_serverstate_listinfo_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_info_txt") . ', '; + $html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listwarning_txt")]) ? $messages[$app->lng("monitor_serverstate_listwarning_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_warning_txt") . ', '; + $html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listcritical_txt")]) ? $messages[$app->lng("monitor_serverstate_listcritical_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_critical_txt") . ', '; + $html_server .= sizeof((isset($messages[$app->lng("monitor_serverstate_listerror_txt")]) ? $messages[$app->lng("monitor_serverstate_listerror_txt")] : array())) . ' ' . $app->lng("monitor_serverstate_error_txt") . ''; + $html_server .= ')</p>'; /* * Verbose - Info */ $html_verbose = $html_server; - foreach($messages as $key => $state) { { - $html_verbose .= $key . ':<br />'; - foreach ($state as $msg) { - $html_verbose .= $msg . '<br />'; - } - $html_verbose .= '<br />'; + foreach($messages as $key => $state) { + $html_verbose .= $key . ':<br />'; + foreach ($state as $msg) { + $html_verbose .= $msg . '<br />'; } + $html_verbose .= '<br />'; } /* @@ -265,9 +290,9 @@ /* * Finish all html's */ - $html_ve .= '</div></div></div>'; - $html_server .= '<div>##VE_INFO##</div></div></div></div>'; - $html_verbose .= '</div></div></div>'; + $html_ve .= '</div></div>'; + $html_server .= '<div>##VE_INFO##</div></div></div>'; + $html_verbose .= '</div></div>'; /* * create and return the result @@ -282,7 +307,7 @@ } /* - * gets the state from the db and process it +* gets the state from the db and process it */ function _processDbState($type, $serverId, $serverState, $messages) { global $app; @@ -291,10 +316,17 @@ * Always the NEWEST record of each monitoring is responsible for the * state */ -// get the State from the DB + // get the State from the DB $record = $app->db->queryOneRecord("SELECT state FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $serverId . " order by created desc"); -// change the new state to the highest state - $serverState = _setState($serverState, $record['state']); + + // change the new state to the highest state + /* + * Monitoring the user_beancounter of a VE is not as easy as i thought, so for now ignore + * this state (if we have a better solution) + */ + if ($type != 'openvz_beancounter') { + $serverState = _setState($serverState, $record['state']); + } /* * The message depands on the type and the state @@ -432,32 +464,35 @@ } } - if ($type == 'openvz_beancounter') { - switch ($record['state']) { - case 'ok': - $messages[$app->lng("monitor_serverstate_listok_txt")][] = $app->lng("monitor_serverstate_beancounterok_txt") . ' ' . - "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; - break; - case 'info': - $messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterinfo_txt") . ' ' . - "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; - break; - case 'warning': - $messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterwarning_txt") . ' ' . - "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; - break; - case 'critical': - $messages[$app->lng("monitor_serverstate_listcritical_txt")][] = $app->lng("monitor_serverstate_beancountercritical_txt") . ' ' . - "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; - break; - case 'error': - $messages[$app->lng("monitor_serverstate_listerror_txt")][] = $app->lng("monitor_serverstate_beancountererror_txt") . ' ' . - "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; - break; - default: - break; - } - } + /* + * ignore, until we find a better solution + */ +// if ($type == 'openvz_beancounter') { +// switch ($record['state']) { +// case 'ok': +// $messages[$app->lng("monitor_serverstate_listok_txt")][] = $app->lng("monitor_serverstate_beancounterok_txt") . ' ' . +// "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; +// break; +// case 'info': +// $messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterinfo_txt") . ' ' . +// "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; +// break; +// case 'warning': +// $messages[$app->lng("monitor_serverstate_listinfo_txt")][] = $app->lng("monitor_serverstate_beancounterwarning_txt") . ' ' . +// "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; +// break; +// case 'critical': +// $messages[$app->lng("monitor_serverstate_listcritical_txt")][] = $app->lng("monitor_serverstate_beancountercritical_txt") . ' ' . +// "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; +// break; +// case 'error': +// $messages[$app->lng("monitor_serverstate_listerror_txt")][] = $app->lng("monitor_serverstate_beancountererror_txt") . ' ' . +// "<a href='#' onclick='loadContent(\"monitor/show_data.php?type=openvz_beancounter\");'>[" . $app->lng("monitor_serverstate_more_txt") . "]</a>"; +// break; +// default: +// break; +// } +// } if ($type == 'mailq') { @@ -549,6 +584,8 @@ if ($type == 'rkhunter') { /* this type has no state */ } + + return array('serverState' => $serverState,'messages' => $messages); } /* -- Gitblit v1.9.1