/** * Formats float number according to flags. * * @param float $num Number value to be formatted. * @param integer $dec How many digits after decimal point. * @param integer $mode Output mode. * * @return string **/ function perfmon_NumberFormat($num, $dec = 2, $mode = 0) { switch ($mode) { case 1: $str = number_format($num, $dec, '.', ''); break; case 2: $str = number_format($num, $dec, '.', ' '); $str = str_replace(' ', '<span></span>', $str); $str = '<span class="perfmon_number">' . $str . '</span>'; break; default: if ($_REQUEST["mode"] == "excel") { $str = perfmon_NumberFormat($num, $dec, 1); } else { $str = perfmon_NumberFormat($num, $dec, 2); } break; } return $str; }
$data[0]["ITEMS"][] = array("KPI_NAME" => GetMessage("PERFMON_KPI_NAME_QCACHE_PRUNES"), "KPI_VALUE" => perfmon_NumberFormat($stat['Qcache_lowmem_prunes'], 0), "KPI_RECOMMENDATION" => GetMessage("PERFMON_KPI_REC_QCACHE_PRUNES", array("#STAT_NAME#" => "<span class=\"perfmon_code\">Qcache_lowmem_prunes</span>", "#PARAM_VALUE#" => CFile::FormatSize($vars['query_cache_size']), "#PARAM_NAME#" => "<span class=\"perfmon_code\">query_cache_size</span>", "#PARAM_VALUE_HIGH#" => "128M"))); } } // Sorting $calc['total_sorts'] = $stat['Sort_scan'] + $stat['Sort_range']; $total_sorts = 'Sort_scan + Sort_range'; $data[0]["ITEMS"][] = array("KPI_NAME" => GetMessage("PERFMON_KPI_NAME_SORTS"), "KPI_VALUE" => perfmon_NumberFormat($calc['total_sorts'], 0), "KPI_RECOMMENDATION" => GetMessage("PERFMON_KPI_REC_SORTS", array("#STAT_NAME#" => "<span class=\"perfmon_code\">" . $total_sorts . "</span>"))); if ($calc['total_sorts'] > 0) { $calc['pct_temp_sort_table'] = round($stat['Sort_merge_passes'] / $calc['total_sorts'] * 100, 2); $data[0]["ITEMS"][] = array("KPI_NAME" => GetMessage("PERFMON_KPI_NAME_SORTS_DISK"), "IS_OK" => $calc['pct_temp_sort_table'] <= 10, "KPI_VALUE" => $calc['pct_temp_sort_table'] . "%", "KPI_RECOMMENDATION" => GetMessage("PERFMON_KPI_REC_SORTS_DISK", array("#STAT_NAME#" => "<span class=\"perfmon_code\">Sort_merge_passes / (Sort_scan + Sort_range)</span>", "#GOOD_VALUE#" => "10", "#PARAM1_VALUE#" => CFile::FormatSize($vars['sort_buffer_size']), "#PARAM1_NAME#" => "<span class=\"perfmon_code\">sort_buffer_size</span>", "#PARAM2_VALUE#" => CFile::FormatSize($vars['read_rnd_buffer_size']), "#PARAM2_NAME#" => "<span class=\"perfmon_code\">read_rnd_buffer_size</span>"))); } # Joins $calc['joins_without_indexes'] = $stat['Select_range_check'] + $stat['Select_full_join']; $calc['joins_without_indexes_per_day'] = intval($calc['joins_without_indexes'] / ($stat['Uptime'] / 86400)); if ($calc['joins_without_indexes_per_day'] > 250) { $data[0]["ITEMS"][] = array("KPI_NAME" => GetMessage("PERFMON_KPI_NAME_JOINS"), "KPI_VALUE" => perfmon_NumberFormat($calc['joins_without_indexes'], 0), "KPI_RECOMMENDATION" => GetMessage("PERFMON_KPI_REC_JOINS", array("#STAT_NAME#" => "<span class=\"perfmon_code\">Select_range_check + Select_full_join</span>", "#PARAM_VALUE#" => CFile::FormatSize($vars['join_buffer_size']), "#PARAM_NAME#" => "<span class=\"perfmon_code\">join_buffer_size</span>"))); } // Temporary tables if ($stat['Created_tmp_tables'] > 0) { $calc['tmp_table_size'] = $vars['tmp_table_size'] > $vars['max_heap_table_size'] ? $vars['max_heap_table_size'] : $vars['tmp_table_size']; if ($stat['Created_tmp_disk_tables'] > 0) { $calc['pct_temp_disk'] = round($stat['Created_tmp_disk_tables'] / ($stat['Created_tmp_tables'] + $stat['Created_tmp_disk_tables']) * 100, 2); } else { $calc['pct_temp_disk'] = 0; } $pct_temp_disk = 30; if ($calc['pct_temp_disk'] > $pct_temp_disk && $calc['max_tmp_table_size'] < 256 * 1024 * 1024) { $is_ok = false; $value = $calc['pct_temp_disk'] . "%"; $rec = GetMessage("PERFMON_KPI_REC_TMP_DISK_1", array("#STAT_NAME#" => "<span class=\"perfmon_code\">Created_tmp_disk_tables / (Created_tmp_tables + Created_tmp_disk_tables)</span>", "#STAT_VALUE#" => $pct_temp_disk . "%", "#PARAM1_NAME#" => "<span class=\"perfmon_code\">tmp_table_size</span>", "#PARAM1_VALUE#" => CFile::FormatSize($vars['tmp_table_size']), "#PARAM2_NAME#" => "<span class=\"perfmon_code\">max_heap_table_size</span>", "#PARAM2_VALUE#" => CFile::FormatSize($vars['max_heap_table_size']))); } elseif ($calc['pct_temp_disk'] > $pct_temp_disk && $calc['max_tmp_table_size'] >= 256) {
} $arSelectedFields[] = "ID"; $arNumCols = array("CACHE_SIZE" => 0, "COMPONENT_TIME" => 4, "QUERIES" => 0, "QUERIES_TIME" => 4, "CACHE_COUNT" => 0, "CACHE_COUNT_R" => 0, "CACHE_COUNT_W" => 0, "CACHE_COUNT_C" => 0); if (isset($arFilter["CACHE_TYPE"]) && $arFilter["CACHE_TYPE"] == "N") { $arFilter["CACHE_TYPE"] = array(false, "N"); } $cData = new CPerfomanceComponent(); $rsData = $cData->GetList(array($by => $order), $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), $arSelectedFields); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_COMP_PAGE"))); $max_display_url = COption::GetOptionInt("perfmon", "max_display_url"); while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_NAME, $arRes); foreach ($arNumCols as $column_name => $precision) { $row->AddViewField($column_name, perfmon_NumberFormat($arRes[$column_name], $precision)); } if ($f_QUERIES > 0) { $row->AddViewField("QUERIES", '<a href="perfmon_sql_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_component_id=' . $f_ID . '">' . $f_QUERIES . '</a>'); } $row->AddViewField("HIT_ID", '<a href="perfmon_hit_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_id=' . $f_HIT_ID . '">' . $f_HIT_ID . '</a>'); if ($f_CACHE_TYPE == "A") { $row->AddViewField("CACHE_TYPE", GetMessage("PERFMON_COMP_CACHE_TYPE_AUTO")); } elseif ($f_CACHE_TYPE == "Y") { $row->AddViewField("CACHE_TYPE", GetMessage("PERFMON_COMP_CACHE_TYPE_YES")); } else { $row->AddViewField("CACHE_TYPE", GetMessage("PERFMON_COMP_CACHE_TYPE_NO")); } if ($f_CACHE_COUNT > 0) { $row->AddViewField("CACHE_COUNT", '<a href="perfmon_cache_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_component_id=' . $f_ID . '">' . $f_CACHE_COUNT . '</a>'); }
$arSelectedFields = $lAdmin->GetVisibleHeaderColumns(); if (!is_array($arSelectedFields) || count($arSelectedFields) < 1) { $arSelectedFields = array("TABLE_NAME", "COLUMN_NAMES", "SQL_COUNT", "SQL_TIME", "SQL_TEXT"); } $arSelectedFields[] = "ID"; $cData = new CPerfomanceIndexSuggest(); $rsData = $cData->GetList($arSelectedFields, array("!=BANNED" => "Y"), array($by => $order)); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_INDEX_PAGE"))); while ($arRes = $rsData->NavNext(true, "f_")) { $arRes["SQL_TEXT"] = CPerfomanceSQL::Format($arRes["SQL_TEXT"]); $row =& $lAdmin->AddRow($f_NAME, $arRes); $row->AddViewField("SQL_TIME", perfmon_NumberFormat($f_SQL_TIME, 6)); if ($f_SQL_COUNT > 0) { $row->AddViewField("SQL_TIME_AVG", perfmon_NumberFormat($f_SQL_TIME / $f_SQL_COUNT, 6)); } $row->AddViewField("SQL_COUNT", '<a href="perfmon_sql_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_suggest_id=' . $f_ID . '">' . $f_SQL_COUNT . '</a>'); $row->AddViewField("COLUMN_NAMES", str_replace(",", "<br>", $f_COLUMN_NAMES)); if ($f_BANNED == "N") { $row->AddViewField("BANNED", '<span class="adm-lamp adm-lamp-in-list adm-lamp-green" title="' . htmlspecialcharsbx(GetMessage("PERFMON_INDEX_GREEN_ALT")) . '"></span>'); } elseif ($f_BANNED == "Y") { $row->AddViewField("BANNED", '<span class="adm-lamp adm-lamp-in-list adm-lamp-red" title="' . htmlspecialcharsbx(GetMessage("PERFMON_INDEX_RED_ALT")) . '"></span>'); } else { $row->AddViewField("BANNED", '<span class="adm-lamp adm-lamp-in-list adm-lamp-yellow" title="' . htmlspecialcharsbx(GetMessage("PERFMON_INDEX_YELLOW_ALT")) . '"></span>'); } $rsQueries = CPerfomanceSQL::GetList(array("ID"), array("=SUGGEST_ID" => $f_ID), array("ID" => "ASC"), false, array("nTopCount" => 1)); if ($arQuery = $rsQueries->GetNext()) { $f_SQL_ID = $arQuery["ID"]; } else { $f_SQL_ID = "";
$rs = $DB->Query($sql); while($rs->Fetch()); $etime = getmicrotime(); $ratio = ($arSuggest["SQL_TIME"]/$arSuggest["SQL_COUNT"])/($etime-$stime); ?> <tr> <td><?echo GetMessage("PERFMON_IDETAIL_QUERY_TIME")?>:</td> <td><?echo perfmon_NumberFormat($etime - $stime, 6)?></td> </tr> <? if($ratio > 1) {?> <tr> <td><?echo GetMessage("PERFMON_IDETAIL_GAIN")?>:</td> <td><span class="notetext"><?echo perfmon_NumberFormat($ratio*100, 2), "%"?></span></td> </tr> <?} ?> <?endif;?> <?echo bitrix_sessid_post();?> <input type="hidden" name="lang" value="<?echo LANGUAGE_ID?>"> <input type="hidden" name="ID" value="<?echo $ID?>"> <? $tabControl->End(); ?> </form> <? $tabControl->ShowWarnings("editform", $message);
:</td> <td><?php echo perfmon_NumberFormat($etime - $stime, 6); ?> </td> </tr> <?php if ($ratio > 1) { ?> <tr> <td><?php echo GetMessage("PERFMON_IDETAIL_GAIN"); ?> :</td> <td><span class="notetext"><?php echo perfmon_NumberFormat($ratio * 100, 2), "%"; ?> </span></td> </tr> <?php } ?> <?php } echo bitrix_sessid_post(); ?> <input type="hidden" name="lang" value="<?php echo LANGUAGE_ID; ?> "> <input type="hidden" name="ID" value="<?php
} } $lAdmin->AddHeaders($arHeaders); $arSelectedFields = $lAdmin->GetVisibleHeaderColumns(); if (!is_array($arSelectedFields) || count($arSelectedFields) < 1) { $arSelectedFields = array("ID", "HIT_ID", "NN", "QUERY_TIME", "SQL_TEXT"); } $cData = new CPerfomanceSQL(); $rsData = $cData->GetList($arSelectedFields, $arFilter, array($by => $order), false, array("nPageSize" => CAdminResult::GetNavSize($sTableID))); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_SQL_PAGE"))); while ($arRes = $rsData->NavNext(true, "f_")) { $arRes["SQL_TEXT"] = CPerfomanceSQL::Format($arRes["SQL_TEXT"]); $row =& $lAdmin->AddRow($f_NAME, $arRes); $row->AddViewField("QUERY_TIME", perfmon_NumberFormat($f_QUERY_TIME, 6)); if (class_exists("geshi") && $f_SQL_TEXT) { $obGeSHi = new GeSHi(CSqlFormat::reformatSql($arRes["SQL_TEXT"], new CSqlFormatText()), 'sql'); $html = $obGeSHi->parse_code(); } else { $html = str_replace(array(" ", "\t", "\n"), array(" ", " ", "<br>"), htmlspecialcharsbx(CSqlFormat::reformatSql($arRes["SQL_TEXT"]))); } $html = '<span onmouseover="addTimer(this)" onmouseout="removeTimer(this)" id="' . $f_ID . '_sql_backtrace">' . $html . '</span>'; $row->AddViewField("SQL_TEXT", $html); $row->AddViewField("HIT_ID", '<a href="perfmon_hit_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_id=' . $f_HIT_ID . '">' . $f_HIT_ID . '</a>'); if ($bCluster && $arRes["NODE_ID"] != "") { $row->AddViewField("NODE_ID", $arRes["NODE_ID"] > 1 ? $arClusterNodes[$arRes["NODE_ID"]] : $arClusterNodes[1]); } $arActions = array(); if ($DBType == "mysql" || $DBType == "oracle") { $arActions[] = array("DEFAULT" => "Y", "TEXT" => GetMessage("PERFMON_SQL_EXPLAIN"), "ACTION" => 'jsUtils.OpenWindow(\'perfmon_explain.php?lang=' . LANG . '&ID=' . $f_ID . '\', 600, 500);');
CTimeZone::Disable(); $rsData = $obTable->GetList($arSelectedFields, $arFilter, array($by => $order), array("nPageSize" => CAdminResult::GetNavSize($sTableID))); CTimeZone::Enable(); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_TABLE_PAGE"))); $max_display_url = COption::GetOptionInt("perfmon", "max_display_url"); while ($arRes = $rsData->Fetch()) { $row =& $lAdmin->AddRow($arRes["ID"], $arRes); $arRowPK = array(); foreach ($arFields as $FIELD_NAME => $FIELD_TYPE) { if (strlen($arRes[$FIELD_NAME]) > 0) { if ($FIELD_TYPE == "int") { $val = perfmon_NumberFormat($arRes[$FIELD_NAME], 0); } elseif ($FIELD_TYPE == "double") { $val = perfmon_NumberFormat($arRes[$FIELD_NAME], 2); } elseif ($FIELD_TYPE == "datetime") { $val = str_replace(" ", " ", $arRes["FULL_" . $FIELD_NAME]); } elseif ($FIELD_TYPE == "date") { $val = str_replace(" ", " ", $arRes["SHORT_" . $FIELD_NAME]); } else { $val = htmlspecialcharsbx($arRes[$FIELD_NAME]); } if (array_key_exists($FIELD_NAME, $arParents) && $DB->TableExists($arParents[$FIELD_NAME]["PARENT_TABLE"])) { $val = '<a onmouseover="addTimer(this)" onmouseout="removeTimer(this)" href="perfmon_table.php?set_filter=Y&table_name=' . $arParents[$FIELD_NAME]["PARENT_TABLE"] . '&find=' . urlencode($arRes[$FIELD_NAME]) . '&find_type=' . $arParents[$FIELD_NAME]["PARENT_COLUMN"] . '">' . $val . '</a>'; } $row->AddViewField($FIELD_NAME, $val); } if ($bDelete && in_array($FIELD_NAME, $arPKColumns)) { $arRowPK[] = urlencode("pk[" . $FIELD_NAME . "]") . "=" . urlencode($arRes[$FIELD_NAME]); }
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_HIT_PAGE2"))); $max_display_url = COption::GetOptionInt("perfmon", "max_display_url"); while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_NAME, $arRes); $row->AddViewField("SCRIPT_NAME", '<a href="perfmon_hit_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_script_name=' . $f_SCRIPT_NAME . '">' . $f_SCRIPT_NAME . '</a>'); $page_time = doubleval($arTotal["SUM_PAGE_TIME"]); if ($page_time > 0) { $row->AddViewField("PERCENT", perfmon_NumberFormat($arRes["SUM_PAGE_TIME"] / $page_time * 100, 2) . "%"); } else { $row->AddViewField("PERCENT", " "); } $row->AddViewField("COUNT", perfmon_NumberFormat($f_COUNT, 0)); foreach ($arGrpFuncs as $func) { foreach ($arGrpCols as $col => $prec) { if (strlen($arRes[$func . "_" . $col])) { $row->AddViewField($func . "_" . $col, perfmon_NumberFormat($arRes[$func . "_" . $col], $prec)); } } } } $lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount()), array("title" => GetMessage("PERFMON_HIT_TOTAL_HITS") . ":", "value" => $arTotal["COUNT"]))); $aContext = array(); $lAdmin->AddAdminContextMenu($aContext); $lAdmin->CheckListMode(); $APPLICATION->SetTitle(GetMessage("PERFMON_HIT_TITLE2")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $oFilter = new CAdminFilter($sTableID . "_filter", array("find_is_admin" => GetMessage("PERFMON_HIT_IS_ADMIN"), "find_count" => GetMessage("PERFMON_HIT_COUNT"))); ?> <form name="find_form" method="get" action="<?php echo $APPLICATION->GetCurPage();
switch ($_REQUEST['action']) { case "delete": CPerfomanceHistory::Delete($ID); break; } } } $lAdmin->AddHeaders(array(array("id" => "ID", "content" => GetMessage("PERFMON_HIST_ID"), "align" => "right", "default" => true), array("id" => "TIMESTAMP_X", "content" => GetMessage("PERFMON_HIST_TIMESTAMP_X"), "align" => "right", "default" => true), array("id" => "TOTAL_MARK", "content" => GetMessage("PERFMON_HIST_TOTAL_MARK"), "align" => "right", "default" => true), array("id" => "ACCELERATOR_ENABLED", "content" => GetMessage("PERFMON_HIST_ACCELERATOR_ENABLED"), "align" => "right", "default" => true))); $cData = new CPerfomanceHistory(); $rsData = $cData->GetList(array("ID" => "DESC")); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_HIST_PAGE"))); while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arRes); $row->AddViewField("TOTAL_MARK", perfmon_NumberFormat($f_TOTAL_MARK, 2)); $row->AddCheckField("ACCELERATOR_ENABLED", false); $arActions = array(); if ($RIGHT >= "W") { $arActions[] = array("ICON" => "delete", "DEFAULT" => "Y", "TEXT" => GetMessage("PERFMON_HIST_DELETE"), "ACTION" => "if(confirm('" . GetMessageJS('PERFMON_HIST_DELETE_CONFIRM') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete")); } if (!empty($arActions)) { $row->AddActions($arActions); } } $lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount()))); $aContext = array(); $lAdmin->AddAdminContextMenu($aContext); $lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount()), array("counter" => true, "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0"))); $aGroupActions = array(); if ($RIGHT >= "W") {
if (in_array("FILE_NAME", $arSelectedFields)) { $arSelectedFields[] = "FILE_PATH"; } $arNumCols = array("CACHE_SIZE" => 0, "COUNT" => 0, "COUNT_R" => 0, "COUNT_W" => 0, "COUNT_C" => 0, "SUM_CACHE_SIZE" => 0, "AVG_CACHE_SIZE" => 0, "MIN_CACHE_SIZE" => 0, "MAX_CACHE_SIZE" => 0, "HIT_RATIO" => 2); $cData = new CPerfomanceCache(); $rsData = $cData->GetList(array($by => $order), $arFilter, $group !== "none", array("nPageSize" => CAdminResult::GetNavSize($sTableID)), $arSelectedFields); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_CACHE_PAGE"))); $i = 0; $max_display_url = COption::GetOptionInt("perfmon", "max_display_url"); while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow(++$i, $arRes); $numbers = array(); foreach ($arNumCols as $column_name => $precision) { $numbers[$column_name] = perfmon_NumberFormat($arRes[$column_name], $precision); $row->AddViewField($column_name, $numbers[$column_name]); } $row->AddViewField("HIT_ID", '<a href="perfmon_hit_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_id=' . $f_HIT_ID . '">' . $f_HIT_ID . '</a>'); if ($f_FILE_NAME != "") { if ($f_FILE_PATH == "") { $f_FILE_PATH = $_SERVER["DOCUMENT_ROOT"] . $f_BASE_DIR . $f_INIT_DIR . $f_FILE_NAME; } if (file_exists($f_FILE_PATH) && substr($f_FILE_PATH, 0, $DOCUMENT_ROOT_LEN) === $_SERVER["DOCUMENT_ROOT"]) { $row->AddViewField("FILE_NAME", '<a target="blank" href="/bitrix/admin/fileman_file_view.php?path=' . urlencode(substr($f_FILE_PATH, $DOCUMENT_ROOT_LEN)) . '&lang=' . LANGUAGE_ID . '">' . $f_FILE_NAME . '</a>'); } } if ($f_OP_MODE == "R") { $row->AddViewField("OP_MODE", GetMessage("PERFMON_CACHE_OP_MODE_R")); } elseif ($f_OP_MODE == "W") { $row->AddViewField("OP_MODE", GetMessage("PERFMON_CACHE_OP_MODE_W"));