Beispiel #1
0
function status_computer_mysql_memory_check()
{
    include_once 'ressources/class.mysql-server.inc';
    $t = time();
    $instance_id = 0;
    $page = CurrentPageName();
    $tpl = new templates();
    $mysql = new mysqlserver();
    $users = new usersMenus();
    if (!$users->AsSystemAdministrator) {
        return;
    }
    if ($users->MEM_TOTAL_INSTALLEE < 624288) {
        return;
    }
    $serverMem = round(($users->MEM_TOTAL_INSTALLEE - 300) / 1024);
    $color = "black";
    $VARIABLES = $mysql->SHOW_VARIABLES();
    if (!is_numeric($mysql->main_array["max_connections"])) {
        $mysql->main_array["max_connections"] = $VARIABLES["max_connections"];
    }
    $read_buffer_size = $mysql->main_array["read_buffer_size"];
    if (!is_numeric($read_buffer_size)) {
        $read_buffer_size = $VARIABLES["read_buffer_size"] / 1024 / 1000;
    }
    $read_rnd_buffer_size = $mysql->main_array["read_rnd_buffer_size"];
    if (!is_numeric($read_rnd_buffer_size)) {
        $read_rnd_buffer_size = $VARIABLES["read_rnd_buffer_size"] / 1024 / 1000;
    }
    $sort_buffer_size = $mysql->main_array["sort_buffer_size"];
    if (!is_numeric($sort_buffer_size)) {
        $sort_buffer_size = $VARIABLES["sort_buffer_size"] / 1024 / 1000;
    }
    $thread_stack = $mysql->main_array["thread_stack"];
    if (!is_numeric($thread_stack)) {
        $thread_stack = $VARIABLES["thread_stack"] / 1024 / 1000;
    }
    $join_buffer_size = $mysql->main_array["join_buffer_size"];
    if (!is_numeric($join_buffer_size)) {
        $join_buffer_size = $VARIABLES["join_buffer_size"] / 1024 / 1000;
    }
    $per_thread_buffers = $sort_buffer_size + $read_rnd_buffer_size + $sort_buffer_size + $thread_stack + $join_buffer_size;
    $Warn = false;
    $total_per_thread_buffers = $per_thread_buffers * $mysql->main_array["max_connections"];
    if ($total_per_thread_buffers > $serverMem) {
        $Warn = true;
    }
    $key_buffer_size = $mysql->main_array["key_buffer_size"];
    if (!is_numeric($key_buffer_size)) {
        $key_buffer_size = $VARIABLES["key_buffer_size"] / 1024 / 1000;
    }
    $max_tmp_table_size = $mysql->main_array["max_tmp_table_size"];
    if (!is_numeric($max_tmp_table_size)) {
        $max_tmp_table_size = $VARIABLES["max_tmp_table_size"] / 1024 / 1000;
    }
    $innodb_buffer_pool_size = $mysql->main_array["innodb_buffer_pool_size"];
    if (!is_numeric($innodb_buffer_pool_size)) {
        $innodb_buffer_pool_size = $VARIABLES["innodb_buffer_pool_size"] / 1024 / 1000;
    }
    $innodb_additional_mem_pool_size = $mysql->main_array["innodb_additional_mem_pool_size"];
    if (!is_numeric($innodb_additional_mem_pool_size)) {
        $innodb_additional_mem_pool_size = $VARIABLES["innodb_additional_mem_pool_size"] / 1024 / 1000;
    }
    $innodb_log_buffer_size = $mysql->main_array["innodb_log_buffer_size"];
    if (!is_numeric($innodb_log_buffer_size)) {
        $innodb_log_buffer_size = $VARIABLES["innodb_log_buffer_size"] / 1024 / 1000;
    }
    $query_cache_size = $mysql->main_array["query_cache_size"];
    if (!is_numeric($query_cache_size)) {
        $query_cache_size = $VARIABLES["query_cache_size"] / 1024 / 1000;
    }
    $server_buffers = $key_buffer_size + $max_tmp_table_size + $innodb_buffer_pool_size + $innodb_additional_mem_pool_size + $innodb_log_buffer_size + $query_cache_size;
    if ($server_buffers > $serverMem) {
        $Warn = true;
    }
    $max_used_memory = $server_buffers + $total_per_thread_buffers;
    if ($max_used_memory > $serverMem) {
        $Warn = true;
    }
    $UNIT = "M";
    if ($max_used_memory > 1000) {
        $max_used_memory = round($max_used_memory / 1000, 2);
        $UNIT = "G";
    }
    $text = $tpl->_ENGINE_parse_body("{mysql_warn_must_tune}");
    $text = str_replace("%m", $serverMem, $text);
    if ($Warn) {
        echo "\n\t\t<table style='width:99%' class=form>\n\t\t<tr>\n\t\t\t<td valign='top'><img src='img/database-error-64.png'>\n\t\t\t<td valign='top'><a href=\"javascript:blur();\" OnClick=\"Loadjs('mysql.perfs.php',true);\" \n\t\t\tstyle='font-size:12px;color:#C72727;text-decoration:underline'>{$text}</a>\n\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t\n\t\t";
        return;
    }
    $sock = new sockets();
    $sock->SET_INFO("MySqlMemoryCheck", 1);
}
Beispiel #2
0
function page()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $users = new usersMenus();
    $EnableZarafaTuning = $sock->GET_INFO("EnableZarafaTuning");
    if (!is_numeric($EnableZarafaTuning)) {
        $EnableZarafaTuning = 0;
    }
    $ZarafTuningParameters = unserialize(base64_decode($sock->GET_INFO("ZarafaTuningParameters")));
    $zarafa_innodb_buffer_pool_size = $ZarafTuningParameters["zarafa_innodb_buffer_pool_size"];
    $zarafa_query_cache_size = $ZarafTuningParameters["zarafa_query_cache_size"];
    $zarafa_innodb_log_file_size = $ZarafTuningParameters["zarafa_innodb_log_file_size"];
    $zarafa_innodb_log_buffer_size = $ZarafTuningParameters["zarafa_innodb_log_buffer_size"];
    $zarafa_max_allowed_packet = $ZarafTuningParameters["zarafa_max_allowed_packet"];
    $zarafa_max_connections = $ZarafTuningParameters["zarafa_max_connections"];
    $memory = $users->MEM_TOTAL_INSTALLEE / 1000;
    if (!is_numeric($zarafa_max_connections)) {
        $zarafa_max_connections = 150;
    }
    if (!is_numeric($zarafa_innodb_buffer_pool_size)) {
        $zarafa_innodb_buffer_pool_size = round($memory / 2.8);
    }
    if (!is_numeric($zarafa_innodb_log_file_size)) {
        $zarafa_innodb_log_file_size = round($zarafa_innodb_buffer_pool_size * 0.25);
    }
    if (!is_numeric($zarafa_innodb_log_buffer_size)) {
        $zarafa_innodb_log_buffer_size = 32;
    }
    if (!is_numeric($zarafa_max_allowed_packet)) {
        $zarafa_max_allowed_packet = 16;
    }
    if (!is_numeric($zarafa_query_cache_size)) {
        $zarafa_query_cache_size = 8;
    }
    if ($zarafa_innodb_log_file_size > 2000) {
        $zarafa_innodb_log_file_size = 2000;
    }
    $mysql = new mysqlserver();
    $VARIABLES = $mysql->SHOW_VARIABLES();
    $read_buffer_size = $ZarafTuningParameters["read_buffer_size"];
    if (!is_numeric($read_buffer_size)) {
        $read_buffer_size = $VARIABLES["read_buffer_size"] / 1024 / 1000;
    }
    $read_rnd_buffer_size = $ZarafTuningParameters["read_rnd_buffer_size"];
    if (!is_numeric($read_rnd_buffer_size)) {
        $read_rnd_buffer_size = $VARIABLES["read_rnd_buffer_size"] / 1024 / 1000;
    }
    $sort_buffer_size = $ZarafTuningParameters["sort_buffer_size"];
    if (!is_numeric($sort_buffer_size)) {
        $sort_buffer_size = $VARIABLES["sort_buffer_size"] / 1024 / 1000;
    }
    $thread_stack = $ZarafTuningParameters["thread_stack"];
    if (!is_numeric($thread_stack)) {
        $thread_stack = $VARIABLES["thread_stack"] / 1024 / 1000;
    }
    $join_buffer_size = $ZarafTuningParameters["join_buffer_size"];
    if (!is_numeric($join_buffer_size)) {
        $join_buffer_size = $VARIABLES["join_buffer_size"] / 1024 / 1000;
    }
    $key_buffer_size = $ZarafTuningParameters["key_buffer_size"];
    if (!is_numeric($key_buffer_size)) {
        $key_buffer_size = $VARIABLES["key_buffer_size"] / 1024 / 1000;
    }
    $max_tmp_table_size = $ZarafTuningParameters["max_tmp_table_size"];
    if (!is_numeric($max_tmp_table_size)) {
        $max_tmp_table_size = $VARIABLES["max_tmp_table_size"] / 1024 / 1000;
    }
    $query_cache_size = $ZarafTuningParameters["query_cache_size"];
    if (!is_numeric($query_cache_size)) {
        $query_cache_size = $VARIABLES["query_cache_size"] / 1024 / 1000;
    }
    $html = "\n\t<div class=explain id='zarafa_mysql_tuning_text' style='font-size:18px'>{zarafa_mysql_tuning_text}</div>\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t<tR>\n\t\t<td class=legend style='font-size:22px'>{enable_tuning_mysql_server}:</td>\n\t\t<td>" . Field_checkbox_design("EnableZarafaTuning", 1, $EnableZarafaTuning, "EnableZarafaTuningCheck()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2><div style='font-size:30px'>{threads}:</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{read_buffer_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("read_buffer_size", $read_buffer_size, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{read_rnd_buffer_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("read_rnd_buffer_size", $read_rnd_buffer_size, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\n\t\n\t<tr>\t\n\t\t<td class=legend style='font-size:22px'>{sort_buffer_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("sort_buffer_size", $sort_buffer_size, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\t\n\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>thread_stack:</td>\n\t\t<td style='font-size:22px'>" . Field_text("thread_stack", $thread_stack, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td colspan=2><hr></td>\n\t</tr>\t\n\t<tr>\n\t\t<td colspan=2><div style='font-size:30px'>{server}:</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{key_buffer_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("key_buffer_size", $key_buffer_size, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>max_tmp_table_size:</td>\n\t\t<td style='font-size:22px'>" . Field_text("max_tmp_table_size", $max_tmp_table_size, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{query_cache_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("query_cache_size", $query_cache_size, "font-size:22px;width:110px;padding:3px") . "&nbsp;M</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{max_allowed_packet}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("zarafa_max_allowed_packet", $zarafa_max_allowed_packet, "font-size:22px;width:90px") . "&nbsp;M</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{max_connections}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("zarafa_max_connections", $zarafa_max_connections, "font-size:22px;width:90px") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\t\t\t\t\n\t<tr>\n\t\t<td colspan=2><hr></td>\n\t</tr>\t\n\t<tr>\n\t\t<td colspan=2><div style='font-size:30px'>INNODB:</td>\n\t</tr>\t\t\n\t\t\t\t\n<tr>\n\t\t<td class=legend style='font-size:22px'>{innodb_buffer_pool_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("zarafa_innodb_buffer_pool_size", $zarafa_innodb_buffer_pool_size, "font-size:22px;width:90px") . "&nbsp;M</td>\n\t\t<td width=1%>" . help_icon("{zarafa_innodb_buffer_pool_size}") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{query_cache_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("zarafa_query_cache_size", $zarafa_query_cache_size, "font-size:22px;width:90px") . "&nbsp;M</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{innodb_log_file_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("zarafa_innodb_log_file_size", $zarafa_innodb_log_file_size, "font-size:22px;width:90px") . "&nbsp;M</td>\n\t\t<td width=1%>" . help_icon("{zarafa_innodb_log_file_size}") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{innodb_log_buffer_size}:</td>\n\t\t<td style='font-size:22px'>" . Field_text("zarafa_innodb_log_buffer_size", $zarafa_innodb_log_buffer_size, "font-size:22px;width:90px") . "&nbsp;M</td>\n\t\t<td width=1%>" . help_icon("{zarafa_innodb_log_buffer_size}") . "</td>\n\t\t\n\t</tr>\t\n\n\t<tr>\n\t\t<td colspan=3 align=right><hr>" . button("{apply}", "ZarafaTunIngApply()", 30) . "</td>\n\t</tr>\t\n</table>\n</div>\n<script>\n\tfunction EnableZarafaTuningCheck(){\n\t\tdocument.getElementById('zarafa_innodb_buffer_pool_size').disabled=true;\n\t\tdocument.getElementById('zarafa_query_cache_size').disabled=true;\n\t\tdocument.getElementById('zarafa_innodb_log_file_size').disabled=true;\n\t\tdocument.getElementById('zarafa_innodb_log_buffer_size').disabled=true;\n\t\tdocument.getElementById('zarafa_max_allowed_packet').disabled=true;\n\t\tdocument.getElementById('zarafa_max_connections').disabled=true;\n\t\t\n\t\tdocument.getElementById('read_buffer_size').disabled=true;\n\t\tdocument.getElementById('read_rnd_buffer_size').disabled=true;\n\t\tdocument.getElementById('sort_buffer_size').disabled=true;\n\t\tdocument.getElementById('thread_stack').disabled=true;\n\t\t\n\t\tdocument.getElementById('key_buffer_size').disabled=true; \n\t\tdocument.getElementById('max_tmp_table_size').disabled=true; \n\t\tdocument.getElementById('query_cache_size').disabled=true;\n\t\t\n\t\tif(document.getElementById('EnableZarafaTuning').checked){\n\t\t\tdocument.getElementById('zarafa_innodb_buffer_pool_size').disabled=false;\n\t\t\tdocument.getElementById('zarafa_query_cache_size').disabled=false;\n\t\t\tdocument.getElementById('zarafa_innodb_log_file_size').disabled=false;\n\t\t\tdocument.getElementById('zarafa_innodb_log_buffer_size').disabled=false;\n\t\t\tdocument.getElementById('zarafa_max_allowed_packet').disabled=false;\n\t\t\tdocument.getElementById('zarafa_max_connections').disabled=false;\t\n\t\t\tdocument.getElementById('read_buffer_size').disabled=false;\n\t\t\tdocument.getElementById('read_rnd_buffer_size').disabled=false;\n\t\t\tdocument.getElementById('sort_buffer_size').disabled=false;\n\t\t\tdocument.getElementById('thread_stack').disabled=false;\t\n\t\t\tdocument.getElementById('key_buffer_size').disabled=false; \n\t\t\tdocument.getElementById('max_tmp_table_size').disabled=false; \n\t\t\tdocument.getElementById('query_cache_size').disabled=false;\n\t\t}\n\t\n\t}\n\tvar x_ZarafaTunIngApply= function (obj) {\n\t\tvar tempvalue=obj.responseText;\n\t\tif(tempvalue.length>3){alert(tempvalue);}\n\t\t\n\t\t}\t\n\t\n\tfunction ZarafaTunIngApply(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('EnableZarafaTuning').checked){\n\t\t\tXHR.appendData('EnableZarafaTuning',1);}else{XHR.appendData('EnableZarafaTuning',0);}\n\t\t\tXHR.appendData('zarafa_innodb_buffer_pool_size',document.getElementById('zarafa_innodb_buffer_pool_size').value);\n\t\t\tXHR.appendData('zarafa_query_cache_size',document.getElementById('zarafa_query_cache_size').value);\n\t\t\tXHR.appendData('zarafa_innodb_log_file_size',document.getElementById('zarafa_innodb_log_file_size').value);\n\t\t\tXHR.appendData('zarafa_innodb_log_buffer_size',document.getElementById('zarafa_innodb_log_buffer_size').value);\n\t\t\tXHR.appendData('zarafa_max_allowed_packet',document.getElementById('zarafa_max_allowed_packet').value);\n\t\t\tXHR.appendData('zarafa_max_connections',document.getElementById('zarafa_max_connections').value);\n\t\t\tXHR.appendData('key_buffer_size',document.getElementById('key_buffer_size').value); \n\t\t\tXHR.appendData('max_tmp_table_size',document.getElementById('max_tmp_table_size').value); \n\t\t\tXHR.appendData('query_cache_size',document.getElementById('query_cache_size').value);\n\t\t\tXHR.appendData('read_buffer_size',document.getElementById('read_buffer_size').value);\n\t\t\tXHR.appendData('read_rnd_buffer_size',document.getElementById('read_rnd_buffer_size').value);\n\t\t\tXHR.appendData('sort_buffer_size',document.getElementById('sort_buffer_size').value);\n\t\t\tXHR.appendData('thread_stack',document.getElementById('thread_stack').value);\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_ZarafaTunIngApply);\n\t\n\t}\n\t\nEnableZarafaTuningCheck();\n</script>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}