PageRenderTime 65ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/phpMyAdmin/server_status.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 1839 lines | 1492 code | 199 blank | 148 comment | 154 complexity | 569a132693423f59bb3510be9c382590 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * displays status variables with descriptions and some hints an optmizing
  5. * + reset status variables
  6. *
  7. * @package PhpMyAdmin
  8. */
  9. /**
  10. * no need for variables importing
  11. * @ignore
  12. */
  13. if (! defined('PMA_NO_VARIABLES_IMPORT')) {
  14. define('PMA_NO_VARIABLES_IMPORT', true);
  15. }
  16. if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
  17. $GLOBALS['is_header_sent'] = true;
  18. }
  19. require_once './libraries/common.inc.php';
  20. /**
  21. * Ajax request
  22. */
  23. if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
  24. // Send with correct charset
  25. header('Content-Type: text/html; charset=UTF-8');
  26. // real-time charting data
  27. if (isset($_REQUEST['chart_data'])) {
  28. switch($_REQUEST['type']) {
  29. // Process and Connections realtime chart
  30. case 'proc':
  31. $c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
  32. $result = PMA_DBI_query('SHOW PROCESSLIST');
  33. $num_procs = PMA_DBI_num_rows($result);
  34. $ret = array(
  35. 'x' => microtime(true) * 1000,
  36. 'y_proc' => $num_procs,
  37. 'y_conn' => $c['Connections']
  38. );
  39. exit(json_encode($ret));
  40. // Query realtime chart
  41. case 'queries':
  42. if (PMA_DRIZZLE) {
  43. $sql = "SELECT concat('Com_', variable_name), variable_value
  44. FROM data_dictionary.GLOBAL_STATEMENTS
  45. WHERE variable_value > 0
  46. UNION
  47. SELECT variable_name, variable_value
  48. FROM data_dictionary.GLOBAL_STATUS
  49. WHERE variable_name = 'Questions'";
  50. $queries = PMA_DBI_fetch_result($sql, 0, 1);
  51. } else {
  52. $queries = PMA_DBI_fetch_result(
  53. "SHOW GLOBAL STATUS
  54. WHERE (Variable_name LIKE 'Com_%' OR Variable_name = 'Questions')
  55. AND Value > 0", 0, 1
  56. );
  57. }
  58. cleanDeprecated($queries);
  59. // admin commands are not queries
  60. unset($queries['Com_admin_commands']);
  61. $questions = $queries['Questions'];
  62. unset($queries['Questions']);
  63. //$sum=array_sum($queries);
  64. $ret = array(
  65. 'x' => microtime(true) * 1000,
  66. 'y' => $questions,
  67. 'pointInfo' => $queries
  68. );
  69. exit(json_encode($ret));
  70. // Traffic realtime chart
  71. case 'traffic':
  72. $traffic = PMA_DBI_fetch_result(
  73. "SHOW GLOBAL STATUS
  74. WHERE Variable_name = 'Bytes_received'
  75. OR Variable_name = 'Bytes_sent'", 0, 1
  76. );
  77. $ret = array(
  78. 'x' => microtime(true) * 1000,
  79. 'y_sent' => $traffic['Bytes_sent'],
  80. 'y_received' => $traffic['Bytes_received']
  81. );
  82. exit(json_encode($ret));
  83. // Data for the monitor
  84. case 'chartgrid':
  85. $ret = json_decode($_REQUEST['requiredData'], true);
  86. $statusVars = array();
  87. $serverVars = array();
  88. $sysinfo = $cpuload = $memory = 0;
  89. $pName = '';
  90. /* Accumulate all required variables and data */
  91. // For each chart
  92. foreach ($ret as $chart_id => $chartNodes) {
  93. // For each data series
  94. foreach ($chartNodes as $node_id => $nodeDataPoints) {
  95. // For each data point in the series (usually just 1)
  96. foreach ($nodeDataPoints as $point_id => $dataPoint) {
  97. $pName = $dataPoint['name'];
  98. switch ($dataPoint['type']) {
  99. /* We only collect the status and server variables here to
  100. * read them all in one query, and only afterwards assign them.
  101. * Also do some white list filtering on the names
  102. */
  103. case 'servervar':
  104. if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
  105. $serverVars[] = $pName;
  106. }
  107. break;
  108. case 'statusvar':
  109. if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
  110. $statusVars[] = $pName;
  111. }
  112. break;
  113. case 'proc':
  114. $result = PMA_DBI_query('SHOW PROCESSLIST');
  115. $ret[$chart_id][$node_id][$point_id]['value'] = PMA_DBI_num_rows($result);
  116. break;
  117. case 'cpu':
  118. if (!$sysinfo) {
  119. include_once 'libraries/sysinfo.lib.php';
  120. $sysinfo = PMA_getSysInfo();
  121. }
  122. if (!$cpuload) {
  123. $cpuload = $sysinfo->loadavg();
  124. }
  125. if (PMA_getSysInfoOs() == 'Linux') {
  126. $ret[$chart_id][$node_id][$point_id]['idle'] = $cpuload['idle'];
  127. $ret[$chart_id][$node_id][$point_id]['busy'] = $cpuload['busy'];
  128. } else
  129. $ret[$chart_id][$node_id][$point_id]['value'] = $cpuload['loadavg'];
  130. break;
  131. case 'memory':
  132. if (!$sysinfo) {
  133. include_once 'libraries/sysinfo.lib.php';
  134. $sysinfo = PMA_getSysInfo();
  135. }
  136. if (!$memory) {
  137. $memory = $sysinfo->memory();
  138. }
  139. $ret[$chart_id][$node_id][$point_id]['value'] = $memory[$pName];
  140. break;
  141. } /* switch */
  142. } /* foreach */
  143. } /* foreach */
  144. } /* foreach */
  145. // Retrieve all required status variables
  146. if (count($statusVars)) {
  147. $statusVarValues = PMA_DBI_fetch_result(
  148. "SHOW GLOBAL STATUS
  149. WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1
  150. );
  151. } else {
  152. $statusVarValues = array();
  153. }
  154. // Retrieve all required server variables
  155. if (count($serverVars)) {
  156. $serverVarValues = PMA_DBI_fetch_result(
  157. "SHOW GLOBAL VARIABLES
  158. WHERE Variable_name='" . implode("' OR Variable_name='", $serverVars) . "'", 0, 1
  159. );
  160. } else {
  161. $serverVarValues = array();
  162. }
  163. // ...and now assign them
  164. foreach ($ret as $chart_id => $chartNodes) {
  165. foreach ($chartNodes as $node_id => $nodeDataPoints) {
  166. foreach ($nodeDataPoints as $point_id => $dataPoint) {
  167. switch($dataPoint['type']) {
  168. case 'statusvar':
  169. $ret[$chart_id][$node_id][$point_id]['value'] = $statusVarValues[$dataPoint['name']];
  170. break;
  171. case 'servervar':
  172. $ret[$chart_id][$node_id][$point_id]['value'] = $serverVarValues[$dataPoint['name']];
  173. break;
  174. }
  175. }
  176. }
  177. }
  178. $ret['x'] = microtime(true) * 1000;
  179. exit(json_encode($ret));
  180. }
  181. }
  182. if (isset($_REQUEST['log_data'])) {
  183. if (PMA_MYSQL_INT_VERSION < 50106) {
  184. /* FIXME: why this? */
  185. exit('""');
  186. }
  187. $start = intval($_REQUEST['time_start']);
  188. $end = intval($_REQUEST['time_end']);
  189. if ($_REQUEST['type'] == 'slow') {
  190. $q = 'SELECT start_time, user_host, Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, '.
  191. 'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, db, sql_text, COUNT(sql_text) AS \'#\' '.
  192. 'FROM `mysql`.`slow_log` WHERE start_time > FROM_UNIXTIME(' . $start . ') '.
  193. 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
  194. $result = PMA_DBI_try_query($q);
  195. $return = array('rows' => array(), 'sum' => array());
  196. $type = '';
  197. while ($row = PMA_DBI_fetch_assoc($result)) {
  198. $type = strtolower(substr($row['sql_text'], 0, strpos($row['sql_text'], ' ')));
  199. switch($type) {
  200. case 'insert':
  201. case 'update':
  202. // Cut off big inserts and updates, but append byte count therefor
  203. if (strlen($row['sql_text']) > 220) {
  204. $row['sql_text'] = substr($row['sql_text'], 0, 200)
  205. . '... ['
  206. . implode(' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2))
  207. . ']';
  208. }
  209. break;
  210. default:
  211. break;
  212. }
  213. if (!isset($return['sum'][$type])) {
  214. $return['sum'][$type] = 0;
  215. }
  216. $return['sum'][$type] += $row['#'];
  217. $return['rows'][] = $row;
  218. }
  219. $return['sum']['TOTAL'] = array_sum($return['sum']);
  220. $return['numRows'] = count($return['rows']);
  221. PMA_DBI_free_result($result);
  222. exit(json_encode($return));
  223. }
  224. if ($_REQUEST['type'] == 'general') {
  225. $limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
  226. ? 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
  227. $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' '.
  228. 'FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
  229. 'AND event_time > FROM_UNIXTIME(' . $start . ') AND event_time < FROM_UNIXTIME(' . $end . ') '.
  230. $limitTypes . 'GROUP by argument'; // HAVING count > 1';
  231. $result = PMA_DBI_try_query($q);
  232. $return = array('rows' => array(), 'sum' => array());
  233. $type = '';
  234. $insertTables = array();
  235. $insertTablesFirst = -1;
  236. $i = 0;
  237. $removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
  238. while ($row = PMA_DBI_fetch_assoc($result)) {
  239. preg_match('/^(\w+)\s/', $row['argument'], $match);
  240. $type = strtolower($match[1]);
  241. if (!isset($return['sum'][$type])) {
  242. $return['sum'][$type] = 0;
  243. }
  244. $return['sum'][$type] += $row['#'];
  245. switch($type) {
  246. case 'insert':
  247. // Group inserts if selected
  248. if ($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i', $row['argument'], $matches)) {
  249. $insertTables[$matches[2]]++;
  250. if ($insertTables[$matches[2]] > 1) {
  251. $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
  252. // Add a ... to the end of this query to indicate that there's been other queries
  253. if ($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.') {
  254. $return['rows'][$insertTablesFirst]['argument'] .= '<br/>...';
  255. }
  256. // Group this value, thus do not add to the result list
  257. continue 2;
  258. } else {
  259. $insertTablesFirst = $i;
  260. $insertTables[$matches[2]] += $row['#'] - 1;
  261. }
  262. }
  263. // No break here
  264. case 'update':
  265. // Cut off big inserts and updates, but append byte count therefor
  266. if (strlen($row['argument']) > 220) {
  267. $row['argument'] = substr($row['argument'], 0, 200)
  268. . '... ['
  269. . implode(' ', PMA_formatByteDown(strlen($row['argument'])), 2, 2)
  270. . ']';
  271. }
  272. break;
  273. default:
  274. break;
  275. }
  276. $return['rows'][] = $row;
  277. $i++;
  278. }
  279. $return['sum']['TOTAL'] = array_sum($return['sum']);
  280. $return['numRows'] = count($return['rows']);
  281. PMA_DBI_free_result($result);
  282. exit(json_encode($return));
  283. }
  284. }
  285. if (isset($_REQUEST['logging_vars'])) {
  286. if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
  287. $value = PMA_sqlAddslashes($_REQUEST['varValue']);
  288. if (!is_numeric($value)) {
  289. $value="'" . $value . "'";
  290. }
  291. if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) {
  292. PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value);
  293. }
  294. }
  295. $loggingVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES WHERE Variable_name IN ("general_log","slow_query_log","long_query_time","log_output")', 0, 1);
  296. exit(json_encode($loggingVars));
  297. }
  298. if (isset($_REQUEST['query_analyzer'])) {
  299. $return = array();
  300. if (strlen($_REQUEST['database'])) {
  301. PMA_DBI_select_db($_REQUEST['database']);
  302. }
  303. if ($profiling = PMA_profilingSupported()) {
  304. PMA_DBI_query('SET PROFILING=1;');
  305. }
  306. // Do not cache query
  307. $query = preg_replace('/^(\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query']);
  308. $result = PMA_DBI_try_query($query);
  309. $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
  310. $result = PMA_DBI_try_query('EXPLAIN ' . $query);
  311. while ($row = PMA_DBI_fetch_assoc($result)) {
  312. $return['explain'][] = $row;
  313. }
  314. // In case an error happened
  315. $return['error'] = PMA_DBI_getError();
  316. PMA_DBI_free_result($result);
  317. if ($profiling) {
  318. $return['profiling'] = array();
  319. $result = PMA_DBI_try_query('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=1 ORDER BY seq');
  320. while ($row = PMA_DBI_fetch_assoc($result)) {
  321. $return['profiling'][]= $row;
  322. }
  323. PMA_DBI_free_result($result);
  324. }
  325. exit(json_encode($return));
  326. }
  327. if (isset($_REQUEST['advisor'])) {
  328. include 'libraries/Advisor.class.php';
  329. $advisor = new Advisor();
  330. exit(json_encode($advisor->run()));
  331. }
  332. }
  333. /**
  334. * Replication library
  335. */
  336. if (PMA_DRIZZLE) {
  337. $server_master_status = false;
  338. $server_slave_status = false;
  339. } else {
  340. include_once './libraries/replication.inc.php';
  341. include_once './libraries/replication_gui.lib.php';
  342. }
  343. /**
  344. * JS Includes
  345. */
  346. $GLOBALS['js_include'][] = 'server_status.js';
  347. $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
  348. $GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
  349. $GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
  350. /* < IE 9 doesn't support canvas natively */
  351. if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
  352. $GLOBALS['js_include'][] = 'jqplot/excanvas.js';
  353. }
  354. $GLOBALS['js_include'][] = 'canvg/canvg.js';
  355. // for charting
  356. $GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js';
  357. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.pieRenderer.js';
  358. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasTextRenderer.js';
  359. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js';
  360. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.dateAxisRenderer.js';
  361. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.highlighter.js';
  362. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.cursor.js';
  363. $GLOBALS['js_include'][] = 'date.js';
  364. /**
  365. * flush status variables if requested
  366. */
  367. if (isset($_REQUEST['flush'])) {
  368. $_flush_commands = array(
  369. 'STATUS',
  370. 'TABLES',
  371. 'QUERY CACHE',
  372. );
  373. if (in_array($_REQUEST['flush'], $_flush_commands)) {
  374. PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
  375. }
  376. unset($_flush_commands);
  377. }
  378. /**
  379. * Kills a selected process
  380. */
  381. if (!empty($_REQUEST['kill'])) {
  382. if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
  383. $message = PMA_Message::success(__('Thread %s was successfully killed.'));
  384. } else {
  385. $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
  386. }
  387. $message->addParam($_REQUEST['kill']);
  388. //$message->display();
  389. }
  390. /**
  391. * get status from server
  392. */
  393. $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
  394. if (PMA_DRIZZLE) {
  395. // Drizzle doesn't put query statistics into variables, add it
  396. $sql = "SELECT concat('Com_', variable_name), variable_value
  397. FROM data_dictionary.GLOBAL_STATEMENTS";
  398. $statements = PMA_DBI_fetch_result($sql, 0, 1);
  399. $server_status = array_merge($server_status, $statements);
  400. }
  401. /**
  402. * for some calculations we require also some server settings
  403. */
  404. $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
  405. /**
  406. * cleanup of some deprecated values
  407. */
  408. cleanDeprecated($server_status);
  409. /**
  410. * calculate some values
  411. */
  412. // Key_buffer_fraction
  413. if (isset($server_status['Key_blocks_unused'])
  414. && isset($server_variables['key_cache_block_size'])
  415. && isset($server_variables['key_buffer_size'])
  416. ) {
  417. $server_status['Key_buffer_fraction_%']
  418. = 100
  419. - $server_status['Key_blocks_unused']
  420. * $server_variables['key_cache_block_size']
  421. / $server_variables['key_buffer_size']
  422. * 100;
  423. } elseif (isset($server_status['Key_blocks_used'])
  424. && isset($server_variables['key_buffer_size'])) {
  425. $server_status['Key_buffer_fraction_%']
  426. = $server_status['Key_blocks_used']
  427. * 1024
  428. / $server_variables['key_buffer_size'];
  429. }
  430. // Ratio for key read/write
  431. if (isset($server_status['Key_writes'])
  432. && isset($server_status['Key_write_requests'])
  433. && $server_status['Key_write_requests'] > 0
  434. ) {
  435. $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
  436. }
  437. if (isset($server_status['Key_reads'])
  438. && isset($server_status['Key_read_requests'])
  439. && $server_status['Key_read_requests'] > 0
  440. ) {
  441. $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
  442. }
  443. // Threads_cache_hitrate
  444. if (isset($server_status['Threads_created'])
  445. && isset($server_status['Connections'])
  446. && $server_status['Connections'] > 0
  447. ) {
  448. $server_status['Threads_cache_hitrate_%']
  449. = 100 - $server_status['Threads_created'] / $server_status['Connections'] * 100;
  450. }
  451. /**
  452. * split variables in sections
  453. */
  454. $allocations = array(
  455. // variable name => section
  456. // variable names match when they begin with the given string
  457. 'Com_' => 'com',
  458. 'Innodb_' => 'innodb',
  459. 'Ndb_' => 'ndb',
  460. 'Handler_' => 'handler',
  461. 'Qcache_' => 'qcache',
  462. 'Threads_' => 'threads',
  463. 'Slow_launch_threads' => 'threads',
  464. 'Binlog_cache_' => 'binlog_cache',
  465. 'Created_tmp_' => 'created_tmp',
  466. 'Key_' => 'key',
  467. 'Delayed_' => 'delayed',
  468. 'Not_flushed_delayed_rows' => 'delayed',
  469. 'Flush_commands' => 'query',
  470. 'Last_query_cost' => 'query',
  471. 'Slow_queries' => 'query',
  472. 'Queries' => 'query',
  473. 'Prepared_stmt_count' => 'query',
  474. 'Select_' => 'select',
  475. 'Sort_' => 'sort',
  476. 'Open_tables' => 'table',
  477. 'Opened_tables' => 'table',
  478. 'Open_table_definitions' => 'table',
  479. 'Opened_table_definitions' => 'table',
  480. 'Table_locks_' => 'table',
  481. 'Rpl_status' => 'repl',
  482. 'Slave_' => 'repl',
  483. 'Tc_' => 'tc',
  484. 'Ssl_' => 'ssl',
  485. 'Open_files' => 'files',
  486. 'Open_streams' => 'files',
  487. 'Opened_files' => 'files',
  488. );
  489. $sections = array(
  490. // section => section name (description)
  491. 'com' => 'Com',
  492. 'query' => __('SQL query'),
  493. 'innodb' => 'InnoDB',
  494. 'ndb' => 'NDB',
  495. 'handler' => __('Handler'),
  496. 'qcache' => __('Query cache'),
  497. 'threads' => __('Threads'),
  498. 'binlog_cache' => __('Binary log'),
  499. 'created_tmp' => __('Temporary data'),
  500. 'delayed' => __('Delayed inserts'),
  501. 'key' => __('Key cache'),
  502. 'select' => __('Joins'),
  503. 'repl' => __('Replication'),
  504. 'sort' => __('Sorting'),
  505. 'table' => __('Tables'),
  506. 'tc' => __('Transaction coordinator'),
  507. 'files' => __('Files'),
  508. 'ssl' => 'SSL',
  509. 'other' => __('Other')
  510. );
  511. /**
  512. * define some needfull links/commands
  513. */
  514. // variable or section name => (name => url)
  515. $links = array();
  516. $links['table'][__('Flush (close) all tables')]
  517. = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
  518. $links['table'][__('Show open tables')]
  519. = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
  520. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  521. if ($server_master_status) {
  522. $links['repl'][__('Show slave hosts')]
  523. = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
  524. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  525. $links['repl'][__('Show master status')] = '#replication_master';
  526. }
  527. if ($server_slave_status) {
  528. $links['repl'][__('Show slave status')] = '#replication_slave';
  529. }
  530. $links['repl']['doc'] = 'replication';
  531. $links['qcache'][__('Flush query cache')]
  532. = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
  533. PMA_generate_common_url();
  534. $links['qcache']['doc'] = 'query_cache';
  535. //$links['threads'][__('Show processes')]
  536. // = 'server_processlist.php?' . PMA_generate_common_url();
  537. $links['threads']['doc'] = 'mysql_threads';
  538. $links['key']['doc'] = 'myisam_key_cache';
  539. $links['binlog_cache']['doc'] = 'binary_log';
  540. $links['Slow_queries']['doc'] = 'slow_query_log';
  541. $links['innodb'][__('Variables')]
  542. = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
  543. $links['innodb'][__('InnoDB Status')]
  544. = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
  545. PMA_generate_common_url();
  546. $links['innodb']['doc'] = 'innodb';
  547. // Variable to contain all com_ variables (query statistics)
  548. $used_queries = array();
  549. // Variable to map variable names to their respective section name
  550. // (used for js category filtering)
  551. $allocationMap = array();
  552. // Variable to mark used sections
  553. $categoryUsed = array();
  554. // sort vars into arrays
  555. foreach ($server_status as $name => $value) {
  556. $section_found = false;
  557. foreach ($allocations as $filter => $section) {
  558. if (strpos($name, $filter) !== false) {
  559. $allocationMap[$name] = $section;
  560. $categoryUsed[$section] = true;
  561. $section_found = true;
  562. if ($section == 'com' && $value > 0) {
  563. $used_queries[$name] = $value;
  564. }
  565. break; // Only exits inner loop
  566. }
  567. }
  568. if (!$section_found) {
  569. $allocationMap[$name] = 'other';
  570. $categoryUsed['other'] = true;
  571. }
  572. }
  573. if (PMA_DRIZZLE) {
  574. $used_queries = PMA_DBI_fetch_result(
  575. 'SELECT * FROM data_dictionary.global_statements',
  576. 0,
  577. 1
  578. );
  579. unset($used_queries['admin_commands']);
  580. } else {
  581. // admin commands are not queries (e.g. they include COM_PING,
  582. // which is excluded from $server_status['Questions'])
  583. unset($used_queries['Com_admin_commands']);
  584. }
  585. /* Ajax request refresh */
  586. if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
  587. switch($_REQUEST['show']) {
  588. case 'query_statistics':
  589. printQueryStatistics();
  590. exit();
  591. case 'server_traffic':
  592. printServerTraffic();
  593. exit();
  594. case 'variables_table':
  595. // Prints the variables table
  596. printVariablesTable();
  597. exit();
  598. default:
  599. break;
  600. }
  601. }
  602. $server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
  603. || $cfg['Server']['host'] == '127.0.0.1'
  604. || $cfg['Server']['host'] == '::1';
  605. PMA_AddJSVar(
  606. 'pma_token',
  607. $_SESSION[' PMA_token ']
  608. );
  609. PMA_AddJSVar(
  610. 'url_query',
  611. str_replace('&amp;', '&', PMA_generate_common_url($db))
  612. );
  613. PMA_AddJSVar(
  614. 'server_time_diff',
  615. 'new Date().getTime() - ' . (microtime(true) * 1000),
  616. false
  617. );
  618. PMA_AddJSVar(
  619. 'server_os',
  620. PHP_OS
  621. );
  622. PMA_AddJSVar(
  623. 'is_superuser',
  624. PMA_isSuperuser()
  625. );
  626. PMA_AddJSVar(
  627. 'server_db_isLocal',
  628. $server_db_isLocal
  629. );
  630. PMA_AddJSVar(
  631. 'profiling_docu',
  632. PMA_showMySQLDocu('general-thread-states', 'general-thread-states')
  633. );
  634. PMA_AddJSVar(
  635. 'explain_docu',
  636. PMA_showMySQLDocu('explain-output', 'explain-output')
  637. );
  638. /**
  639. * start output
  640. */
  641. /**
  642. * Does the common work
  643. */
  644. require './libraries/server_common.inc.php';
  645. /**
  646. * Displays the links
  647. */
  648. require './libraries/server_links.inc.php';
  649. ?>
  650. <div id="serverstatus">
  651. <h2><?php
  652. /**
  653. * Displays the sub-page heading
  654. */
  655. if ($GLOBALS['cfg']['MainPageIconic']) {
  656. echo PMA_getImage('s_status.png');
  657. }
  658. echo __('Runtime Information');
  659. ?></h2>
  660. <div id="serverStatusTabs">
  661. <ul>
  662. <li><a href="#statustabs_traffic"><?php echo __('Server'); ?></a></li>
  663. <li><a href="#statustabs_queries"><?php echo __('Query statistics'); ?></a></li>
  664. <li><a href="#statustabs_allvars"><?php echo __('All status variables'); ?></a></li>
  665. <li class="jsfeature"><a href="#statustabs_charting"><?php echo __('Monitor'); ?></a></li>
  666. <li class="jsfeature"><a href="#statustabs_advisor"><?php echo __('Advisor'); ?></a></li>
  667. </ul>
  668. <div id="statustabs_traffic" class="clearfloat">
  669. <div class="buttonlinks jsfeature">
  670. <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=server_traffic&amp;' . PMA_generate_common_url(); ?>" >
  671. <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
  672. <?php echo __('Refresh'); ?>
  673. </a>
  674. <span class="refreshList" style="display:none;">
  675. <label for="id_trafficChartDataPointsList"><?php echo __('Number of data points: '); ?></label>
  676. <?php echo getDataPointsNumberList('trafficChartDataPoints'); ?>
  677. </span>
  678. <span class="refreshList" style="display:none;">
  679. <label for="id_trafficChartRefresh"><?php echo __('Refresh rate: '); ?></label>
  680. <?php refreshList('trafficChartRefresh'); ?>
  681. </span>
  682. <a class="tabChart livetrafficLink" href="#">
  683. <?php echo __('Live traffic chart'); ?>
  684. </a>
  685. <a class="tabChart liveconnectionsLink" href="#">
  686. <?php echo __('Live conn./process chart'); ?>
  687. </a>
  688. </div>
  689. <div class="tabInnerContent">
  690. <?php printServerTraffic(); ?>
  691. </div>
  692. </div>
  693. <div id="statustabs_queries" class="clearfloat">
  694. <div class="buttonlinks jsfeature">
  695. <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=query_statistics&amp;' . PMA_generate_common_url(); ?>" >
  696. <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
  697. <?php echo __('Refresh'); ?>
  698. </a>
  699. <span class="refreshList" style="display:none;">
  700. <label for="id_queryChartDataPointsList"><?php echo __('Number of data points: '); ?></label>
  701. <?php echo getDataPointsNumberList('queryChartDataPoints'); ?>
  702. </span>
  703. <span class="refreshList" style="display:none;">
  704. <label for="id_queryChartRefresh"><?php echo __('Refresh rate: '); ?></label>
  705. <?php refreshList('queryChartRefresh'); ?>
  706. </span>
  707. <a class="tabChart livequeriesLink" href="#">
  708. <?php echo __('Live query chart'); ?>
  709. </a>
  710. </div>
  711. <div class="tabInnerContent">
  712. <?php printQueryStatistics(); ?>
  713. </div>
  714. </div>
  715. <div id="statustabs_allvars" class="clearfloat">
  716. <fieldset id="tableFilter" class="jsfeature">
  717. <div class="buttonlinks">
  718. <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=variables_table&amp;' . PMA_generate_common_url(); ?>" >
  719. <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
  720. <?php echo __('Refresh'); ?>
  721. </a>
  722. </div>
  723. <legend><?php echo __('Filters'); ?></legend>
  724. <div class="formelement">
  725. <label for="filterText"><?php echo __('Containing the word:'); ?></label>
  726. <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
  727. </div>
  728. <div class="formelement">
  729. <input type="checkbox" name="filterAlert" id="filterAlert" />
  730. <label for="filterAlert"><?php echo __('Show only alert values'); ?></label>
  731. </div>
  732. <div class="formelement">
  733. <select id="filterCategory" name="filterCategory">
  734. <option value=''><?php echo __('Filter by category...'); ?></option>
  735. <?php
  736. foreach ($sections as $section_id => $section_name) {
  737. if (isset($categoryUsed[$section_id])) {
  738. ?>
  739. <option value='<?php echo $section_id; ?>'><?php echo $section_name; ?></option>
  740. <?php
  741. }
  742. }
  743. ?>
  744. </select>
  745. </div>
  746. <div class="formelement">
  747. <input type="checkbox" name="dontFormat" id="dontFormat" />
  748. <label for="dontFormat"><?php echo __('Show unformatted values'); ?></label>
  749. </div>
  750. </fieldset>
  751. <div id="linkSuggestions" class="defaultLinks" style="display:none">
  752. <p class="notice"><?php echo __('Related links:'); ?>
  753. <?php
  754. foreach ($links as $section_name => $section_links) {
  755. echo '<span class="status_' . $section_name . '"> ';
  756. $i=0;
  757. foreach ($section_links as $link_name => $link_url) {
  758. if ($i > 0) {
  759. echo ', ';
  760. }
  761. if ('doc' == $link_name) {
  762. echo PMA_showMySQLDocu($link_url, $link_url);
  763. } else {
  764. echo '<a href="' . $link_url . '">' . $link_name . '</a>';
  765. }
  766. $i++;
  767. }
  768. echo '</span>';
  769. }
  770. unset($link_url, $link_name, $i);
  771. ?>
  772. </p>
  773. </div>
  774. <div class="tabInnerContent">
  775. <?php printVariablesTable(); ?>
  776. </div>
  777. </div>
  778. <div id="statustabs_charting" class="jsfeature">
  779. <?php printMonitor(); ?>
  780. </div>
  781. <div id="statustabs_advisor" class="jsfeature">
  782. <div class="tabLinks">
  783. <?php echo PMA_getImage('play.png'); ?> <a href="#startAnalyzer"><?php echo __('Run analyzer'); ?></a>
  784. <?php echo PMA_getImage('b_help.png'); ?> <a href="#openAdvisorInstructions"><?php echo __('Instructions'); ?></a>
  785. </div>
  786. <div class="tabInnerContent clearfloat">
  787. </div>
  788. <div id="advisorInstructionsDialog" style="display:none;">
  789. <?php
  790. echo '<p>';
  791. echo __('The Advisor system can provide recommendations on server variables by analyzing the server status variables.');
  792. echo '</p> <p>';
  793. echo __('Do note however that this system provides recommendations based on simple calculations and by rule of thumb which may not necessarily apply to your system.');
  794. echo '</p> <p>';
  795. echo __('Prior to changing any of the configuration, be sure to know what you are changing (by reading the documentation) and how to undo the change. Wrong tuning can have a very negative effect on performance.');
  796. echo '</p> <p>';
  797. echo __('The best way to tune your system would be to change only one setting at a time, observe or benchmark your database, and undo the change if there was no clearly measurable improvement.');
  798. echo '</p>';
  799. ?>
  800. </div>
  801. </div>
  802. </div>
  803. </div>
  804. <?php
  805. function printQueryStatistics()
  806. {
  807. global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
  808. $hour_factor = 3600 / $server_status['Uptime'];
  809. $total_queries = array_sum($used_queries);
  810. ?>
  811. <h3 id="serverstatusqueries">
  812. <?php
  813. /* l10n: Questions is the name of a MySQL Status variable */
  814. echo sprintf(__('Questions since startup: %s'), PMA_formatNumber($total_queries, 0)) . ' ';
  815. echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
  816. ?>
  817. <br />
  818. <span>
  819. <?php
  820. echo '&oslash; ' . __('per hour') . ': ';
  821. echo PMA_formatNumber($total_queries * $hour_factor, 0);
  822. echo '<br />';
  823. echo '&oslash; ' . __('per minute') . ': ';
  824. echo PMA_formatNumber($total_queries * 60 / $server_status['Uptime'], 0);
  825. echo '<br />';
  826. if ($total_queries / $server_status['Uptime'] >= 1) {
  827. echo '&oslash; ' . __('per second') . ': ';
  828. echo PMA_formatNumber($total_queries / $server_status['Uptime'], 0);
  829. }
  830. ?>
  831. </span>
  832. </h3>
  833. <?php
  834. // reverse sort by value to show most used statements first
  835. arsort($used_queries);
  836. $odd_row = true;
  837. $count_displayed_rows = 0;
  838. $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
  839. ?>
  840. <table id="serverstatusqueriesdetails" class="data sortable noclick">
  841. <col class="namecol" />
  842. <col class="valuecol" span="3" />
  843. <thead>
  844. <tr><th><?php echo __('Statements'); ?></th>
  845. <th><?php
  846. /* l10n: # = Amount of queries */
  847. echo __('#');
  848. ?>
  849. </th>
  850. <th>&oslash; <?php echo __('per hour'); ?></th>
  851. <th>%</th>
  852. </tr>
  853. </thead>
  854. <tbody>
  855. <?php
  856. $chart_json = array();
  857. $query_sum = array_sum($used_queries);
  858. $other_sum = 0;
  859. foreach ($used_queries as $name => $value) {
  860. $odd_row = !$odd_row;
  861. // For the percentage column, use Questions - Connections, because
  862. // the number of connections is not an item of the Query types
  863. // but is included in Questions. Then the total of the percentages is 100.
  864. $name = str_replace(array('Com_', '_'), array('', ' '), $name);
  865. // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
  866. if ($value < $query_sum * 0.02 && count($chart_json)>6) {
  867. $other_sum += $value;
  868. } else {
  869. $chart_json[$name] = $value;
  870. }
  871. ?>
  872. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  873. <th class="name"><?php echo htmlspecialchars($name); ?></th>
  874. <td class="value"><?php echo htmlspecialchars(PMA_formatNumber($value, 5, 0, true)); ?></td>
  875. <td class="value"><?php echo
  876. htmlspecialchars(PMA_formatNumber($value * $hour_factor, 4, 1, true)); ?></td>
  877. <td class="value"><?php echo
  878. htmlspecialchars(PMA_formatNumber($value * $perc_factor, 0, 2)); ?>%</td>
  879. </tr>
  880. <?php
  881. }
  882. ?>
  883. </tbody>
  884. </table>
  885. <div id="serverstatusquerieschart">
  886. <span style="display:none;">
  887. <?php
  888. if ($other_sum > 0) {
  889. $chart_json[__('Other')] = $other_sum;
  890. }
  891. echo json_encode($chart_json);
  892. ?>
  893. </span>
  894. </div>
  895. <?php
  896. }
  897. function printServerTraffic()
  898. {
  899. global $server_status, $PMA_PHP_SELF;
  900. global $server_master_status, $server_slave_status, $replication_types;
  901. $hour_factor = 3600 / $server_status['Uptime'];
  902. /**
  903. * starttime calculation
  904. */
  905. $start_time = PMA_DBI_fetch_value(
  906. 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']
  907. );
  908. ?>
  909. <h3><?php
  910. echo sprintf(
  911. __('Network traffic since startup: %s'),
  912. implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
  913. );
  914. ?>
  915. </h3>
  916. <p>
  917. <?php
  918. echo sprintf(
  919. __('This MySQL server has been running for %1$s. It started up on %2$s.'),
  920. PMA_timespanFormat($server_status['Uptime']),
  921. PMA_localisedDate($start_time)
  922. ) . "\n";
  923. ?>
  924. </p>
  925. <?php
  926. if ($server_master_status || $server_slave_status) {
  927. echo '<p class="notice">';
  928. if ($server_master_status && $server_slave_status) {
  929. echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
  930. } elseif ($server_master_status) {
  931. echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
  932. } elseif ($server_slave_status) {
  933. echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
  934. }
  935. echo ' ';
  936. echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
  937. echo '</p>';
  938. }
  939. /* if the server works as master or slave in replication process, display useful information */
  940. if ($server_master_status || $server_slave_status) {
  941. ?>
  942. <hr class="clearfloat" />
  943. <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
  944. <?php
  945. foreach ($replication_types as $type) {
  946. if (${"server_{$type}_status"}) {
  947. PMA_replication_print_status_table($type);
  948. }
  949. }
  950. unset($types);
  951. }
  952. ?>
  953. <table id="serverstatustraffic" class="data noclick">
  954. <thead>
  955. <tr>
  956. <th colspan="2"><?php echo __('Traffic') . '&nbsp;' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?></th>
  957. <th>&oslash; <?php echo __('per hour'); ?></th>
  958. </tr>
  959. </thead>
  960. <tbody>
  961. <tr class="odd">
  962. <th class="name"><?php echo __('Received'); ?></th>
  963. <td class="value"><?php echo
  964. implode(' ',
  965. PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?></td>
  966. <td class="value"><?php echo
  967. implode(' ',
  968. PMA_formatByteDown(
  969. $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?></td>
  970. </tr>
  971. <tr class="even">
  972. <th class="name"><?php echo __('Sent'); ?></th>
  973. <td class="value"><?php echo
  974. implode(' ',
  975. PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?></td>
  976. <td class="value"><?php echo
  977. implode(' ',
  978. PMA_formatByteDown(
  979. $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?></td>
  980. </tr>
  981. <tr class="odd">
  982. <th class="name"><?php echo __('Total'); ?></th>
  983. <td class="value"><?php echo
  984. implode(' ',
  985. PMA_formatByteDown(
  986. $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)
  987. ); ?></td>
  988. <td class="value"><?php echo
  989. implode(' ',
  990. PMA_formatByteDown(
  991. ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
  992. * $hour_factor, 3, 1)
  993. ); ?></td>
  994. </tr>
  995. </tbody>
  996. </table>
  997. <table id="serverstatusconnections" class="data noclick">
  998. <thead>
  999. <tr>
  1000. <th colspan="2"><?php echo __('Connections'); ?></th>
  1001. <th>&oslash; <?php echo __('per hour'); ?></th>
  1002. <th>%</th>
  1003. </tr>
  1004. </thead>
  1005. <tbody>
  1006. <tr class="odd">
  1007. <th class="name"><?php echo __('max. concurrent connections'); ?></th>
  1008. <td class="value"><?php echo
  1009. PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
  1010. <td class="value">--- </td>
  1011. <td class="value">--- </td>
  1012. </tr>
  1013. <tr class="even">
  1014. <th class="name"><?php echo __('Failed attempts'); ?></th>
  1015. <td class="value"><?php echo
  1016. PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
  1017. <td class="value"><?php echo
  1018. PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
  1019. 4, 2, true); ?></td>
  1020. <td class="value"><?php echo
  1021. $server_status['Connections'] > 0
  1022. ? PMA_formatNumber(
  1023. $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
  1024. 0, 2, true) . '%'
  1025. : '--- '; ?></td>
  1026. </tr>
  1027. <tr class="odd">
  1028. <th class="name"><?php echo __('Aborted'); ?></th>
  1029. <td class="value"><?php echo
  1030. PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
  1031. <td class="value"><?php echo
  1032. PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
  1033. 4, 2, true); ?></td>
  1034. <td class="value"><?php echo
  1035. $server_status['Connections'] > 0
  1036. ? PMA_formatNumber(
  1037. $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
  1038. 0, 2, true) . '%'
  1039. : '--- '; ?></td>
  1040. </tr>
  1041. <tr class="even">
  1042. <th class="name"><?php echo __('Total'); ?></th>
  1043. <td class="value"><?php echo
  1044. PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
  1045. <td class="value"><?php echo
  1046. PMA_formatNumber($server_status['Connections'] * $hour_factor,
  1047. 4, 2); ?></td>
  1048. <td class="value"><?php echo
  1049. PMA_formatNumber(100, 0, 2); ?>%</td>
  1050. </tr>
  1051. </tbody>
  1052. </table>
  1053. <?php
  1054. $url_params = array();
  1055. $show_full_sql = !empty($_REQUEST['full']);
  1056. if ($show_full_sql) {
  1057. $url_params['full'] = 1;
  1058. $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
  1059. } else {
  1060. $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
  1061. }
  1062. if (PMA_DRIZZLE) {
  1063. $sql_query = "SELECT
  1064. p.id AS Id,
  1065. p.username AS User,
  1066. p.host AS Host,
  1067. p.db AS db,
  1068. p.command AS Command,
  1069. p.time AS Time,
  1070. p.state AS State,
  1071. " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
  1072. FROM data_dictionary.PROCESSLIST p
  1073. " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
  1074. } else {
  1075. $sql_query = $show_full_sql
  1076. ? 'SHOW FULL PROCESSLIST'
  1077. : 'SHOW PROCESSLIST';
  1078. }
  1079. $result = PMA_DBI_query($sql_query);
  1080. /**
  1081. * Displays the page
  1082. */
  1083. ?>
  1084. <table id="tableprocesslist" class="data clearfloat noclick">
  1085. <thead>
  1086. <tr>
  1087. <th><?php echo __('Processes'); ?></th>
  1088. <th><?php echo __('ID'); ?></th>
  1089. <th><?php echo __('User'); ?></th>
  1090. <th><?php echo __('Host'); ?></th>
  1091. <th><?php echo __('Database'); ?></th>
  1092. <th><?php echo __('Command'); ?></th>
  1093. <th><?php echo __('Time'); ?></th>
  1094. <th><?php echo __('Status'); ?></th>
  1095. <th><?php
  1096. echo __('SQL query');
  1097. if (! PMA_DRIZZLE) {
  1098. ?>
  1099. <a href="<?php echo $full_text_link; ?>"
  1100. title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
  1101. <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
  1102. alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
  1103. </a>
  1104. <?php } ?>
  1105. </th>
  1106. </tr>
  1107. </thead>
  1108. <tbody>
  1109. <?php
  1110. $odd_row = true;
  1111. while ($process = PMA_DBI_fetch_assoc($result)) {
  1112. $url_params['kill'] = $process['Id'];
  1113. $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
  1114. ?>
  1115. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  1116. <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
  1117. <td class="value"><?php echo $process['Id']; ?></td>
  1118. <td><?php echo $process['User']; ?></td>
  1119. <td><?php echo $process['Host']; ?></td>
  1120. <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
  1121. <td><?php echo $process['Command']; ?></td>
  1122. <td class="value"><?php echo $process['Time']; ?></td>
  1123. <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
  1124. <td>
  1125. <?php
  1126. if (empty($process['Info'])) {
  1127. echo '---';
  1128. } else {
  1129. if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
  1130. echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
  1131. } else {
  1132. echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
  1133. }
  1134. }
  1135. ?>
  1136. </td>
  1137. </tr>
  1138. <?php
  1139. $odd_row = ! $odd_row;
  1140. }
  1141. ?>
  1142. </tbody>
  1143. </table>
  1144. <?php
  1145. }
  1146. function printVariablesTable()
  1147. {
  1148. global $server_status, $server_variables, $allocationMap, $links;
  1149. /**
  1150. * Messages are built using the message name
  1151. */
  1152. $strShowStatus = array(
  1153. 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
  1154. 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
  1155. 'Binlog_cache_disk_use' => __('The number of transactions that used the temporary binary log cache but that exceeded the value of binlog_cache_size and used a temporary file to store statements from the transaction.'),
  1156. 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
  1157. 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
  1158. 'Created_tmp_disk_tables' => __('The number of temporary tables on disk created automatically by the server while executing statements. If Created_tmp_disk_tables is big, you may want to increase the tmp_table_size value to cause temporary tables to be memory-based instead of disk-based.'),
  1159. 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
  1160. 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
  1161. 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
  1162. 'Delayed_insert_threads' => __('The number of INSERT DELAYED handler threads in use. Every different table on which one uses INSERT DELAYED gets its own thread.'),
  1163. 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
  1164. 'Flush_commands' => __('The number of executed FLUSH statements.'),
  1165. 'Handler_commit' => __('The number of internal COMMIT statements.'),
  1166. 'Handler_delete' => __('The number of times a row was deleted from a table.'),
  1167. 'Handler_discover' => __('The MySQL server can ask the NDB Cluster storage engine if it knows about a table with a given name. This is called dis…

Large files files are truncated, but you can click here to view the full file