PageRenderTime 68ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/perfmon/admin/perfmon_panel.php

https://gitlab.com/alexprowars/bitrix
PHP | 1351 lines | 1252 code | 81 blank | 18 comment | 141 complexity | 4e6a95a599813bd5132d7d61f3fb0159 MD5 | raw file
  1. <?
  2. define("BX_SESSION_ID_CHANGE", false);
  3. define("PERFMON_STOP", true);
  4. if(isset($_REQUEST["test"]) && $_REQUEST["test"] === "Y")
  5. {
  6. define("NOT_CHECK_PERMISSIONS", true);
  7. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
  8. /** @global CMain $APPLICATION */
  9. /** @global CDatabase $DB */
  10. /** @global CUser $USER */
  11. IncludeModuleLangFile(__FILE__);
  12. if(
  13. $_REQUEST["last"] === "Y"
  14. && isset($_SESSION["PERFMON_TIMES"])
  15. && is_array($_SESSION["PERFMON_TIMES"])
  16. && count($_SESSION["PERFMON_TIMES"]) > 0
  17. && check_bitrix_sessid()
  18. && $APPLICATION->GetGroupRight("perfmon") >= "W"
  19. )
  20. {
  21. $sec_per_page = number_format(array_sum($_SESSION["PERFMON_TIMES"])/doubleval(count($_SESSION["PERFMON_TIMES"])), 4, ".", " ");
  22. COption::SetOptionString("perfmon", "mark_php_page_time", $sec_per_page);
  23. $result = number_format(doubleval(count($_SESSION["PERFMON_TIMES"]))/array_sum($_SESSION["PERFMON_TIMES"]), 2, ".", " ");
  24. COption::SetOptionString("perfmon", "mark_php_page_rate", $result);
  25. COption::SetOptionString("perfmon", "mark_php_page_date", ConvertTimeStamp(false, "FULL"));
  26. if (CModule::IncludeModule('perfmon'))
  27. {
  28. $ACCELERATOR_ENABLED = "N";
  29. foreach(CPerfomanceMeasure::GetAllAccelerators() as $accel)
  30. {
  31. if ($accel->IsWorking())
  32. {
  33. $ACCELERATOR_ENABLED = "Y";
  34. }
  35. }
  36. CPerfomanceHistory::Add($a=array(
  37. "TOTAL_MARK" => round(doubleval(count($_SESSION["PERFMON_TIMES"]))/array_sum($_SESSION["PERFMON_TIMES"]), 2),
  38. "ACCELERATOR_ENABLED" => $ACCELERATOR_ENABLED,
  39. ));
  40. }
  41. ?><script>
  42. BX('mark_result_in_note').innerHTML = '<b><?echo GetMessage("PERFMON_PANEL_MARK_RESULT", array("#result#" => $result)), "<span class=\"required\"><sup>1</sup></span>"?></b>';
  43. BX('page_rate_result').innerHTML = '<b><?echo $result?></b>';
  44. BX('page_time_result').innerHTML = '<?echo $sec_per_page?>';
  45. BX('tab_cont_perfomance').innerHTML = '<?echo GetMessage("PERFMON_PANEL_PERF_NAME")." (".$result.")"?>';
  46. jsUtils.FindChildObject(BX('perfomance'), 'div', 'adm-detail-title', true).innerHTML = '<?echo GetMessage("PERFMON_PANEL_PERF_TITLE2", array("#TOTAL_MARK_DATE#" => COption::GetOptionString("perfmon", "mark_php_page_date"), "#TOTAL_MARK_VALUE#" => $result));?>';
  47. </script><?
  48. }
  49. AddEventHandler("main", "OnAfterEpilog", function()
  50. {
  51. $main_exec_time = round(microtime(true) - START_EXEC_TIME, 4);
  52. $_SESSION["PERFMON_TIMES"][] = $main_exec_time;
  53. }
  54. );
  55. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
  56. die();
  57. }
  58. elseif(isset($_REQUEST["test"]) && $_REQUEST["test"] === "cluster")
  59. {
  60. define("PUBLIC_AJAX_MODE", true);
  61. define("BX_SECURITY_SHOW_MESSAGE", true);
  62. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
  63. /** @global CMain $APPLICATION */
  64. /** @global CDatabase $DB */
  65. /** @global CUser $USER */
  66. IncludeModuleLangFile(__FILE__);
  67. if(
  68. check_bitrix_sessid()
  69. && $APPLICATION->GetGroupRight("perfmon") >= "W"
  70. && CModule::IncludeModule('perfmon')
  71. )
  72. {
  73. $threads_step = intval($_GET["threads_step"]);
  74. if($threads_step <= 0)
  75. $threads_step = 0;
  76. $threads_from = intval($_GET["threads_from"]);
  77. if($threads_from <= 0)
  78. $threads_from = 1;
  79. $threads_to = intval($_GET["threads_to"]);
  80. if($threads_to < $threads_from)
  81. $threads_to = $threads_from + $threads_step;
  82. $threads_duration = intval($_GET["threads_duration"]);
  83. if($threads_duration <= 0)
  84. $threads_duration = 10;
  85. $match = array();
  86. if(
  87. preg_match("/^http:\\/\\/([0-9a-zA-Z-_.]+)\\/?\$/", $_GET["server_name"], $match)
  88. || preg_match("/^([0-9a-zA-Z-_.]+)\\/?\$/", $_GET["server_name"], $match)
  89. )
  90. {
  91. $server_name = $match[1];
  92. $server_port = 80;
  93. }
  94. elseif(
  95. preg_match("/^https:\\/\\/([0-9a-zA-Z-_.]+)\\/?\$/", $_GET["server_name"], $match)
  96. )
  97. {
  98. $server_name = $match[1];
  99. $server_port = 443;
  100. }
  101. elseif(
  102. preg_match("/^([0-9a-zA-Z-_.]+):(\\d+)\\/?\$/", $_GET["server_name"], $match)
  103. )
  104. {
  105. $server_name = $match[1];
  106. $server_port = $match[2];
  107. }
  108. else
  109. {
  110. ShowError(GetMessage("PERFMON_PANEL_WRONG_SERVER_NAME"));
  111. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
  112. die();
  113. }
  114. if($_GET["server_url"] <> '')
  115. $server_url = $_GET["server_url"];
  116. else
  117. $server_url = '/bitrix/admin/perfmon_panel.php?test=Y&show_page_exec_time=Y&show_sql_stat=N';
  118. if(mb_strpos($server_url, "show_page_exec_time=Y") === false)
  119. {
  120. if(mb_strpos($server_url, "?") === false)
  121. $server_url .= "?";
  122. $server_url .= '&show_page_exec_time=Y&show_sql_stat=N';
  123. }
  124. $bFinish = false;
  125. $threads = intval($_GET["threads"]);
  126. if($threads == 0)
  127. {
  128. //First clear old data
  129. $ob = new CPerfCluster;
  130. $ob->Truncate();
  131. //Timemark
  132. $_SESSION["treads_test_end"] = time() + $threads_duration*60;
  133. //Save options
  134. COption::SetOptionInt("perfmon", "test_threads_from", $threads_from);
  135. COption::SetOptionInt("perfmon", "test_threads_to", $threads_to);
  136. COption::SetOptionInt("perfmon", "test_threads_step", $threads_step);
  137. COption::SetOptionString("perfmon", "test_server_name", $_GET["server_name"]);
  138. COption::SetOptionString("perfmon", "test_server_url", $_GET["server_url"]);
  139. COption::SetOptionInt("perfmon", "test_threads_duration", $threads_duration);
  140. ?><script>
  141. BX('threads_from').value = <?echo $threads_from?>;
  142. BX('threads_to').value = <?echo $threads_to?>;
  143. BX('threads_step').value = <?echo $threads_step?>;
  144. BX('server_name').value = '<?echo CUtil::JSEscape($_GET["server_name"])?>';
  145. BX('server_url').value = '<?echo CUtil::JSEscape($_GET["server_url"])?>';
  146. BX('threads_duration').value = <?echo $threads_duration?>;
  147. ThreadsUpdateImage('img_PAGES_PER_SECOND', <?echo $threads_from?>, <?echo $threads_to?>);
  148. ThreadsUpdateImage('img_PAGE_EXEC_TIME', <?echo $threads_from?>, <?echo $threads_to?>);
  149. ThreadsTest(<?echo $threads_from?>);
  150. </script><?
  151. }
  152. elseif(time() > $_SESSION["treads_test_end"]) //Finished
  153. {
  154. ?><script>
  155. ThreadsStop();
  156. </script><?
  157. $bFinish = true;
  158. }
  159. else
  160. {
  161. $ob = new CPerfCluster;
  162. $ob->Measure(
  163. $server_name,
  164. $server_port,
  165. $server_url,
  166. $threads
  167. );
  168. $threads = $threads + $threads_step;
  169. if($threads > $threads_to)
  170. $threads = $threads_to;
  171. ?><script>
  172. ThreadsUpdateImage('img_PAGES_PER_SECOND', <?echo $threads_from?>, <?echo $threads_to?>);
  173. ThreadsUpdateImage('img_PAGE_EXEC_TIME', <?echo $threads_from?>, <?echo $threads_to?>);
  174. ThreadsTest(<?echo $threads?>);
  175. </script><?
  176. }
  177. ?>
  178. <div style="text-align:center;">
  179. &nbsp;
  180. <table border="0" cellpadding="0" cellspacing="0" class="internal" width="100%">
  181. <tr class="heading">
  182. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_NN")?></td>
  183. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_CONCURRENCY")?></td>
  184. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_HITS")?></td>
  185. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_ERRORS")?></td>
  186. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_PAGES_PER_SECOND")?></td>
  187. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_PAGE_EXEC_TIME")?></td>
  188. <td align="center"><?echo GetMessage("PERFMON_PANEL_CLUSTER_PAGE_RESP_TIME")?></td>
  189. </tr>
  190. <?
  191. $i = 0;
  192. $cData = new CPerfCluster;
  193. $rsData = $cData->GetList(array("ID" => "ASC"));
  194. while($ar = $rsData->Fetch()):
  195. $i++;
  196. ?>
  197. <tr>
  198. <td class="bx-digit-cell"><?echo $i?></td>
  199. <td class="bx-digit-cell"><?echo intval($ar["THREADS"])?></td>
  200. <td class="bx-digit-cell"><?echo intval($ar["HITS"])?></td>
  201. <td class="bx-digit-cell"><?echo intval($ar["ERRORS"])?></td>
  202. <td class="bx-digit-cell"><?echo number_format($ar["PAGES_PER_SECOND"], 2, ".", " ")?></td>
  203. <td class="bx-digit-cell"><?echo number_format($ar["PAGE_EXEC_TIME"], 6, ".", " ")?></td>
  204. <td class="bx-digit-cell"><?echo number_format($ar["PAGE_RESP_TIME"], 6, ".", " ")?></td>
  205. </tr>
  206. <?endwhile;?>
  207. <?if(!$bFinish):?>
  208. <tr>
  209. <td colspan="7" id="measure_message"><?echo GetMessage("PERFMON_PANEL_MEASURE")?></td>
  210. </tr>
  211. <?endif;?>
  212. </table>
  213. </div>
  214. <?
  215. }
  216. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
  217. die();
  218. }
  219. elseif(isset($_REQUEST["test"]) && $_REQUEST["test"] === "session" && isset($_REQUEST["last"]) && $_REQUEST["last"] === "Y")
  220. {
  221. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  222. /** @global CMain $APPLICATION */
  223. /** @global CDatabase $DB */
  224. /** @global CUser $USER */
  225. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
  226. IncludeModuleLangFile(__FILE__);
  227. if(
  228. check_bitrix_sessid()
  229. && $APPLICATION->GetGroupRight("perfmon") >= "W"
  230. )
  231. {
  232. if(
  233. isset($_SESSION["PERFMON_SESSION_START"])
  234. && is_array($_SESSION["PERFMON_SESSION_START"])
  235. && count($_SESSION["PERFMON_SESSION_START"]) > 0
  236. )
  237. {
  238. $result = number_format(array_sum($_SESSION["PERFMON_SESSION_START"])/doubleval(count($_SESSION["PERFMON_SESSION_START"])), 4, ".", " ");
  239. COption::SetOptionString("perfmon", "mark_php_session_time_value", $result);
  240. ?><script>
  241. BX('session_time_result').innerHTML = '<?echo $result?>';
  242. </script><?
  243. }
  244. }
  245. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
  246. die();
  247. }
  248. elseif(isset($_REQUEST["test"]) && $_REQUEST["test"] === "session")
  249. {
  250. define("NOT_CHECK_PERMISSIONS", true);
  251. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
  252. session_write_close();
  253. $stime = microtime(true);
  254. session_start();
  255. $etime = microtime(true);
  256. if(isset($_SESSION["PERFMON_SESSION_START"]) && is_array($_SESSION["PERFMON_SESSION_START"]))
  257. {
  258. $_SESSION["PERFMON_SESSION_START"][] = $etime - $stime;
  259. }
  260. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
  261. die();
  262. }
  263. elseif(isset($_REQUEST["test"]))
  264. {
  265. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  266. /** @global CMain $APPLICATION */
  267. /** @global CDatabase $DB */
  268. /** @global CUser $USER */
  269. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/perfmon/include.php");
  270. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/perfmon/prolog.php");
  271. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
  272. IncludeModuleLangFile(__FILE__);
  273. if(check_bitrix_sessid() && $APPLICATION->GetGroupRight("perfmon") >= "W")
  274. {
  275. switch($_REQUEST["test"])
  276. {
  277. case "cpu":
  278. COption::SetOptionString("perfmon", "mark_php_cpu_value", number_format(CPerfomanceMeasure::GetPHPCPUMark(), 1, ".", " "));
  279. echo COption::GetOptionString("perfmon", "mark_php_cpu_value");
  280. break;
  281. case "files":
  282. COption::SetOptionString("perfmon", "mark_php_files_value", number_format(CPerfomanceMeasure::GetPHPFilesMark(), 1, ".", " "));
  283. echo COption::GetOptionString("perfmon", "mark_php_files_value");
  284. break;
  285. case "mail":
  286. COption::SetOptionString("perfmon", "mark_php_mail_value", number_format(CPerfomanceMeasure::GetPHPMailMark(), 4, ".", " "));
  287. echo COption::GetOptionString("perfmon", "mark_php_mail_value");
  288. break;
  289. case "db_insert":
  290. COption::SetOptionString("perfmon", "mark_db_insert_value", number_format(CPerfomanceMeasure::GetDBMark("insert"), 0, ".", " "));
  291. echo COption::GetOptionString("perfmon", "mark_db_insert_value");
  292. break;
  293. case "db_read":
  294. COption::SetOptionString("perfmon", "mark_db_read_value", number_format(CPerfomanceMeasure::GetDBMark("read"), 0, ".", " "));
  295. echo COption::GetOptionString("perfmon", "mark_db_read_value");
  296. break;
  297. case "db_update":
  298. COption::SetOptionString("perfmon", "mark_db_update_value", number_format(CPerfomanceMeasure::GetDBMark("update"), 0, ".", " "));
  299. echo COption::GetOptionString("perfmon", "mark_db_update_value");
  300. break;
  301. case "php":
  302. $bPHPIsGood = version_compare(phpversion(), "5.1.0", ">=");
  303. if($bPHPIsGood)
  304. {
  305. if(ini_get('open_basedir') <> '')
  306. {
  307. $bPHPIsGood = false;
  308. }
  309. }
  310. if($bPHPIsGood)
  311. {
  312. $size = CPerfAccel::unformat(ini_get('realpath_cache_size'));
  313. if($size < 4*1024*1024)
  314. $bPHPIsGood = false;
  315. }
  316. if($bPHPIsGood)
  317. {
  318. $bPHPIsGood = false;
  319. foreach(CPerfomanceMeasure::GetAllAccelerators() as $accel)
  320. {
  321. if ($accel->IsWorking())
  322. {
  323. $bPHPIsGood = true;
  324. }
  325. }
  326. }
  327. if($bPHPIsGood)
  328. {
  329. echo GetMessage("PERFMON_PANEL_MARK_PHP_IS_GOOD");
  330. COption::SetOptionString("perfmon", "mark_php_is_good", "Y");
  331. }
  332. else
  333. {
  334. echo "<span class=\"errortext\">".GetMessage("PERFMON_PANEL_MARK_PHP_IS_NO_GOOD")."</span>";
  335. COption::SetOptionString("perfmon", "mark_php_is_good", "N");
  336. }
  337. break;
  338. case "monitor":
  339. if($duration > 0)
  340. {
  341. CPerfomanceKeeper::SetActive($duration > 0, time() + $duration);
  342. }
  343. elseif($action == "stop")
  344. {
  345. CPerfomanceKeeper::SetActive(false);
  346. }
  347. if(CPerfomanceKeeper::IsActive())
  348. {
  349. $end_time = COption::GetOptionInt("perfmon", "end_time");
  350. if(time() > $end_time)
  351. {
  352. CPerfomanceKeeper::SetActive(false);
  353. if(COption::GetOptionString("perfmon", "total_mark_value", "") == "measure")
  354. COption::SetOptionString("perfmon", "total_mark_value", "calc");
  355. }
  356. }
  357. $cData = new CPerfomanceHit;
  358. $rsData = $cData->GetList(array("IS_ADMIN" => "DESC"), array("=IS_ADMIN" => "N"), true, false, array("IS_ADMIN", "COUNT", "SUM_PAGE_TIME", "AVG_PAGE_TIME"));
  359. $arTotalPage = $rsData->Fetch();
  360. if(($action == "stop") || (COption::GetOptionString("perfmon", "total_mark_value") == "calc"))
  361. {
  362. if($arTotalPage["AVG_PAGE_TIME"] > 0)
  363. COption::SetOptionString("perfmon", "total_mark_value", number_format(1/$arTotalPage["AVG_PAGE_TIME"], 2));
  364. else
  365. COption::SetOptionString("perfmon", "total_mark_value", "N/A");
  366. COption::SetOptionString("perfmon", "total_mark_hits", intval($arTotalPage["COUNT"]));
  367. COption::SetOptionString("perfmon", "total_mark_time", ConvertTimeStamp(false, "FULL"));
  368. }
  369. if(CPerfomanceKeeper::IsActive() || $duration > 0):
  370. $interval = COption::GetOptionInt("perfmon", "end_time") - time();
  371. if($interval < 0)
  372. $interval = 0;
  373. $hours = intval($interval / 3600);
  374. $interval -= $hours * 3600;
  375. $minutes = intval($interval / 60);
  376. $interval -= $minutes * 60;
  377. $seconds = intval($interval);
  378. echo GetMessage("PERFMON_PANEL_MINUTES", array("#HOURS#" => $hours, "#MINUTES#" => $minutes, "#SECONDS#" => $seconds));?><br>
  379. <?echo GetMessage("PERFMON_PANEL_TEST_PROGRESS", array("#HITS#" => intval($arTotalPage["COUNT"])));?><br>
  380. <input type="button" value="<?echo GetMessage("PERFMON_PANEL_BTN_STOP")?>" OnClick="javascript:StopTest()">
  381. <script>
  382. setTimeout("ShowDev()", 3000);
  383. </script>
  384. <?else:
  385. ?>
  386. <table border="0" cellpadding="0" cellspacing="0" class="internal" width="100%">
  387. <tr class="heading">
  388. <td width="40%" align="center"><?echo GetMessage("PERFMON_PANEL_DEV_SCRIPT_NAME")?></td>
  389. <td width="0%" align="center"><?echo GetMessage("PERFMON_PANEL_DEV_WARNINGS"),"<span class=\"required\"><sup>2</sup></span>"?></td>
  390. <td width="20%" align="center"><?echo GetMessage("PERFMON_PANEL_DEV_PERCENT")?></td>
  391. <td width="20%" align="center"><?echo GetMessage("PERFMON_PANEL_DEV_COUNT")?></td>
  392. <td width="20%" align="center"><?echo GetMessage("PERFMON_PANEL_DEV_AVG_PAGE_TIME")?></td>
  393. </tr>
  394. <?
  395. $cData = new CPerfomanceHit;
  396. $rsData = $cData->GetList(array("SUM_PAGE_TIME" => "DESC"), array("=IS_ADMIN" => "N"), true, false, array("SCRIPT_NAME", "COUNT", "SUM_PAGE_TIME", "AVG_PAGE_TIME"));
  397. $i = 20;
  398. while(($ar = $rsData->Fetch()) && ($i > 0)):
  399. $ar["PERCENT"] = $ar["SUM_PAGE_TIME"] / $arTotalPage["SUM_PAGE_TIME"] * 100;
  400. $i--;
  401. ?>
  402. <tr>
  403. <td><a href="<?echo htmlspecialcharsbx("perfmon_hit_list.php?lang=".LANGUAGE_ID."&set_filter=Y&find_script_name=".urlencode($ar["SCRIPT_NAME"]))?>"><?echo htmlspecialcharsEx($ar["SCRIPT_NAME"])?></a></td>
  404. <td class="bx-digit-cell" id="err_count_<?echo $i?>"><?
  405. $rsHit = CPerfomanceHit::GetList(array("COUNT" => "DESC"), array(
  406. '=SCRIPT_NAME' => $ar["SCRIPT_NAME"],
  407. '=IS_ADMIN' => 'N',
  408. '=CACHE_TYPE' => 'Y',
  409. '>MENU_RECALC' => 0,
  410. ), true, array(), array('COUNT'));
  411. if(($arHit = $rsHit->Fetch()) && ($arHit["COUNT"] >= $ar["COUNT"])):
  412. $err_count = 1;
  413. $sHint = '<tr><td nowrap><b>'.GetMessage("PERFMON_PANEL_DEV_WARN1").'</b> '.GetMessage("PERFMON_PANEL_DEV_WARN1_DESC").'</td></tr>';
  414. else:
  415. $err_count = 0;
  416. $sHint = "";
  417. endif;
  418. $arComps = array();
  419. if($ar["COUNT"] > 1)
  420. {
  421. $rsHit = CPerfomanceComponent::GetList(array("COUNT" => "DESC"), array(
  422. '=HIT_SCRIPT_NAME' => $ar["SCRIPT_NAME"],
  423. '=HIT_IS_ADMIN' => 'N',
  424. '=HIT_CACHE_TYPE' => 'Y',
  425. '>QUERIES' => 0,
  426. ), true, array(), array('COMPONENT_NAME', 'COUNT'));
  427. while($arHit = $rsHit->Fetch())
  428. {
  429. if($arHit["COUNT"] >= $ar["COUNT"])
  430. $arComps[] = htmlspecialcharsbx($arHit["COMPONENT_NAME"]);
  431. }
  432. }
  433. if(count($arComps))
  434. {
  435. $err_count++;
  436. $sHint .= '<tr><td nowrap><b>'.GetMessage("PERFMON_PANEL_DEV_WARN2").' '.GetMessage("PERFMON_PANEL_DEV_WARN2_DESC").'</b> <ul style="font-size:100%">';
  437. foreach($arComps as $component_name)
  438. $sHint .= '<li><a href="perfmon_comp_list.php?lang='.LANGUAGE_ID.'&amp;set_filter=Y&amp;find_hit_script_name='.urlencode(htmlspecialcharsbx($ar["SCRIPT_NAME"])).'&amp;find_component_name='.urlencode($component_name).'">'.$component_name.'</a></li>';
  439. $sHint .= '</ul></td></tr>';
  440. }
  441. $rsHit = CPerfomanceComponent::GetList(array("COUNT" => "DESC"), array(
  442. '=HIT_SCRIPT_NAME' => $ar["SCRIPT_NAME"],
  443. '=HIT_IS_ADMIN' => 'N',
  444. '=HIT_CACHE_TYPE' => 'Y',
  445. '>CACHE_SIZE' => 1024*1024,
  446. ), true, array(), array('COMPONENT_NAME', 'MAX_CACHE_SIZE'));
  447. $bFirst = true;
  448. while($arHit = $rsHit->Fetch())
  449. {
  450. if($bFirst)
  451. {
  452. $err_count++;
  453. $sHint .= '<tr><td nowrap><b>'.GetMessage("PERFMON_PANEL_DEV_WARN3").'</b> '.GetMessage("PERFMON_PANEL_DEV_WARN3_DESC").'<ul style="font-size:100%">';
  454. $bFirst = false;
  455. }
  456. $sHint .= '<li>'.CFile::FormatSize($arHit["MAX_CACHE_SIZE"], 0).' <a href="perfmon_comp_list.php?lang='.LANGUAGE_ID.'&amp;set_filter=Y&amp;find_hit_script_name='.urlencode(htmlspecialcharsbx($ar["SCRIPT_NAME"])).'&amp;find_component_name='.urlencode(htmlspecialcharsbx($arHit["COMPONENT_NAME"])).'">'.htmlspecialcharsbx($arHit["COMPONENT_NAME"]).'</a></li>';
  457. }
  458. if(!$bFirst)
  459. $sHint .= '</ul></td></tr>';
  460. ?>
  461. <?if($err_count):?>
  462. <a href="javascript:void(0)" id="a_err_count_<?echo $i?>"><?echo $err_count?></a>
  463. <script>
  464. window.structHint<?echo "err_count_".$i?> = new BXHint(
  465. '<?echo CUtil::JSEscape('<table cellspacing="0" border="0" style="font-size:100%">'.$sHint.'</table>')?>',
  466. BX('<?echo "a_err_count_".$i?>'), {width:false, show_on_click:true}
  467. );
  468. </script>
  469. <?else:?>
  470. &nbsp;
  471. <?endif;?>
  472. </td>
  473. <td class="bx-digit-cell"><?echo number_format($ar["PERCENT"], 2)?>%</td>
  474. <td class="bx-digit-cell"><?echo number_format($ar["COUNT"], 0, ".", " ")?></td>
  475. <td class="bx-digit-cell"><?echo number_format($ar["AVG_PAGE_TIME"], 4, ".", " ")?></td>
  476. </tr>
  477. <?endwhile;?>
  478. </table>
  479. <br />
  480. <a href="perfmon_hit_grouped.php?find_is_admin=N&amp;set_filter=Y&amp;lang=<?echo LANGUAGE_ID?>"><?echo GetMessage("PERFMON_PANEL_DEV_GROUPED_HIT_LIST")?></a>
  481. <script>
  482. CloseWaitWindow();
  483. BX('calc').disabled = false;
  484. jsUtils.FindChildObject(BX('dev'), 'div', 'adm-detail-title', true).innerHTML = '<?echo
  485. GetMessage("PERFMON_PANEL_DEV_TITLE2", array(
  486. "#mark_value#" => COption::GetOptionString("perfmon", "total_mark_value"),
  487. "#hits#" => COption::GetOptionString("perfmon", "total_mark_hits"),
  488. "#duration#" => COption::GetOptionString("perfmon", "total_mark_duration"),
  489. "#mark_time#" => COption::GetOptionString("perfmon", "total_mark_time"),
  490. ));?>';
  491. BX('tab_cont_dev').innerHTML = '<?echo GetMessage("PERFMON_PANEL_DEV_NAME")." (".COption::GetOptionString("perfmon", "total_mark_value").")";?>';
  492. </script>
  493. <?endif;
  494. break;
  495. default:
  496. echo '&nbsp;';
  497. }
  498. }
  499. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
  500. die();
  501. }
  502. else
  503. {
  504. define("ADMIN_MODULE_NAME", "perfmon");
  505. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  506. /** @global CMain $APPLICATION */
  507. /** @global CDatabase $DB */
  508. /** @global CUser $USER */
  509. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/perfmon/include.php");
  510. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/perfmon/prolog.php");
  511. IncludeModuleLangFile(__FILE__);
  512. $RIGHT = $APPLICATION->GetGroupRight("perfmon");
  513. if($RIGHT < "R")
  514. $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  515. $mark_value = COption::GetOptionString("perfmon", "mark_php_page_rate", "");
  516. $mark_date = COption::GetOptionString("perfmon", "mark_php_page_date", "");
  517. if($REQUEST_METHOD == "POST" && ($calc.$total_calc!="") && $RIGHT >= "W" && check_bitrix_sessid())
  518. {
  519. COption::RemoveOption("perfmon", "mark_php_cpu_value");
  520. COption::RemoveOption("perfmon", "mark_php_files_value");
  521. COption::RemoveOption("perfmon", "mark_php_mail_value");
  522. COption::RemoveOption("perfmon", "mark_php_session_time_value");
  523. COption::RemoveOption("perfmon", "mark_php_is_good");
  524. COption::RemoveOption("perfmon", "mark_db_insert_value");
  525. COption::RemoveOption("perfmon", "mark_db_read_value");
  526. COption::RemoveOption("perfmon", "mark_db_update_value");
  527. if($total_calc <> '')
  528. {
  529. CPerfomanceComponent::Clear();
  530. CPerfomanceSQL::Clear();
  531. CPerfomanceHit::Clear();
  532. CPerfomanceError::Clear();
  533. CPerfomanceCache::Clear();
  534. COption::SetOptionString("perfmon", "total_mark_value", "measure");
  535. COption::SetOptionInt("perfmon", "total_mark_duration", $total_duration);
  536. COption::RemoveOption("perfmon", "total_mark_hits");
  537. COption::RemoveOption("perfmon", "total_mark_time");
  538. }
  539. COption::SetOptionString("perfmon", "mark_php_page_rate", "measure");
  540. COption::SetOptionString("perfmon", "mark_php_page_time", "measure");
  541. $_SESSION["PERFMON_TIMES"] = array();
  542. $_SESSION["PERFMON_SESSION_START"] = array();
  543. LocalRedirect("perfmon_panel.php?lang=".LANGUAGE_ID);
  544. }
  545. $bComponentCache = COption::GetOptionString("main", "component_cache_on", "Y")=="Y";
  546. $arModulesInstalled = array();
  547. $rsModules = CModule::GetDropDownList();
  548. while($arModule = $rsModules->Fetch())
  549. {
  550. $arModulesInstalled[] = $arModule["REFERENCE_ID"];
  551. }
  552. $statistic_path = IsModuleInstalled('statistic')
  553. && (COption::GetOptionString("statistic", "SAVE_PATH_DATA") == "Y");
  554. $search_is_ok = IsModuleInstalled('search')
  555. && (COption::GetOptionString("search", "use_stemming")=="Y")
  556. && (COption::GetOptionString("search", "use_tf_cache")=="Y");
  557. if(CModule::IncludeModule('advertising') && COption::GetOptionString('advertising', 'DONT_FIX_BANNER_SHOWS')!=="Y")
  558. {
  559. $rsBanners = CAdvBanner::GetList('', '', array("FIX_SHOW" => "Y"), null, "N");
  560. if($rsBanners->Fetch())
  561. $adv_banners_fix_shows = true;
  562. else
  563. $adv_banners_fix_shows = false;
  564. }
  565. else
  566. {
  567. $adv_banners_fix_shows = false;
  568. }
  569. $arConstants = array(
  570. "CACHED_b_forum_filter",
  571. "CACHED_b_forum2site",
  572. "CACHED_b_forum_perms",
  573. "CACHED_b_forum_smile",
  574. "CACHED_b_forum_user",
  575. "CACHED_b_forum_group",
  576. "CACHED_b_forum",
  577. "CACHED_b_iblock_property_enum",
  578. "CACHED_b_iblock_type",
  579. "CACHED_b_iblock",
  580. "CACHED_b_lang",
  581. "CACHED_b_option",
  582. "CACHED_b_lang_domain",
  583. "CACHED_b_site_template",
  584. "CACHED_b_event",
  585. "CACHED_b_agent",
  586. "CACHED_b_user_field",
  587. "CACHED_b_task",
  588. "CACHED_b_task_operation",
  589. "CACHED_b_search_tags",
  590. "CACHED_b_search_tags_len",
  591. "CACHED_b_sec_iprule",
  592. "CACHED_b_sec_filter_mask",
  593. "CACHED_b_sec_redirect_url",
  594. "CACHED_b_sonet_group_subjects",
  595. "CACHED_b_vote_question",
  596. );
  597. foreach($arConstants as $i => $constant)
  598. {
  599. if(!defined($constant))
  600. unset($arConstants[$i]);
  601. elseif(constant($constant)!==false)
  602. unset($arConstants[$i]);
  603. }
  604. $bManagedCache = count($arConstants) <= 0;
  605. $arEncodedModules = array();
  606. foreach($arModulesInstalled as $module_id)
  607. {
  608. $file_name = $_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/".$module_id."/include.php";
  609. if(file_exists($file_name) && is_file($file_name))
  610. {
  611. $fp = fopen($file_name, "rb");
  612. $sign = fread($fp, 4);
  613. if($sign == "Zend")
  614. $arEncodedModules[] = $module_id;
  615. fclose($fp);
  616. }
  617. }
  618. $bEncodedModules = count($arEncodedModules) <= 0;
  619. if($DB->type == "MYSQL")
  620. {
  621. $db_last_optimize = COption::GetOptionInt("main", "LAST_DB_OPTIMIZATION_TIME", 0);
  622. $bOptimized = $db_last_optimize >= (time() - 31*24*3600);
  623. }
  624. else
  625. {
  626. $bOptimized = true;
  627. }
  628. $bOptimal = $bComponentCache
  629. && $bManagedCache
  630. && $bEncodedModules
  631. && $bOptimized
  632. ;
  633. if($bOptimal)
  634. {
  635. if(COption::GetOptionString("perfmon", "bitrix_optimal", "-") !== "Y")
  636. COption::SetOptionString("perfmon", "bitrix_optimal", "Y");
  637. }
  638. else
  639. {
  640. if(COption::GetOptionString("perfmon", "bitrix_optimal", "-") !== "N")
  641. COption::SetOptionString("perfmon", "bitrix_optimal", "N");
  642. }
  643. $cData = new CPerfomanceHit;
  644. $rsData = $cData->GetList(array("IS_ADMIN" => "DESC"), array("=IS_ADMIN" => "N"), true, false, array("IS_ADMIN", "COUNT", "SUM_PAGE_TIME", "AVG_PAGE_TIME"));
  645. $arTotalPage = $rsData->Fetch();
  646. if(COption::GetOptionString("perfmon", "total_mark_value") == "calc" && $arTotalPage)
  647. {
  648. COption::SetOptionString("perfmon", "total_mark_value", number_format(1/$arTotalPage["AVG_PAGE_TIME"], 2));
  649. COption::SetOptionString("perfmon", "total_mark_hits", intval($arTotalPage["COUNT"]));
  650. COption::SetOptionString("perfmon", "total_mark_time", ConvertTimeStamp(false, "FULL"));
  651. }
  652. $APPLICATION->SetTitle(GetMessage("PERFMON_PANEL_TITLE"));
  653. $aTabs = array(
  654. array(
  655. "DIV" => "perfomance",
  656. "TAB" => GetMessage("PERFMON_PANEL_PERF_NAME").(
  657. mb_strlen($mark_value) && $mark_value != "measure"?
  658. " (".$mark_value.")":
  659. ""
  660. ),
  661. "ICON" => "main_user_edit",
  662. "TITLE" => (
  663. mb_strlen($mark_value) && $mark_value != "measure"?
  664. GetMessage("PERFMON_PANEL_PERF_TITLE2", array("#TOTAL_MARK_DATE#" => $mark_date, "#TOTAL_MARK_VALUE#" => $mark_value)):
  665. GetMessage("PERFMON_PANEL_PERF_TITLE1")
  666. ),
  667. ),
  668. array(
  669. "DIV" => "bitrix",
  670. "TAB" => GetMessage("PERFMON_PANEL_BITRIX_NAME").(
  671. COption::GetOptionString("perfmon", "bitrix_optimal", "-") === "Y"?
  672. " (".GetMessage("PERFMON_PANEL_MARK_PHP_IS_GOOD").")":
  673. " (".GetMessage("PERFMON_PANEL_MARK_PHP_IS_NO_GOOD").")"
  674. ),
  675. "ICON" => "main_user_edit",
  676. "TITLE" => GetMessage("PERFMON_PANEL_BITRIX_TITLE"),
  677. ),
  678. array(
  679. "DIV" => "dev",
  680. "TAB" => GetMessage("PERFMON_PANEL_DEV_NAME").(
  681. COption::GetOptionString("perfmon", "total_mark_time", "") <> ''?
  682. " (".COption::GetOptionString("perfmon", "total_mark_value").")":
  683. ""
  684. ),
  685. "ICON" => "main_user_edit",
  686. "TITLE" => (
  687. COption::GetOptionString("perfmon", "total_mark_time", "") <> ''?
  688. GetMessage("PERFMON_PANEL_DEV_TITLE2", array(
  689. "#mark_value#" => COption::GetOptionString("perfmon", "total_mark_value"),
  690. "#hits#" => COption::GetOptionString("perfmon", "total_mark_hits"),
  691. "#duration#" => COption::GetOptionString("perfmon", "total_mark_duration"),
  692. "#mark_time#" => COption::GetOptionString("perfmon", "total_mark_time"),
  693. )):
  694. GetMessage("PERFMON_PANEL_DEV_TITLE1")
  695. ),
  696. ),
  697. array(
  698. "DIV" => "cluster",
  699. "TAB" => GetMessage("PERFMON_PANEL_CLUSTER_TAB"),
  700. "ICON" => "main_user_edit",
  701. "TITLE" => GetMessage("PERFMON_PANEL_CLUSTER_TAB_TITLE"),
  702. ),
  703. );
  704. $tabControl = new CAdminTabControl("tabControl", $aTabs, true, true);
  705. require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
  706. ?>
  707. <script>
  708. var page_rate_count = 10;
  709. var session_count = 10;
  710. var duration = <?echo CPerfomanceKeeper::IsActive()? 0: intval(COption::GetOptionInt("perfmon", "total_mark_duration", 0))?>;
  711. function StopTest()
  712. {
  713. CHttpRequest.Action = function(result)
  714. {
  715. BX('dev_table').innerHTML = result;
  716. CloseWaitWindow();
  717. };
  718. CHttpRequest.Send('perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=monitor&action=stop');
  719. }
  720. function ShowBitrix()
  721. {
  722. tabControl.SelectTab('bitrix');
  723. setTimeout("ShowDev()", 1500);
  724. }
  725. function ShowDev()
  726. {
  727. tabControl.SelectTab('dev');
  728. CHttpRequest.Action = function(result)
  729. {
  730. BX('dev_table').innerHTML = result;
  731. };
  732. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=monitor';
  733. if(duration > 0)
  734. {
  735. url += '&duration='+duration;
  736. duration = 0;
  737. }
  738. ShowWaitWindow();
  739. CHttpRequest.Send(url);
  740. }
  741. function MeasureAll()
  742. {
  743. setTimeout("CPUMeasure()", 200);
  744. }
  745. function PageRate()
  746. {
  747. CHttpRequest.Action = function(result)
  748. {
  749. BX('page_rate_result_hidden').innerHTML = result;
  750. if(page_rate_count > 0)
  751. {
  752. setTimeout("PageRate()", 200);
  753. }
  754. else
  755. {
  756. CloseWaitWindow();
  757. <?if(COption::GetOptionString("perfmon", "total_mark_value") == "measure" && !CPerfomanceKeeper::IsActive()):?>
  758. setTimeout("ShowBitrix()", 1500);
  759. <?endif?>
  760. }
  761. };
  762. if(page_rate_count == 10)
  763. {
  764. ShowWaitWindow();
  765. BX('page_rate_result').innerHTML = '<b><?echo GetMessage("PERFMON_PANEL_MEASURE")?></b>'
  766. }
  767. page_rate_count--;
  768. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=Y';
  769. if(page_rate_count == 0)
  770. url += '&last=Y';
  771. CHttpRequest.Send(url);
  772. }
  773. function CPUMeasure()
  774. {
  775. CHttpRequest.Action = function(result)
  776. {
  777. CloseWaitWindow();
  778. BX('mark_php_cpu_value_result').innerHTML = result;
  779. setTimeout("FilesMeasure()", 200);
  780. };
  781. ShowWaitWindow();
  782. BX('mark_php_cpu_value_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  783. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=cpu';
  784. CHttpRequest.Send(url);
  785. }
  786. function FilesMeasure()
  787. {
  788. CHttpRequest.Action = function(result)
  789. {
  790. CloseWaitWindow();
  791. BX('mark_php_files_value_result').innerHTML = result;
  792. setTimeout("MailMeasure()", 200);
  793. };
  794. ShowWaitWindow();
  795. BX('mark_php_files_value_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  796. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=files';
  797. CHttpRequest.Send(url);
  798. }
  799. function MailMeasure()
  800. {
  801. CHttpRequest.Action = function(result)
  802. {
  803. CloseWaitWindow();
  804. BX('mark_php_mail_value_result').innerHTML = result;
  805. setTimeout("SessionMeasure()", 200);
  806. };
  807. ShowWaitWindow();
  808. BX('mark_php_mail_value_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  809. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=mail';
  810. CHttpRequest.Send(url);
  811. }
  812. function SessionMeasure()
  813. {
  814. CHttpRequest.Action = function(result)
  815. {
  816. BX('session_time_result_hidden').innerHTML = result;
  817. if(session_count > 0)
  818. setTimeout("SessionMeasure()", 200);
  819. else
  820. {
  821. CloseWaitWindow();
  822. setTimeout("PHPMeasure()", 200);
  823. }
  824. };
  825. if(session_count == 10)
  826. {
  827. ShowWaitWindow();
  828. BX('session_time_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>'
  829. }
  830. session_count--;
  831. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=session';
  832. if(session_count == 0)
  833. url += '&last=Y';
  834. CHttpRequest.Send(url);
  835. }
  836. function PHPMeasure()
  837. {
  838. CHttpRequest.Action = function(result)
  839. {
  840. CloseWaitWindow();
  841. BX('mark_php_is_good_result').innerHTML = result;
  842. setTimeout("DBInsertMeasure()", 200);
  843. };
  844. ShowWaitWindow();
  845. BX('mark_php_is_good_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  846. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=php';
  847. CHttpRequest.Send(url);
  848. }
  849. function DBInsertMeasure()
  850. {
  851. CHttpRequest.Action = function(result)
  852. {
  853. CloseWaitWindow();
  854. BX('mark_db_insert_value_result').innerHTML = result;
  855. setTimeout("DBReadMeasure()", 200);
  856. };
  857. ShowWaitWindow();
  858. BX('mark_db_insert_value_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  859. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=db_insert';
  860. CHttpRequest.Send(url);
  861. }
  862. function DBReadMeasure()
  863. {
  864. CHttpRequest.Action = function(result)
  865. {
  866. CloseWaitWindow();
  867. BX('mark_db_read_value_result').innerHTML = result;
  868. setTimeout("DBUpdateMeasure()", 200);
  869. };
  870. ShowWaitWindow();
  871. BX('mark_db_read_value_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  872. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=db_read';
  873. CHttpRequest.Send(url);
  874. }
  875. function DBUpdateMeasure()
  876. {
  877. CHttpRequest.Action = function(result)
  878. {
  879. CloseWaitWindow();
  880. BX('mark_db_update_value_result').innerHTML = result;
  881. setTimeout("PageRate()", 200);
  882. };
  883. ShowWaitWindow();
  884. BX('mark_db_update_value_result').innerHTML = '<?echo GetMessage("PERFMON_PANEL_MEASURE")?>';
  885. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=db_update';
  886. CHttpRequest.Send(url);
  887. }
  888. var threads_running = false;
  889. function ThreadsStop()
  890. {
  891. var measure_message = BX('measure_message');
  892. if(measure_message)
  893. measure_message.innerHTML = '<?echo GetMessage("PERFMON_PANEL_CLUSTER_STOPPED")?>';
  894. var threads_button = BX('threads_button');
  895. threads_button.value = '<?echo GetMessage("PERFMON_PANEL_CLUSTER_START")?>';
  896. threads_button.disabled = false;
  897. BX('threads_from').disabled = false;
  898. BX('threads_to').disabled = false;
  899. BX('threads_step').disabled = false;
  900. BX('server_name').disabled = false;
  901. BX('server_url').disabled = false;
  902. BX('threads_duration').disabled = false;
  903. threads_running = false;
  904. CloseWaitWindow();
  905. }
  906. function ThreadsTest(threads)
  907. {
  908. var url = 'perfmon_panel.php?lang=<?echo LANGUAGE_ID?>&<?echo bitrix_sessid_get()?>&test=cluster';
  909. url += '&threads_from=' + parseInt(BX('threads_from').value);
  910. url += '&threads_to=' + parseInt(BX('threads_to').value);
  911. url += '&threads_step=' + parseInt(BX('threads_step').value);
  912. url += '&server_name=' + BX('server_name').value;
  913. url += '&server_url=' + BX.util.urlencode(BX('server_url').value);
  914. url += '&threads_duration=' + parseInt(BX('threads_duration').value);
  915. if(threads)
  916. {
  917. url += '&threads='+threads;
  918. }
  919. else
  920. {
  921. var threads_button = BX('threads_button');
  922. if(!threads_running)
  923. {
  924. ShowWaitWindow();
  925. threads_running = true;
  926. threads_button.value = '<?echo GetMessage("PERFMON_PANEL_CLUSTER_STOP")?>';
  927. BX('threads_from').disabled = true;
  928. BX('threads_to').disabled = true;
  929. BX('threads_step').disabled = true;
  930. BX('server_name').disabled = true;
  931. BX('server_url').disabled = true;
  932. BX('threads_duration').disabled = true;
  933. }
  934. else
  935. {
  936. threads_running = false;
  937. threads_button.value = '<?echo GetMessage("PERFMON_PANEL_CLUSTER_WAIT")?>';
  938. threads_button.disabled = true;
  939. }
  940. }
  941. if(threads_running)
  942. {
  943. CHttpRequest.Action = function(result)
  944. {
  945. BX('threads_result').innerHTML = result;
  946. if(!threads_running)
  947. ThreadsStop();
  948. };
  949. CHttpRequest.Send(url);
  950. }
  951. }
  952. function ThreadsUpdateImage(id, threads_from, threads_to)
  953. {
  954. var img = BX.findChild(BX(id), {'tag':'IMG'},true);
  955. if(img)
  956. {
  957. var src = img.src;
  958. src = src.replace(/rand=.*?&/, 'rand=' + Math.random() + '&');
  959. if(src.search('&threads_from=') == -1)
  960. src += '&threads_from=' + threads_from;
  961. else
  962. src = src.replace(/&threads_from=[0-9]+/, '&threads_from=' + threads_from);
  963. if(src.search('&threads_to=') == -1)
  964. src += '&threads_to=' + threads_to;
  965. else
  966. src = src.replace(/&threads_to=[0-9]+/, '&threads_to=' + threads_to);
  967. img.src = src;
  968. img.style.display = 'block';
  969. }
  970. }
  971. </script>
  972. <?echo BeginNote()?>
  973. <form method="POST" Action="<?echo $APPLICATION->GetCurPage()?>" ENCTYPE="multipart/form-data" name="post_form1">
  974. <p id="mark_result_in_note" style="font-size:200%"><b>
  975. <?
  976. $mark_value = COption::GetOptionString("perfmon", "mark_php_page_rate", "");
  977. if($mark_value == "" || $mark_value == "measure")
  978. echo GetMessage("PERFMON_PANEL_MARK_NO_RESULT");
  979. else
  980. echo GetMessage("PERFMON_PANEL_MARK_RESULT", array("#result#" => $mark_value))."<span class=\"required\"><sup>1</sup></span>";
  981. ?>
  982. </b></p>
  983. <p>
  984. <?echo bitrix_sessid_post();?>
  985. <input type="hidden" name="lang" value="<?echo LANGUAGE_ID?>">
  986. <input type="submit" name="total_calc" value="<?echo GetMessage("PERFMON_PANEL_BTN_START")?>" <?if($RIGHT < "W") echo "disabled"?>>
  987. &nbsp;<select name="total_duration">
  988. <?
  989. $total_duration = COption::GetOptionInt("perfmon", "total_mark_duration");
  990. if($total_duration <= 0) $total_duration = 300;
  991. ?>
  992. <option value="60" <?if($total_duration==60) echo "selected"?>><?echo GetMessage("PERFMON_PANEL_INTERVAL_60_SEC")?></option>
  993. <option value="300" <?if($total_duration==300) echo "selected"?>><?echo GetMessage("PERFMON_PANEL_INTERVAL_300_SEC")?></option>
  994. <option value="600" <?if($total_duration==600) echo "selected"?>><?echo GetMessage("PERFMON_PANEL_INTERVAL_600_SEC")?></option>
  995. <option value="1800" <?if($total_duration==1800) echo "selected"?>><?echo GetMessage("PERFMON_PANEL_INTERVAL_1800_SEC")?></option>
  996. <option value="3600" <?if($total_duration==3600) echo "selected"?>><?echo GetMessage("PERFMON_PANEL_INTERVAL_3600_SEC")?></option>
  997. </select>
  998. </p>
  999. <?echo GetMessage("PERFMON_PANEL_TOP_NOTE");?>
  1000. </form>
  1001. <?echo EndNote()?>
  1002. <form method="POST" Action="<?echo $APPLICATION->GetCurPage()?>" ENCTYPE="multipart/form-data" name="post_form">
  1003. <?$tabControl->Begin();?>
  1004. <?$tabControl->BeginNextTab();?>
  1005. <tr>
  1006. <td>
  1007. <table border="0" cellpadding="0" cellspacing="0" class="internal" width="100%">
  1008. <tr class="heading">
  1009. <td width="20%" align="center"><?echo GetMessage("PERFMON_PANEL_PERF_PARAMETER")?></td>
  1010. <td width="20%" align="center"><?echo GetMessage("PERFMON_PANEL_PERF_SCORE")?></td>
  1011. <td width="20%" align="center"><?echo GetMessage("PERFMON_PANEL_PERF_SAMPLE")?></td>
  1012. <td width="40%" align="center"><?echo GetMessage("PERFMON_PANEL_PERF_VALUE")?></td>
  1013. </tr>
  1014. <?
  1015. $mark_value = COption::GetOptionString("perfmon", "mark_php_page_rate", "");
  1016. ?>
  1017. <tr>
  1018. <td nowrap><?echo GetMessage("PERFMON_PANEL_PAGE_RATE")?></td>
  1019. <?if($mark_value == "measure"):?>
  1020. <td class="bx-digit-cell"><b>
  1021. <script>setTimeout('MeasureAll();', 500);</script>
  1022. <div id="page_rate_result_hidden" style="display:none"></div>
  1023. <div id="page_rate_result"><?echo GetMessage("PERFMON_PANEL_MEASURE")?></div>
  1024. </b></td>
  1025. <?elseif($mark_value <> ''):?>
  1026. <td class="bx-digit-cell"><b><?echo $mark_value?></b></td>
  1027. <?else:?>
  1028. <td class="bx-digit-cell"><b><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></b></td>
  1029. <?endif?>
  1030. <td class="bx-digit-cell">30</td>
  1031. <td>&nbsp;</td>
  1032. </tr>
  1033. <?
  1034. $mark_value = COption::GetOptionString("perfmon", "mark_php_page_time", "");
  1035. ?>
  1036. <tr>
  1037. <td nowrap><?echo GetMessage("PERFMON_PANEL_PAGE_TIME")?></td>
  1038. <?if($mark_value == "measure"):?>
  1039. <td class="bx-digit-cell" id="page_time_result"><?echo GetMessage("PERFMON_PANEL_MEASURE")?></td>
  1040. <?elseif($mark_value <> ''):?>
  1041. <td class="bx-digit-cell" id="page_time_result"><?echo $mark_value?></td>
  1042. <?else:?>
  1043. <td class="bx-digit-cell" id="page_time_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1044. <?endif?>
  1045. <td class="bx-digit-cell">0.0330</td>
  1046. <td><?echo GetMessage("PERFMON_PANEL_PAGE_TIME_UNITS")?></td>
  1047. </tr>
  1048. <?
  1049. $mark_value = COption::GetOptionString("perfmon", "mark_php_cpu_value", "");
  1050. ?>
  1051. <tr>
  1052. <td nowrap><?echo GetMessage("PERFMON_PANEL_CPU")?></td>
  1053. <?if($mark_value <> ''):?>
  1054. <td class="bx-digit-cell" id="mark_php_cpu_value_result"><?echo $mark_value?></td>
  1055. <?else:?>
  1056. <td class="bx-digit-cell" id="mark_php_cpu_value_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1057. <?endif?>
  1058. <td class="bx-digit-cell">9.0</td>
  1059. <td><?echo GetMessage("PERFMON_PANEL_CPU_UNITS")?></td>
  1060. </tr>
  1061. <?
  1062. $mark_value = COption::GetOptionString("perfmon", "mark_php_files_value", "");
  1063. ?>
  1064. <tr>
  1065. <td nowrap><?echo GetMessage("PERFMON_PANEL_FILES")?></td>
  1066. <?if($mark_value <> ''):?>
  1067. <td class="bx-digit-cell" id="mark_php_files_value_result"><?echo $mark_value?></td>
  1068. <?else:?>
  1069. <td class="bx-digit-cell" id="mark_php_files_value_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1070. <?endif?>
  1071. <td class="bx-digit-cell">10 000</td>
  1072. <td><?echo GetMessage("PERFMON_PANEL_FILES_UNITS")?></td>
  1073. </tr>
  1074. <?
  1075. $mark_value = COption::GetOptionString("perfmon", "mark_php_mail_value", "");
  1076. ?>
  1077. <tr>
  1078. <td nowrap><?echo GetMessage("PERFMON_PANEL_MAIL")?></td>
  1079. <?if($mark_value <> ''):?>
  1080. <td class="bx-digit-cell" id="mark_php_mail_value_result"><?echo $mark_value?></td>
  1081. <?else:?>
  1082. <td class="bx-digit-cell" id="mark_php_mail_value_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1083. <?endif?>
  1084. <td class="bx-digit-cell">0.0100</td>
  1085. <td><?echo GetMessage("PERFMON_PANEL_MAIL_UNITS")?></td>
  1086. </tr>
  1087. <?
  1088. $mark_value = COption::GetOptionString("perfmon", "mark_php_session_time_value", "");
  1089. ?>
  1090. <tr>
  1091. <td nowrap><?echo GetMessage("PERFMON_PANEL_SESSION")?><div id="session_time_result_hidden" style="display:none"></div></td>
  1092. <?if($mark_value == -1):?>
  1093. <td class="bx-digit-cell" id="session_time_result"><?echo GetMessage("PERFMON_PANEL_SESSION_ERR")?></td>
  1094. <?elseif($mark_value <> ''):?>
  1095. <td class="bx-digit-cell" id="session_time_result"><?echo $mark_value?></td>
  1096. <?else:?>
  1097. <td class="bx-digit-cell" id="session_time_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1098. <?endif?>
  1099. <td class="bx-digit-cell">0.0002</td>
  1100. <td><?echo GetMessage("PERFMON_PANEL_SESSION_UNITS")?></td>
  1101. </tr>
  1102. <?
  1103. $mark_value = COption::GetOptionString("perfmon", "mark_php_is_good", "");
  1104. ?>
  1105. <tr>
  1106. <td nowrap><?echo GetMessage("PERFMON_PANEL_PHP")?></td>
  1107. <?if($mark_value <> ''):?>
  1108. <td class="bx-digit-cell" id="mark_php_is_good_result"><?echo ($mark_value == "N"? "<span class=\"errortext\">".GetMessage("PERFMON_PANEL_MARK_PHP_IS_NO_GOOD")."</span>": GetMessage("PERFMON_PANEL_MARK_PHP_IS_GOOD"))?></td>
  1109. <?else:?>
  1110. <td class="bx-digit-cell" id="mark_php_is_good_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1111. <?endif?>
  1112. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_MARK_PHP_IS_GOOD")?></td>
  1113. <td><a href="perfmon_php.php?lang=<?echo LANGUAGE_ID?>"><?echo GetMessage("PERFMON_PANEL_PHP_REC")?></a></td>
  1114. </tr>
  1115. <?
  1116. if($DB->type == "MYSQL")
  1117. $db_type = "MySQL";
  1118. elseif($DB->type == "ORACLE")
  1119. $db_type = "Oracle";
  1120. else
  1121. $db_type = "MS SQL";
  1122. $mark_value = COption::GetOptionString("perfmon", "mark_db_insert_value", "");
  1123. ?>
  1124. <tr>
  1125. <td nowrap><?echo GetMessage("PERFMON_PANEL_MARK_DB_INSERT_VALUE", array("#database_type#" => $db_type))?></td>
  1126. <?if($mark_value <> ''):?>
  1127. <td class="bx-digit-cell" id="mark_db_insert_value_result"><?echo $mark_value?></td>
  1128. <?else:?>
  1129. <td class="bx-digit-cell" id="mark_db_insert_value_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1130. <?endif?>
  1131. <td class="bx-digit-cell">5 600</td>
  1132. <td><?echo GetMessage("PERFMON_PANEL_MARK_DB_INSERT_UNITS")?></td>
  1133. </tr>
  1134. <?
  1135. $mark_value = COption::GetOptionString("perfmon", "mark_db_read_value", "");
  1136. ?>
  1137. <tr>
  1138. <td nowrap><?echo GetMessage("PERFMON_PANEL_MARK_DB_READ_VALUE", array("#database_type#" => $db_type))?></td>
  1139. <?if($mark_value <> ''):?>
  1140. <td class="bx-digit-cell" id="mark_db_read_value_result"><?echo $mark_value?></td>
  1141. <?else:?>
  1142. <td class="bx-digit-cell" id="mark_db_read_value_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1143. <?endif?>
  1144. <td class="bx-digit-cell">7 800</td>
  1145. <td><?echo GetMessage("PERFMON_PANEL_MARK_DB_READ_UNITS")?></td>
  1146. </tr>
  1147. <?
  1148. $mark_value = COption::GetOptionString("perfmon", "mark_db_update_value", "");
  1149. ?>
  1150. <tr>
  1151. <td nowrap><?echo GetMessage("PERFMON_PANEL_MARK_DB_UPDATE_VALUE", array("#database_type#" => $db_type))?></td>
  1152. <?if($mark_value <> ''):?>
  1153. <td class="bx-digit-cell" id="mark_db_update_value_result"><?echo $mark_value?></td>
  1154. <?else:?>
  1155. <td class="bx-digit-cell" id="mark_db_update_value_result"><?echo GetMessage("PERFMON_PANEL_UNKNOWN")?></td>
  1156. <?endif?>
  1157. <td class="bx-digit-cell">5 800</td>
  1158. <td><?echo GetMessage("PERFMON_PANEL_MARK_DB_UPDATE_UNITS")?></td>
  1159. </tr>
  1160. </table>
  1161. </td>
  1162. </tr>
  1163. <tr>
  1164. <td>
  1165. <br>
  1166. <?echo bitrix_sessid_post();?>
  1167. <input type="hidden" name="lang" value="<?echo LANGUAGE_ID?>">
  1168. <input type="submit" name="calc" id="calc" value="<?echo GetMessage("PERFMON_PANEL_BTN_TEST")?>" <?if($RIGHT < "W" || COption::GetOptionString("perfmon", "total_mark_value") == "measure") echo "disabled"?> class="adm-btn-save">
  1169. </td>
  1170. </tr>
  1171. <?$tabControl->BeginNextTab();?>
  1172. <tr>
  1173. <td>
  1174. <table border="0" cellpadding="0" cellspacing="0" class="internal" width="100%">
  1175. <tr class="heading">
  1176. <td width="40%" align="center"><?echo GetMessage("PERFMON_PANEL_BITRIX_PARAMETER")?></td>
  1177. <td width="30%" align="center"><?echo GetMessage("PERFMON_PANEL_BITRIX_VALUE")?></td>
  1178. <td width="30%" align="center"><?echo GetMessage("PERFMON_PANEL_BITRIX_RECOMMENDATION")?></td>
  1179. </tr>
  1180. <tr>
  1181. <td nowrap><?echo GetMessage("PERFMON_PANEL_COMPONENT_CACHE")?></td>
  1182. <?if($bComponentCache):?>
  1183. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_COMPONENT_CACHE_ON")?></td>
  1184. <td>&nbsp;</td>
  1185. <?else:?>
  1186. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_COMPONENT_CACHE_OFF")?></td>
  1187. <td><a href="cache.php?lang=<?echo LANGUAGE_ID?>"><?echo GetMessage("PERFMON_PANEL_COMPONENT_CACHE_REC")?></a></td>
  1188. <?endif?>
  1189. </tr>
  1190. <?if(IsModuleInstalled('statistic')):?>
  1191. <tr>
  1192. <td nowrap><?echo GetMessage("PERFMON_PANEL_STAT_SAVE_PATH")?></td>
  1193. <?if($statistic_path):?>
  1194. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_STAT_SAVE_PATH_ON")?></td>
  1195. <td><a href="settings.php?lang=<?echo LANGUAGE_ID?>&amp;mid=statistic&amp;tabControl_active_tab=edit2&amp;back_url_settings=<?echo urlencode($APPLICATION->GetCurPageParam("tabControl_active_tab=bitrix", array("tabControl_active_tab")))?>"><?echo GetMessage("PERFMON_PANEL_STAT_SAVE_PATH_REC")?></a></td>
  1196. <?else:?>
  1197. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_STAT_SAVE_PATH_OFF")?></td>
  1198. <td>&nbsp;</td>
  1199. <?endif?>
  1200. </tr>
  1201. <?endif?>
  1202. <?if(IsModuleInstalled('advertising')):?>
  1203. <tr>
  1204. <td nowrap><?echo GetMessage("PERFMON_PANEL_ADV_BANNERS_FIX_SHOWS")?></td>
  1205. <?if($adv_banners_fix_shows):?>
  1206. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_ADV_BANNERS_FIX_SHOWS_ON")?></td>
  1207. <td><a href="settings.php?lang=<?echo LANGUAGE_ID?>&amp;mid=advertising&amp;back_url_settings=<?echo urlencode($APPLICATION->GetCurPageParam("tabControl_active_tab=bitrix", array("tabControl_active_tab")))?>"><?echo GetMessage("PERFMON_PANEL_ADV_BANNERS_FIX_SHOWS_REC")?></a></td>
  1208. <?else:?>
  1209. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_ADV_BANNERS_FIX_SHOWS_OFF")?></td>
  1210. <td>&nbsp;</td>
  1211. <?endif?>
  1212. </tr>
  1213. <?endif?>
  1214. <?if(IsModuleInstalled('search')):?>
  1215. <tr>
  1216. <td nowrap><?echo GetMessage("PERFMON_PANEL_SEARCH_STEM")?></td>
  1217. <?if($search_is_ok):?>
  1218. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_SEARCH_STEM_ON")?></td>
  1219. <td>&nbsp;</td>
  1220. <?else:?>
  1221. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_SEARCH_STEM_OFF")?></td>
  1222. <td><a href="settings.php?lang=<?echo LANGUAGE_ID?>&amp;mid=search&amp;back_url_settings=<?echo urlencode($APPLICATION->GetCurPageParam("tabControl_active_tab=bitrix", array("tabControl_active_tab")))?>"><?echo GetMessage("PERFMON_PANEL_SEARCH_STEM_REC")?></a></td>
  1223. <?endif?>
  1224. </tr>
  1225. <?endif?>
  1226. <tr>
  1227. <td nowrap><?echo GetMessage("PERFMON_PANEL_CACHE_STORAGE")?></td>
  1228. <?
  1229. $cache_type = GetMessage("PERFMON_PANEL_CACHE_STORAGE_UNKNOWN");
  1230. switch(\Bitrix\Main\Data\Cache::getCacheEngineType())
  1231. {
  1232. case "cacheenginememcache":
  1233. $cache_type = GetMessage("PERFMON_PANEL_CACHE_STORAGE_MEMCACHE");
  1234. break;
  1235. case "cacheengineapc":
  1236. $cache_type = GetMessage("PERFMON_PANEL_CACHE_STORAGE_APC");
  1237. break;
  1238. case "cacheenginexcache":
  1239. $cache_type = GetMessage("PERFMON_PANEL_CACHE_STORAGE_XCACHE");
  1240. break;
  1241. case "cacheenginefiles":
  1242. $cache_type = GetMessage("PERFMON_PANEL_CACHE_STORAGE_FILES");
  1243. break;
  1244. case "cacheenginememcachecluster":
  1245. $cache_type = GetMessage("PERFMON_PANEL_CACHE_STORAGE_CLUSTER");
  1246. break;
  1247. default:
  1248. $cache_type = \Bitrix\Main\Data\Cache::getCacheEngineType();
  1249. break;
  1250. }
  1251. ?>
  1252. <td class="bx-digit-cell"><?echo $cache_type?></td>
  1253. <td><?echo GetMessage("PERFMON_PANEL_CACHE_STORAGE_REC");?></td>
  1254. </tr>
  1255. <tr>
  1256. <td nowrap><?echo GetMessage("PERFMON_PANEL_MANAGED_CACHE")?></td>
  1257. <?if($bManagedCache):?>
  1258. <td class="bx-digit-cell"><?echo GetMessage("PERFMON_PANEL_MANAGED_CACHE_ON")?></td>
  1259. <td>&nbsp;</td>
  1260. <?else:?>
  1261. <td class="bx-digit-cell"><a href="javascript:void()" OnClick="BX('managed_cache_details').style.display='block';return false;"><?echo GetMessage("PERFMON_PANEL_MANAGED_CACHE_OFF")?></a><div id="managed_cache_details" style="display:none"><?echo implode("<br>", $arConstants)?></div></td>
  1262. <td><?echo GetMessage("PERFMON_PANEL_MANAGED_CACHE_REC", array(
  1263. "#file#" => (
  1264. IsModuleInstalled('fileman') && ($USER->CanDoOperation('fileman_admin_files') || $USER->CanDoOperation('fileman_edit_existent_files'))?
  1265. "<a href=\"".'/bitrix/admin/fileman_file_edit.php?lang='.LANGUAGE_ID.'&amp;full_src=Y&amp;path='.urlencode(BX_PERSONAL_ROOT.'/php_interface/dbconn.php').'&amp;back_url='.urlencode('/bitrix/admin/security_panel.php?lang='.LANGUAGE_ID)."\">dbconn.php</a>":
  1266. "dbconn.php"
  1267. ),
  1268. ));?>
  1269. </td>
  1270. <?en