PageRenderTime 64ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/phpmyadmin/server_status.php

https://bitbucket.org/adarshj/convenient_website
PHP | 1814 lines | 1468 code | 197 blank | 149 comment | 153 complexity | 17fa8f1ea8e4afb659192941d7da6208 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0
  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 = getSysInfo();
  121. }
  122. if (!$cpuload) {
  123. $cpuload = $sysinfo->loadavg();
  124. }
  125. if (PHP_OS == '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 = 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. // Charting
  351. $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
  352. /* Files required for chart exporting */
  353. $GLOBALS['js_include'][] = 'highcharts/exporting.js';
  354. /* < IE 9 doesn't support canvas natively */
  355. if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
  356. $GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
  357. }
  358. $GLOBALS['js_include'][] = 'canvg/canvg.js';
  359. // for profiling chart
  360. $GLOBALS['js_include'][] = 'jqplot/jquery.jqplot.js';
  361. $GLOBALS['js_include'][] = 'jqplot/plugins/jqplot.pieRenderer.js';
  362. /**
  363. * flush status variables if requested
  364. */
  365. if (isset($_REQUEST['flush'])) {
  366. $_flush_commands = array(
  367. 'STATUS',
  368. 'TABLES',
  369. 'QUERY CACHE',
  370. );
  371. if (in_array($_REQUEST['flush'], $_flush_commands)) {
  372. PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
  373. }
  374. unset($_flush_commands);
  375. }
  376. /**
  377. * Kills a selected process
  378. */
  379. if (!empty($_REQUEST['kill'])) {
  380. if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
  381. $message = PMA_Message::success(__('Thread %s was successfully killed.'));
  382. } else {
  383. $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
  384. }
  385. $message->addParam($_REQUEST['kill']);
  386. //$message->display();
  387. }
  388. /**
  389. * get status from server
  390. */
  391. $server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
  392. if (PMA_DRIZZLE) {
  393. // Drizzle doesn't put query statistics into variables, add it
  394. $sql = "SELECT concat('Com_', variable_name), variable_value
  395. FROM data_dictionary.GLOBAL_STATEMENTS";
  396. $statements = PMA_DBI_fetch_result($sql, 0, 1);
  397. $server_status = array_merge($server_status, $statements);
  398. }
  399. /**
  400. * for some calculations we require also some server settings
  401. */
  402. $server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
  403. /**
  404. * cleanup of some deprecated values
  405. */
  406. cleanDeprecated($server_status);
  407. /**
  408. * calculate some values
  409. */
  410. // Key_buffer_fraction
  411. if (isset($server_status['Key_blocks_unused'])
  412. && isset($server_variables['key_cache_block_size'])
  413. && isset($server_variables['key_buffer_size'])
  414. ) {
  415. $server_status['Key_buffer_fraction_%']
  416. = 100
  417. - $server_status['Key_blocks_unused']
  418. * $server_variables['key_cache_block_size']
  419. / $server_variables['key_buffer_size']
  420. * 100;
  421. } elseif (isset($server_status['Key_blocks_used'])
  422. && isset($server_variables['key_buffer_size'])) {
  423. $server_status['Key_buffer_fraction_%']
  424. = $server_status['Key_blocks_used']
  425. * 1024
  426. / $server_variables['key_buffer_size'];
  427. }
  428. // Ratio for key read/write
  429. if (isset($server_status['Key_writes'])
  430. && isset($server_status['Key_write_requests'])
  431. && $server_status['Key_write_requests'] > 0
  432. ) {
  433. $server_status['Key_write_ratio_%'] = 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
  434. }
  435. if (isset($server_status['Key_reads'])
  436. && isset($server_status['Key_read_requests'])
  437. && $server_status['Key_read_requests'] > 0
  438. ) {
  439. $server_status['Key_read_ratio_%'] = 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
  440. }
  441. // Threads_cache_hitrate
  442. if (isset($server_status['Threads_created'])
  443. && isset($server_status['Connections'])
  444. && $server_status['Connections'] > 0
  445. ) {
  446. $server_status['Threads_cache_hitrate_%']
  447. = 100 - $server_status['Threads_created'] / $server_status['Connections'] * 100;
  448. }
  449. /**
  450. * split variables in sections
  451. */
  452. $allocations = array(
  453. // variable name => section
  454. // variable names match when they begin with the given string
  455. 'Com_' => 'com',
  456. 'Innodb_' => 'innodb',
  457. 'Ndb_' => 'ndb',
  458. 'Handler_' => 'handler',
  459. 'Qcache_' => 'qcache',
  460. 'Threads_' => 'threads',
  461. 'Slow_launch_threads' => 'threads',
  462. 'Binlog_cache_' => 'binlog_cache',
  463. 'Created_tmp_' => 'created_tmp',
  464. 'Key_' => 'key',
  465. 'Delayed_' => 'delayed',
  466. 'Not_flushed_delayed_rows' => 'delayed',
  467. 'Flush_commands' => 'query',
  468. 'Last_query_cost' => 'query',
  469. 'Slow_queries' => 'query',
  470. 'Queries' => 'query',
  471. 'Prepared_stmt_count' => 'query',
  472. 'Select_' => 'select',
  473. 'Sort_' => 'sort',
  474. 'Open_tables' => 'table',
  475. 'Opened_tables' => 'table',
  476. 'Open_table_definitions' => 'table',
  477. 'Opened_table_definitions' => 'table',
  478. 'Table_locks_' => 'table',
  479. 'Rpl_status' => 'repl',
  480. 'Slave_' => 'repl',
  481. 'Tc_' => 'tc',
  482. 'Ssl_' => 'ssl',
  483. 'Open_files' => 'files',
  484. 'Open_streams' => 'files',
  485. 'Opened_files' => 'files',
  486. );
  487. $sections = array(
  488. // section => section name (description)
  489. 'com' => 'Com',
  490. 'query' => __('SQL query'),
  491. 'innodb' => 'InnoDB',
  492. 'ndb' => 'NDB',
  493. 'handler' => __('Handler'),
  494. 'qcache' => __('Query cache'),
  495. 'threads' => __('Threads'),
  496. 'binlog_cache' => __('Binary log'),
  497. 'created_tmp' => __('Temporary data'),
  498. 'delayed' => __('Delayed inserts'),
  499. 'key' => __('Key cache'),
  500. 'select' => __('Joins'),
  501. 'repl' => __('Replication'),
  502. 'sort' => __('Sorting'),
  503. 'table' => __('Tables'),
  504. 'tc' => __('Transaction coordinator'),
  505. 'files' => __('Files'),
  506. 'ssl' => 'SSL',
  507. 'other' => __('Other')
  508. );
  509. /**
  510. * define some needfull links/commands
  511. */
  512. // variable or section name => (name => url)
  513. $links = array();
  514. $links['table'][__('Flush (close) all tables')]
  515. = $PMA_PHP_SELF . '?flush=TABLES&amp;' . PMA_generate_common_url();
  516. $links['table'][__('Show open tables')]
  517. = 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
  518. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  519. if ($server_master_status) {
  520. $links['repl'][__('Show slave hosts')]
  521. = 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') .
  522. '&amp;goto=server_status.php&amp;' . PMA_generate_common_url();
  523. $links['repl'][__('Show master status')] = '#replication_master';
  524. }
  525. if ($server_slave_status) {
  526. $links['repl'][__('Show slave status')] = '#replication_slave';
  527. }
  528. $links['repl']['doc'] = 'replication';
  529. $links['qcache'][__('Flush query cache')]
  530. = $PMA_PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&amp;' .
  531. PMA_generate_common_url();
  532. $links['qcache']['doc'] = 'query_cache';
  533. //$links['threads'][__('Show processes')]
  534. // = 'server_processlist.php?' . PMA_generate_common_url();
  535. $links['threads']['doc'] = 'mysql_threads';
  536. $links['key']['doc'] = 'myisam_key_cache';
  537. $links['binlog_cache']['doc'] = 'binary_log';
  538. $links['Slow_queries']['doc'] = 'slow_query_log';
  539. $links['innodb'][__('Variables')]
  540. = 'server_engines.php?engine=InnoDB&amp;' . PMA_generate_common_url();
  541. $links['innodb'][__('InnoDB Status')]
  542. = 'server_engines.php?engine=InnoDB&amp;page=Status&amp;' .
  543. PMA_generate_common_url();
  544. $links['innodb']['doc'] = 'innodb';
  545. // Variable to contain all com_ variables (query statistics)
  546. $used_queries = array();
  547. // Variable to map variable names to their respective section name
  548. // (used for js category filtering)
  549. $allocationMap = array();
  550. // Variable to mark used sections
  551. $categoryUsed = array();
  552. // sort vars into arrays
  553. foreach ($server_status as $name => $value) {
  554. $section_found = false;
  555. foreach ($allocations as $filter => $section) {
  556. if (strpos($name, $filter) !== false) {
  557. $allocationMap[$name] = $section;
  558. $categoryUsed[$section] = true;
  559. $section_found = true;
  560. if ($section == 'com' && $value > 0) {
  561. $used_queries[$name] = $value;
  562. }
  563. break; // Only exits inner loop
  564. }
  565. }
  566. if (!$section_found) {
  567. $allocationMap[$name] = 'other';
  568. $categoryUsed['other'] = true;
  569. }
  570. }
  571. if (PMA_DRIZZLE) {
  572. $used_queries = PMA_DBI_fetch_result(
  573. 'SELECT * FROM data_dictionary.global_statements',
  574. 0,
  575. 1
  576. );
  577. unset($used_queries['admin_commands']);
  578. } else {
  579. // admin commands are not queries (e.g. they include COM_PING,
  580. // which is excluded from $server_status['Questions'])
  581. unset($used_queries['Com_admin_commands']);
  582. }
  583. /* Ajax request refresh */
  584. if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
  585. switch($_REQUEST['show']) {
  586. case 'query_statistics':
  587. printQueryStatistics();
  588. exit();
  589. case 'server_traffic':
  590. printServerTraffic();
  591. exit();
  592. case 'variables_table':
  593. // Prints the variables table
  594. printVariablesTable();
  595. exit();
  596. default:
  597. break;
  598. }
  599. }
  600. $server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
  601. || $cfg['Server']['host'] == '127.0.0.1'
  602. || $cfg['Server']['host'] == '::1';
  603. PMA_AddJSVar(
  604. 'pma_token',
  605. $_SESSION[' PMA_token ']
  606. );
  607. PMA_AddJSVar(
  608. 'url_query',
  609. str_replace('&amp;', '&', PMA_generate_common_url($db))
  610. );
  611. PMA_AddJSVar(
  612. 'server_time_diff',
  613. 'new Date().getTime() - ' . (microtime(true) * 1000),
  614. false
  615. );
  616. PMA_AddJSVar(
  617. 'server_os',
  618. PHP_OS
  619. );
  620. PMA_AddJSVar(
  621. 'is_superuser',
  622. PMA_isSuperuser()
  623. );
  624. PMA_AddJSVar(
  625. 'server_db_isLocal',
  626. $server_db_isLocal
  627. );
  628. PMA_AddJSVar(
  629. 'profiling_docu',
  630. PMA_showMySQLDocu('general-thread-states', 'general-thread-states')
  631. );
  632. PMA_AddJSVar(
  633. 'explain_docu',
  634. PMA_showMySQLDocu('explain-output', 'explain-output')
  635. );
  636. /**
  637. * start output
  638. */
  639. /**
  640. * Does the common work
  641. */
  642. require './libraries/server_common.inc.php';
  643. /**
  644. * Displays the links
  645. */
  646. require './libraries/server_links.inc.php';
  647. ?>
  648. <div id="serverstatus">
  649. <h2><?php
  650. /**
  651. * Displays the sub-page heading
  652. */
  653. if ($GLOBALS['cfg']['MainPageIconic']) {
  654. echo PMA_getImage('s_status.png');
  655. }
  656. echo __('Runtime Information');
  657. ?></h2>
  658. <div id="serverStatusTabs">
  659. <ul>
  660. <li><a href="#statustabs_traffic"><?php echo __('Server'); ?></a></li>
  661. <li><a href="#statustabs_queries"><?php echo __('Query statistics'); ?></a></li>
  662. <li><a href="#statustabs_allvars"><?php echo __('All status variables'); ?></a></li>
  663. <li class="jsfeature"><a href="#statustabs_charting"><?php echo __('Monitor'); ?></a></li>
  664. <li class="jsfeature"><a href="#statustabs_advisor"><?php echo __('Advisor'); ?></a></li>
  665. </ul>
  666. <div id="statustabs_traffic" class="clearfloat">
  667. <div class="buttonlinks jsfeature">
  668. <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=server_traffic&amp;' . PMA_generate_common_url(); ?>" >
  669. <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
  670. <?php echo __('Refresh'); ?>
  671. </a>
  672. <span class="refreshList" style="display:none;">
  673. <label for="id_trafficChartRefresh"><?php echo __('Refresh rate: '); ?></label>
  674. <?php refreshList('trafficChartRefresh'); ?>
  675. </span>
  676. <a class="tabChart livetrafficLink" href="#">
  677. <?php echo __('Live traffic chart'); ?>
  678. </a>
  679. <a class="tabChart liveconnectionsLink" href="#">
  680. <?php echo __('Live conn./process chart'); ?>
  681. </a>
  682. </div>
  683. <div class="tabInnerContent">
  684. <?php printServerTraffic(); ?>
  685. </div>
  686. </div>
  687. <div id="statustabs_queries" class="clearfloat">
  688. <div class="buttonlinks jsfeature">
  689. <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=query_statistics&amp;' . PMA_generate_common_url(); ?>" >
  690. <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
  691. <?php echo __('Refresh'); ?>
  692. </a>
  693. <span class="refreshList" style="display:none;">
  694. <label for="id_queryChartRefresh"><?php echo __('Refresh rate: '); ?></label>
  695. <?php refreshList('queryChartRefresh'); ?>
  696. </span>
  697. <a class="tabChart livequeriesLink" href="#">
  698. <?php echo __('Live query chart'); ?>
  699. </a>
  700. </div>
  701. <div class="tabInnerContent">
  702. <?php printQueryStatistics(); ?>
  703. </div>
  704. </div>
  705. <div id="statustabs_allvars" class="clearfloat">
  706. <fieldset id="tableFilter" class="jsfeature">
  707. <div class="buttonlinks">
  708. <a class="tabRefresh" href="<?php echo $PMA_PHP_SELF . '?show=variables_table&amp;' . PMA_generate_common_url(); ?>" >
  709. <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
  710. <?php echo __('Refresh'); ?>
  711. </a>
  712. </div>
  713. <legend><?php echo __('Filters'); ?></legend>
  714. <div class="formelement">
  715. <label for="filterText"><?php echo __('Containing the word:'); ?></label>
  716. <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
  717. </div>
  718. <div class="formelement">
  719. <input type="checkbox" name="filterAlert" id="filterAlert" />
  720. <label for="filterAlert"><?php echo __('Show only alert values'); ?></label>
  721. </div>
  722. <div class="formelement">
  723. <select id="filterCategory" name="filterCategory">
  724. <option value=''><?php echo __('Filter by category...'); ?></option>
  725. <?php
  726. foreach ($sections as $section_id => $section_name) {
  727. if (isset($categoryUsed[$section_id])) {
  728. ?>
  729. <option value='<?php echo $section_id; ?>'><?php echo $section_name; ?></option>
  730. <?php
  731. }
  732. }
  733. ?>
  734. </select>
  735. </div>
  736. <div class="formelement">
  737. <input type="checkbox" name="dontFormat" id="dontFormat" />
  738. <label for="dontFormat"><?php echo __('Show unformatted values'); ?></label>
  739. </div>
  740. </fieldset>
  741. <div id="linkSuggestions" class="defaultLinks" style="display:none">
  742. <p class="notice"><?php echo __('Related links:'); ?>
  743. <?php
  744. foreach ($links as $section_name => $section_links) {
  745. echo '<span class="status_' . $section_name . '"> ';
  746. $i=0;
  747. foreach ($section_links as $link_name => $link_url) {
  748. if ($i > 0) {
  749. echo ', ';
  750. }
  751. if ('doc' == $link_name) {
  752. echo PMA_showMySQLDocu($link_url, $link_url);
  753. } else {
  754. echo '<a href="' . $link_url . '">' . $link_name . '</a>';
  755. }
  756. $i++;
  757. }
  758. echo '</span>';
  759. }
  760. unset($link_url, $link_name, $i);
  761. ?>
  762. </p>
  763. </div>
  764. <div class="tabInnerContent">
  765. <?php printVariablesTable(); ?>
  766. </div>
  767. </div>
  768. <div id="statustabs_charting" class="jsfeature">
  769. <?php printMonitor(); ?>
  770. </div>
  771. <div id="statustabs_advisor" class="jsfeature">
  772. <div class="tabLinks">
  773. <?php echo PMA_getImage('play.png'); ?> <a href="#startAnalyzer"><?php echo __('Run analyzer'); ?></a>
  774. <?php echo PMA_getImage('b_help.png'); ?> <a href="#openAdvisorInstructions"><?php echo __('Instructions'); ?></a>
  775. </div>
  776. <div class="tabInnerContent clearfloat">
  777. </div>
  778. <div id="advisorInstructionsDialog" style="display:none;">
  779. <?php
  780. echo '<p>';
  781. echo __('The Advisor system can provide recommendations on server variables by analyzing the server status variables.');
  782. echo '</p> <p>';
  783. 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.');
  784. echo '</p> <p>';
  785. 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.');
  786. echo '</p> <p>';
  787. 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.');
  788. echo '</p>';
  789. ?>
  790. </div>
  791. </div>
  792. </div>
  793. </div>
  794. <?php
  795. function printQueryStatistics()
  796. {
  797. global $server_status, $used_queries, $url_query, $PMA_PHP_SELF;
  798. $hour_factor = 3600 / $server_status['Uptime'];
  799. $total_queries = array_sum($used_queries);
  800. ?>
  801. <h3 id="serverstatusqueries">
  802. <?php
  803. /* l10n: Questions is the name of a MySQL Status variable */
  804. echo sprintf(__('Questions since startup: %s'), PMA_formatNumber($total_queries, 0)) . ' ';
  805. echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
  806. ?>
  807. <br />
  808. <span>
  809. <?php
  810. echo '&oslash; ' . __('per hour') . ': ';
  811. echo PMA_formatNumber($total_queries * $hour_factor, 0);
  812. echo '<br />';
  813. echo '&oslash; ' . __('per minute') . ': ';
  814. echo PMA_formatNumber($total_queries * 60 / $server_status['Uptime'], 0);
  815. echo '<br />';
  816. if ($total_queries / $server_status['Uptime'] >= 1) {
  817. echo '&oslash; ' . __('per second') . ': ';
  818. echo PMA_formatNumber($total_queries / $server_status['Uptime'], 0);
  819. }
  820. ?>
  821. </span>
  822. </h3>
  823. <?php
  824. // reverse sort by value to show most used statements first
  825. arsort($used_queries);
  826. $odd_row = true;
  827. $count_displayed_rows = 0;
  828. $perc_factor = 100 / $total_queries; //(- $server_status['Connections']);
  829. ?>
  830. <table id="serverstatusqueriesdetails" class="data sortable noclick">
  831. <col class="namecol" />
  832. <col class="valuecol" span="3" />
  833. <thead>
  834. <tr><th><?php echo __('Statements'); ?></th>
  835. <th><?php
  836. /* l10n: # = Amount of queries */
  837. echo __('#');
  838. ?>
  839. </th>
  840. <th>&oslash; <?php echo __('per hour'); ?></th>
  841. <th>%</th>
  842. </tr>
  843. </thead>
  844. <tbody>
  845. <?php
  846. $chart_json = array();
  847. $query_sum = array_sum($used_queries);
  848. $other_sum = 0;
  849. foreach ($used_queries as $name => $value) {
  850. $odd_row = !$odd_row;
  851. // For the percentage column, use Questions - Connections, because
  852. // the number of connections is not an item of the Query types
  853. // but is included in Questions. Then the total of the percentages is 100.
  854. $name = str_replace(array('Com_', '_'), array('', ' '), $name);
  855. // Group together values that make out less than 2% into "Other", but only if we have more than 6 fractions already
  856. if ($value < $query_sum * 0.02 && count($chart_json)>6) {
  857. $other_sum += $value;
  858. } else {
  859. $chart_json[$name] = $value;
  860. }
  861. ?>
  862. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  863. <th class="name"><?php echo htmlspecialchars($name); ?></th>
  864. <td class="value"><?php echo htmlspecialchars(PMA_formatNumber($value, 5, 0, true)); ?></td>
  865. <td class="value"><?php echo
  866. htmlspecialchars(PMA_formatNumber($value * $hour_factor, 4, 1, true)); ?></td>
  867. <td class="value"><?php echo
  868. htmlspecialchars(PMA_formatNumber($value * $perc_factor, 0, 2)); ?>%</td>
  869. </tr>
  870. <?php
  871. }
  872. ?>
  873. </tbody>
  874. </table>
  875. <div id="serverstatusquerieschart">
  876. <span style="display:none;">
  877. <?php
  878. if ($other_sum > 0) {
  879. $chart_json[__('Other')] = $other_sum;
  880. }
  881. echo json_encode($chart_json);
  882. ?>
  883. </span>
  884. </div>
  885. <?php
  886. }
  887. function printServerTraffic()
  888. {
  889. global $server_status, $PMA_PHP_SELF;
  890. global $server_master_status, $server_slave_status, $replication_types;
  891. $hour_factor = 3600 / $server_status['Uptime'];
  892. /**
  893. * starttime calculation
  894. */
  895. $start_time = PMA_DBI_fetch_value(
  896. 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']
  897. );
  898. ?>
  899. <h3><?php
  900. echo sprintf(
  901. __('Network traffic since startup: %s'),
  902. implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
  903. );
  904. ?>
  905. </h3>
  906. <p>
  907. <?php
  908. echo sprintf(
  909. __('This MySQL server has been running for %1$s. It started up on %2$s.'),
  910. PMA_timespanFormat($server_status['Uptime']),
  911. PMA_localisedDate($start_time)
  912. ) . "\n";
  913. ?>
  914. </p>
  915. <?php
  916. if ($server_master_status || $server_slave_status) {
  917. echo '<p class="notice">';
  918. if ($server_master_status && $server_slave_status) {
  919. echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.');
  920. } elseif ($server_master_status) {
  921. echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.');
  922. } elseif ($server_slave_status) {
  923. echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.');
  924. }
  925. echo ' ';
  926. echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.');
  927. echo '</p>';
  928. }
  929. /* if the server works as master or slave in replication process, display useful information */
  930. if ($server_master_status || $server_slave_status) {
  931. ?>
  932. <hr class="clearfloat" />
  933. <h3><a name="replication"></a><?php echo __('Replication status'); ?></h3>
  934. <?php
  935. foreach ($replication_types as $type) {
  936. if (${"server_{$type}_status"}) {
  937. PMA_replication_print_status_table($type);
  938. }
  939. }
  940. unset($types);
  941. }
  942. ?>
  943. <table id="serverstatustraffic" class="data noclick">
  944. <thead>
  945. <tr>
  946. <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>
  947. <th>&oslash; <?php echo __('per hour'); ?></th>
  948. </tr>
  949. </thead>
  950. <tbody>
  951. <tr class="odd">
  952. <th class="name"><?php echo __('Received'); ?></th>
  953. <td class="value"><?php echo
  954. implode(' ',
  955. PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?></td>
  956. <td class="value"><?php echo
  957. implode(' ',
  958. PMA_formatByteDown(
  959. $server_status['Bytes_received'] * $hour_factor, 3, 1)); ?></td>
  960. </tr>
  961. <tr class="even">
  962. <th class="name"><?php echo __('Sent'); ?></th>
  963. <td class="value"><?php echo
  964. implode(' ',
  965. PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?></td>
  966. <td class="value"><?php echo
  967. implode(' ',
  968. PMA_formatByteDown(
  969. $server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?></td>
  970. </tr>
  971. <tr class="odd">
  972. <th class="name"><?php echo __('Total'); ?></th>
  973. <td class="value"><?php echo
  974. implode(' ',
  975. PMA_formatByteDown(
  976. $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)
  977. ); ?></td>
  978. <td class="value"><?php echo
  979. implode(' ',
  980. PMA_formatByteDown(
  981. ($server_status['Bytes_received'] + $server_status['Bytes_sent'])
  982. * $hour_factor, 3, 1)
  983. ); ?></td>
  984. </tr>
  985. </tbody>
  986. </table>
  987. <table id="serverstatusconnections" class="data noclick">
  988. <thead>
  989. <tr>
  990. <th colspan="2"><?php echo __('Connections'); ?></th>
  991. <th>&oslash; <?php echo __('per hour'); ?></th>
  992. <th>%</th>
  993. </tr>
  994. </thead>
  995. <tbody>
  996. <tr class="odd">
  997. <th class="name"><?php echo __('max. concurrent connections'); ?></th>
  998. <td class="value"><?php echo
  999. PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
  1000. <td class="value">--- </td>
  1001. <td class="value">--- </td>
  1002. </tr>
  1003. <tr class="even">
  1004. <th class="name"><?php echo __('Failed attempts'); ?></th>
  1005. <td class="value"><?php echo
  1006. PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
  1007. <td class="value"><?php echo
  1008. PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor,
  1009. 4, 2, true); ?></td>
  1010. <td class="value"><?php echo
  1011. $server_status['Connections'] > 0
  1012. ? PMA_formatNumber(
  1013. $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
  1014. 0, 2, true) . '%'
  1015. : '--- '; ?></td>
  1016. </tr>
  1017. <tr class="odd">
  1018. <th class="name"><?php echo __('Aborted'); ?></th>
  1019. <td class="value"><?php echo
  1020. PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
  1021. <td class="value"><?php echo
  1022. PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor,
  1023. 4, 2, true); ?></td>
  1024. <td class="value"><?php echo
  1025. $server_status['Connections'] > 0
  1026. ? PMA_formatNumber(
  1027. $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
  1028. 0, 2, true) . '%'
  1029. : '--- '; ?></td>
  1030. </tr>
  1031. <tr class="even">
  1032. <th class="name"><?php echo __('Total'); ?></th>
  1033. <td class="value"><?php echo
  1034. PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
  1035. <td class="value"><?php echo
  1036. PMA_formatNumber($server_status['Connections'] * $hour_factor,
  1037. 4, 2); ?></td>
  1038. <td class="value"><?php echo
  1039. PMA_formatNumber(100, 0, 2); ?>%</td>
  1040. </tr>
  1041. </tbody>
  1042. </table>
  1043. <?php
  1044. $url_params = array();
  1045. $show_full_sql = !empty($_REQUEST['full']);
  1046. if ($show_full_sql) {
  1047. $url_params['full'] = 1;
  1048. $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
  1049. } else {
  1050. $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
  1051. }
  1052. if (PMA_DRIZZLE) {
  1053. $sql_query = "SELECT
  1054. p.id AS Id,
  1055. p.username AS User,
  1056. p.host AS Host,
  1057. p.db AS db,
  1058. p.command AS Command,
  1059. p.time AS Time,
  1060. p.state AS State,
  1061. " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
  1062. FROM data_dictionary.PROCESSLIST p
  1063. " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
  1064. } else {
  1065. $sql_query = $show_full_sql
  1066. ? 'SHOW FULL PROCESSLIST'
  1067. : 'SHOW PROCESSLIST';
  1068. }
  1069. $result = PMA_DBI_query($sql_query);
  1070. /**
  1071. * Displays the page
  1072. */
  1073. ?>
  1074. <table id="tableprocesslist" class="data clearfloat noclick">
  1075. <thead>
  1076. <tr>
  1077. <th><?php echo __('Processes'); ?></th>
  1078. <th><?php echo __('ID'); ?></th>
  1079. <th><?php echo __('User'); ?></th>
  1080. <th><?php echo __('Host'); ?></th>
  1081. <th><?php echo __('Database'); ?></th>
  1082. <th><?php echo __('Command'); ?></th>
  1083. <th><?php echo __('Time'); ?></th>
  1084. <th><?php echo __('Status'); ?></th>
  1085. <th><?php
  1086. echo __('SQL query');
  1087. if (! PMA_DRIZZLE) {
  1088. ?>
  1089. <a href="<?php echo $full_text_link; ?>"
  1090. title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>">
  1091. <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?>text.png"
  1092. alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?>" />
  1093. </a>
  1094. <?php } ?>
  1095. </th>
  1096. </tr>
  1097. </thead>
  1098. <tbody>
  1099. <?php
  1100. $odd_row = true;
  1101. while ($process = PMA_DBI_fetch_assoc($result)) {
  1102. $url_params['kill'] = $process['Id'];
  1103. $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
  1104. ?>
  1105. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  1106. <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
  1107. <td class="value"><?php echo $process['Id']; ?></td>
  1108. <td><?php echo $process['User']; ?></td>
  1109. <td><?php echo $process['Host']; ?></td>
  1110. <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
  1111. <td><?php echo $process['Command']; ?></td>
  1112. <td class="value"><?php echo $process['Time']; ?></td>
  1113. <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
  1114. <td>
  1115. <?php
  1116. if (empty($process['Info'])) {
  1117. echo '---';
  1118. } else {
  1119. if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
  1120. echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
  1121. } else {
  1122. echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
  1123. }
  1124. }
  1125. ?>
  1126. </td>
  1127. </tr>
  1128. <?php
  1129. $odd_row = ! $odd_row;
  1130. }
  1131. ?>
  1132. </tbody>
  1133. </table>
  1134. <?php
  1135. }
  1136. function printVariablesTable()
  1137. {
  1138. global $server_status, $server_variables, $allocationMap, $links;
  1139. /**
  1140. * Messages are built using the message name
  1141. */
  1142. $strShowStatus = array(
  1143. 'Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'),
  1144. 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'),
  1145. '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.'),
  1146. 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'),
  1147. 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'),
  1148. '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.'),
  1149. 'Created_tmp_files' => __('How many temporary files mysqld has created.'),
  1150. 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'),
  1151. 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'),
  1152. '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.'),
  1153. 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'),
  1154. 'Flush_commands' => __('The number of executed FLUSH statements.'),
  1155. 'Handler_commit' => __('The number of internal COMMIT statements.'),
  1156. 'Handler_delete' => __('The number of times a row was deleted from a table.'),
  1157. '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 discovery. Handler_discover indicates the number of time tables have been discovered.'),
  1158. 'Handler_read_first' => __('The number of times the first entry was read from an index. If this is high, it suggests that the server is doing a lot of full index scans; for example, SELECT col1 FROM foo, assuming that col1 is indexed.'),
  1159. 'Handler_read_key' => __('The number of requests to read a row based on a key. If this is high, it is a good indication that your queries and tables are properly indexed.'),
  1160. 'Handler_read_next' => __('The number of requests to read the next row in key order. This is incremented if you are querying an index column with a range constraint or if you are doing an index scan.'),
  1161. 'Handler_read_prev' => __('The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.'),
  1162. 'Handler_read_rnd' => __('The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don\'t use keys properly.'),
  1163. 'Handler_read_rnd_next' => __('The number of requests to read the next row in the data file. This is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.'),
  1164. 'Handler_rollback' => __('The number of internal ROLLBACK statements.'),
  1165. 'Handler_update' => __('The number of requests to update a row in a table.'),
  1166. 'Handler_write' => __('The number of requests to insert a row in a table.'),
  1167. 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'),
  1168. 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'),
  1169. 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'),
  1170. 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'),
  1171. 'Innodb_buffer_pool_pages_latched' => __('The number of latched pages in InnoDB buffer pool. These are pages currently being read or written or that can\'t be flushed or removed for some other reason.'),
  1172. 'Innodb_buffer_pool_pages_misc' => __('The number of pages busy because they have been allocated for administrative overhead such as row locks or the adaptive hash index. This value can also be calculated as Innodb_buffer_pool_pages_total - Innodb_buffer_pool_pages_free - Innodb_buffer_pool_pages_data.'),
  1173. 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'),
  1174. 'Innodb_buffer_pool_read_ahead_rnd' => __('The number of "random" read-aheads InnoDB initiated. This happens when a query is to scan a large portion of a table but in random order.'),
  1175. 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'),
  1176. 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'),
  1177. 'Innodb_buffer_pool_reads' => __('The number of logical reads that InnoDB could not satisfy from buffer pool and had to do a single-page read.'),
  1178. 'Innodb_buffer_pool_wait_free' => __('Normally, writes to the InnoDB buffer pool happen in the background. However, if it\'s necessary to read or create a page and no clean pages are available, it\'s necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size was set properly, this value should be small.'),
  1179. 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'),
  1180. 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'),
  1181. 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'),
  1182. 'Innodb_data_pending_reads' => __('The current number of pending reads.'),
  1183. 'Innodb_data_pending_writes' => __('The current number of pending writes.'),
  1184. 'Innodb_data_read' => __('The amount of data read so far, in bytes.'),
  1185. 'Innodb_data_reads' => __('The total number of data reads.'),
  1186. 'Innodb_data_writes' => __('The total number of data writes.'),
  1187. 'Innodb_data_written' => __('The amount of data written so far, in bytes.'),
  1188. 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'),
  1189. 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'),
  1190. 'Innodb_log_waits' => __('The number of waits we had because log buffer was too small and we had to wait for it to be flushed before continuing.'),
  1191. 'Innodb_log_write_requests' => __('The number of log write requests.'),
  1192. 'Innodb_log_writes' => __('The number of physical writes to the log file.'),
  1193. 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'),
  1194. 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'),
  1195. 'Innodb_os_log_pending_writes' => __('Pending log file writes.'),
  1196. 'Innodb_os_log_written' => __('The number of bytes written to the log file.'),
  1197. 'Innodb_pages_created' => __('The number of pages created.'),
  1198. 'Innodb_page_size' => __('The compiled-in InnoDB page size (default 16KB). Many values are counted in pages; the page size allows them to be easily converted to bytes.'),
  1199. 'Innodb_pages_read' => __('The number of pages read.'),
  1200. 'Innodb_pages_written' => __('The number of pages written.'),
  1201. 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'),
  1202. 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'),
  1203. 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'),
  1204. 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'),
  1205. 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'),
  1206. 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'),
  1207. 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'),
  1208. 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'),
  1209. 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'),
  1210. 'Key_blocks_not_flushed' => __('The number of key blocks in the key cache that have changed but haven\'t yet been flushed to disk. It used to be known as Not_flushed_key_blocks.'),
  1211. 'Key_blocks_unused' => __('The number of unused blocks in the key cache. You can use this value to determine how much of the key cache is in use.'),
  1212. 'Key_blocks_used' => __('The number of used blocks in the key cache. This value is a high-water mark that indicates the maximum number of blocks that have ever been in use at one time.'),
  1213. 'Key_read_requests' => __('The number of requests to read a key block from the cache.'),
  1214. 'Key_reads' => __('The number of physical reads of a key block from disk. If Key_reads is big, then your key_buffer_size value is probably too small. The cache miss rate can be calculated as Key_reads/Key_read_requests.'),
  1215. 'Key_write_requests' => __('The number of requests to write a key block to the cache.'),
  1216. 'Key_writes' => __('The number of physical writes of a key block to disk.'),
  1217. 'Last_query_cost' => __('The total cost of the last compiled query as computed by the query optimizer. Useful for comparing the cost of different query plans for the same query. The default value of 0 means that no query has been compiled yet.'),
  1218. 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'),
  1219. 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'),
  1220. 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'),
  1221. 'Open_files' => __('The number of files that are open.'),
  1222. 'Open_streams' => __('The number of streams that are open (used mainly for logging).'),
  1223. 'Open_tables' => __('The number of tables that are open.'),
  1224. 'Qcache_free_blocks' => __('The number of free memory blocks in query cache. High numbers can indicate fragmentation issues, which may be solved by issuing a FLUSH QUERY CACHE statement.'),
  1225. 'Qcache_free_memory' => __('The amount of free memory for query cache.'),
  1226. 'Qcache_hits' => __('The number of cache hits.'),
  1227. 'Qcache_inserts' => __('The number of queries added to the cache.'),
  1228. 'Qcache_lowmem_prunes' => __('The number of queries that have been removed from the cache to free up memory for caching new queries. This information can help you tune the query cache size. The query cache uses a least recently used (LRU) strategy to decide which queries to remove from the cache.'),
  1229. 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'),
  1230. 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'),
  1231. 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'),
  1232. 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'),
  1233. 'Select_full_join' => __('The number of joins that do not use indexes. If this value is not 0, you should carefully check the indexes of your tables.'),
  1234. 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'),
  1235. 'Select_range_check' => __('The number of joins without keys that check for key usage after each row. (If this is not 0, you should carefully check the indexes of your tables.)'),
  1236. 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'),
  1237. 'Select_scan' => __('The number of joins that did a full scan of the first table.'),
  1238. 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'),
  1239. 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'),
  1240. 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'),
  1241. 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'),
  1242. 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'),
  1243. 'Sort_merge_passes' => __('The number of merge passes the sort algorithm has had to do. If this value is large, you should consider increasing the value of the sort_buffer_size system variable.'),
  1244. 'Sort_range' => __('The number of sorts that were done with ranges.'),
  1245. 'Sort_rows' => __('The number of sorted rows.'),
  1246. 'Sort_scan' => __('The number of sorts that were done by scanning the table.'),
  1247. 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'),
  1248. 'Table_locks_waited' => __('The number of times that a table lock could not be acquired immediately and a wait was needed. If this is high, and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.'),
  1249. 'Threads_cached' => __('The number of threads in the thread cache. The cache hit rate can be calculated as Threads_created/Connections. If this value is red you should raise your thread_cache_size.'),
  1250. 'Threads_connected' => __('The number of currently open connections.'),
  1251. 'Threads_created' => __('The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. (Normally this doesn\'t give a notable performance improvement if you have a good thread implementation.)'),
  1252. 'Threads_running' => __('The number of threads that are not sleeping.')
  1253. );
  1254. /**
  1255. * define some alerts
  1256. */
  1257. // name => max value before alert
  1258. $alerts = array(
  1259. // lower is better
  1260. // variable => max value
  1261. 'Aborted_clients' => 0,
  1262. 'Aborted_connects' => 0,
  1263. 'Binlog_cache_disk_use' => 0,
  1264. 'Created_tmp_disk_tables' => 0,
  1265. 'Handler_read_rnd' => 0,
  1266. 'Handler_read_rnd_next' => 0,
  1267. 'Innodb_buffer_pool_pages_dirty' => 0,
  1268. 'Innodb_buffer_pool_reads' => 0,
  1269. 'Innodb_buffer_pool_wait_free' => 0,
  1270. 'Innodb_log_waits' => 0,
  1271. 'Innodb_row_lock_time_avg' => 10, // ms
  1272. 'Innodb_row_lock_time_max' => 50, // ms
  1273. 'Innodb_row_lock_waits' => 0,
  1274. 'Slow_queries' => 0,
  1275. 'Delayed_errors' => 0,
  1276. 'Select_full_join' => 0,
  1277. 'Select_range_check' => 0,
  1278. 'Sort_merge_passes' => 0,
  1279. 'Opened_tables' => 0,
  1280. 'Table_locks_waited' => 0,
  1281. 'Qcache_lowmem_prunes' => 0,
  1282. 'Qcache_free_blocks' => isset($server_status['Qcache_total_blocks']) ? $server_status['Qcache_total_blocks'] / 5 : 0,
  1283. 'Slow_launch_threads' => 0,
  1284. // depends on Key_read_requests
  1285. // normaly lower then 1:0.01
  1286. 'Key_reads' => isset($server_status['Key_read_requests']) ? (0.01 * $server_status['Key_read_requests']) : 0,
  1287. // depends on Key_write_requests
  1288. // normaly nearly 1:1
  1289. 'Key_writes' => isset($server_status['Key_write_requests']) ? (0.9 * $server_status['Key_write_requests']) : 0,
  1290. 'Key_buffer_fraction' => 0.5,
  1291. // alert if more than 95% of thread cache is in use
  1292. 'Threads_cached' => isset($server_variables['thread_cache_size']) ? 0.95 * $server_variables['thread_cache_size'] : 0
  1293. // higher is better
  1294. // variable => min value
  1295. //'Handler read key' => '> ',
  1296. );
  1297. ?>
  1298. <table class="data sortable noclick" id="serverstatusvariables">
  1299. <col class="namecol" />
  1300. <col class="valuecol" />
  1301. <col class="descrcol" />
  1302. <thead>
  1303. <tr>
  1304. <th><?php echo __('Variable'); ?></th>
  1305. <th><?php echo __('Value'); ?></th>
  1306. <th><?php echo __('Description'); ?></th>
  1307. </tr>
  1308. </thead>
  1309. <tbody>
  1310. <?php
  1311. $odd_row = false;
  1312. foreach ($server_status as $name => $value) {
  1313. $odd_row = !$odd_row;
  1314. ?>
  1315. <tr class="<?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name])?' s_' . $allocationMap[$name]:''; ?>">
  1316. <th class="name"><?php
  1317. echo htmlspecialchars(str_replace('_', ' ', $name));
  1318. /* Fields containing % are calculated, they can not be described in MySQL documentation */
  1319. if (strpos($name, '%') === FALSE) {
  1320. echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
  1321. }
  1322. ?>
  1323. </th>
  1324. <td class="value"><span class="formatted"><?php
  1325. if (isset($alerts[$name])) {
  1326. if ($value > $alerts[$name]) {
  1327. echo '<span class="attention">';
  1328. } else {
  1329. echo '<span class="allfine">';
  1330. }
  1331. }
  1332. if ('%' === substr($name, -1, 1)) {
  1333. echo htmlspecialchars(PMA_formatNumber($value, 0, 2)) . ' %';
  1334. } elseif (strpos($name, 'Uptime') !== false) {
  1335. echo htmlspecialchars(PMA_timespanFormat($value));
  1336. } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
  1337. echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
  1338. } elseif (is_numeric($value) && $value == (int) $value) {
  1339. echo htmlspecialchars(PMA_formatNumber($value, 3, 0));
  1340. } elseif (is_numeric($value)) {
  1341. echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
  1342. } else {
  1343. echo htmlspecialchars($value);
  1344. }
  1345. if (isset($alerts[$name])) {
  1346. echo '</span>';
  1347. }
  1348. ?></span><span style="display:none;" class="original"><?php echo $value; ?></span>
  1349. </td>
  1350. <td class="descr">
  1351. <?php
  1352. if (isset($strShowStatus[$name ])) {
  1353. echo $strShowStatus[$name];
  1354. }
  1355. if (isset($links[$name])) {
  1356. foreach ($links[$name] as $link_name => $link_url) {
  1357. if ('doc' == $link_name) {
  1358. echo PMA_showMySQLDocu($link_url, $link_url);
  1359. } else {
  1360. echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
  1361. "\n";
  1362. }
  1363. }
  1364. unset($link_url, $link_name);
  1365. }
  1366. ?>
  1367. </td>
  1368. </tr>
  1369. <?php
  1370. }
  1371. ?>
  1372. </tbody>
  1373. </table>
  1374. <?php
  1375. }
  1376. function printMonitor()
  1377. {
  1378. global $server_status, $server_db_isLocal;
  1379. ?>
  1380. <div class="tabLinks" style="display:none;">
  1381. <a href="#pauseCharts">
  1382. <?php echo PMA_getImage('play.png'); ?>
  1383. <?php echo __('Start Monitor'); ?>
  1384. </a>
  1385. <a href="#settingsPopup" rel="popupLink" style="display:none;">
  1386. <?php echo PMA_getImage('s_cog.png'); ?>
  1387. <?php echo __('Settings'); ?>
  1388. </a>
  1389. <?php if (!PMA_DRIZZLE) { ?>
  1390. <a href="#monitorInstructionsDialog">
  1391. <?php echo PMA_getImage('b_help.png'); ?>
  1392. <?php echo __('Instructions/Setup'); ?>
  1393. </a>
  1394. <?php } ?>
  1395. <a href="#endChartEditMode" style="display:none;">
  1396. <?php echo PMA_getImage('s_okay.png'); ?>
  1397. <?php echo __('Done rearranging/editing charts'); ?>
  1398. </a>
  1399. </div>
  1400. <div class="popupContent settingsPopup">
  1401. <a href="#addNewChart">
  1402. <?php echo PMA_getImage('b_chart.png'); ?>
  1403. <?php echo __('Add chart'); ?>
  1404. </a>
  1405. <a href="#rearrangeCharts"><?php echo PMA_getImage('b_tblops.png'); ?><?php echo __('Rearrange/edit charts'); ?></a>
  1406. <div class="clearfloat paddingtop"></div>
  1407. <div class="floatleft">
  1408. <?php
  1409. echo __('Refresh rate') . '<br />';
  1410. refreshList('gridChartRefresh', 5, Array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200));
  1411. ?><br />
  1412. </div>
  1413. <div class="floatleft">
  1414. <?php echo __('Chart columns'); ?> <br />
  1415. <select name="chartColumns">
  1416. <option>1</option>
  1417. <option>2</option>
  1418. <option>3</option>
  1419. <option>4</option>
  1420. <option>5</option>
  1421. <option>6</option>
  1422. <option>7</option>
  1423. <option>8</option>
  1424. <option>9</option>
  1425. <option>10</option>
  1426. </select>
  1427. </div>
  1428. <div class="clearfloat paddingtop">
  1429. <b><?php echo __('Chart arrangement'); ?></b> <?php echo PMA_showHint(__('The arrangement of the charts is stored to the browsers local storage. You may want to export it if you have a complicated set up.')); ?><br/>
  1430. <a href="#importMonitorConfig"><?php echo __('Import'); ?></a>&nbsp;&nbsp;<a href="#exportMonitorConfig"><?php echo __('Export'); ?></a>&nbsp;&nbsp;<a href="#clearMonitorConfig"><?php echo __('Reset to default'); ?></a>
  1431. </div>
  1432. </div>
  1433. <div id="monitorInstructionsDialog" title="<?php echo __('Monitor Instructions'); ?>" style="display:none;">
  1434. <?php echo __('The phpMyAdmin Monitor can assist you in optimizing the server configuration and track down time intensive queries. For the latter you will need to set log_output to \'TABLE\' and have either the slow_query_log or general_log enabled. Note however, that the general_log produces a lot of data and increases server load by up to 15%'); ?>
  1435. <?php if (PMA_MYSQL_INT_VERSION < 50106) { ?>
  1436. <p>
  1437. <?php echo PMA_getImage('s_attention.png'); ?>
  1438. <?php
  1439. echo __('Unfortunately your Database server does not support logging to table, which is a requirement for analyzing the database logs with phpMyAdmin. Logging to table is supported by MySQL 5.1.6 and onwards. You may still use the server charting features however.');
  1440. ?>
  1441. </p>
  1442. <?php
  1443. } else {
  1444. ?>
  1445. <p></p>
  1446. <img class="ajaxIcon" src="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt="Loading" />
  1447. <div class="ajaxContent"></div>
  1448. <div class="monitorUse" style="display:none;">
  1449. <p></p>
  1450. <?php
  1451. echo '<strong>';
  1452. echo __('Using the monitor:');
  1453. echo '</strong><p>';
  1454. echo __('Your browser will refresh all displayed charts in a regular interval. You may add charts and change the refresh rate under \'Settings\', or remove any chart using the cog icon on each respective chart.');
  1455. echo '</p><p>';
  1456. echo __('To display queries from the logs, select the relevant time span on any chart by holding down the left mouse button and panning over the chart. Once confirmed, this will load a table of grouped queries, there you may click on any occuring SELECT statements to further analyze them.');
  1457. echo '</p>';
  1458. ?>
  1459. <p>
  1460. <?php echo PMA_getImage('s_attention.png'); ?>
  1461. <?php
  1462. echo '<strong>';
  1463. echo __('Please note:');
  1464. echo '</strong><br />';
  1465. echo __('Enabling the general_log may increase the server load by 5-15%. Also be aware that generating statistics from the logs is a load intensive task, so it is advisable to select only a small time span and to disable the general_log and empty its table once monitoring is not required any more.');
  1466. ?>
  1467. </p>
  1468. </div>
  1469. <?php } ?>
  1470. </div>
  1471. <div id="addChartDialog" title="<?php echo __('Add chart'); ?>" style="display:none;">
  1472. <div id="tabGridVariables">
  1473. <p><input type="text" name="chartTitle" value="<?php echo __('Chart Title'); ?>" /></p>
  1474. <input type="radio" name="chartType" value="preset" id="chartPreset" />
  1475. <label for="chartPreset"><?php echo __('Preset chart'); ?></label>
  1476. <select name="presetCharts"></select><br/>
  1477. <input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked" />
  1478. <label for="chartStatusVar"><?php echo __('Status variable(s)'); ?></label><br/>
  1479. <div id="chartVariableSettings">
  1480. <label for="chartSeries"><?php echo __('Select series:'); ?></label><br />
  1481. <select id="chartSeries" name="varChartList" size="1">
  1482. <option><?php echo __('Commonly monitored'); ?></option>
  1483. <option>Processes</option>
  1484. <option>Questions</option>
  1485. <option>Connections</option>
  1486. <option>Bytes_sent</option>
  1487. <option>Bytes_received</option>
  1488. <option>Threads_connected</option>
  1489. <option>Created_tmp_disk_tables</option>
  1490. <option>Handler_read_first</option>
  1491. <option>Innodb_buffer_pool_wait_free</option>
  1492. <option>Key_reads</option>
  1493. <option>Open_tables</option>
  1494. <option>Select_full_join</option>
  1495. <option>Slow_queries</option>
  1496. </select><br />
  1497. <label for="variableInput"><?php echo __('or type variable name:'); ?> </label>
  1498. <input type="text" name="variableInput" id="variableInput" />
  1499. <p></p>
  1500. <input type="checkbox" name="differentialValue" id="differentialValue" value="differential" checked="checked" />
  1501. <label for="differentialValue"><?php echo __('Display as differential value'); ?></label><br />
  1502. <input type="checkbox" id="useDivisor" name="useDivisor" value="1" />
  1503. <label for="useDivisor"><?php echo __('Apply a divisor'); ?></label>
  1504. <span class="divisorInput" style="display:none;">
  1505. <input type="text" name="valueDivisor" size="4" value="1" />
  1506. (<a href="#kibDivisor"><?php echo __('KiB'); ?></a>, <a href="#mibDivisor"><?php echo __('MiB'); ?></a>)
  1507. </span><br />
  1508. <input type="checkbox" id="useUnit" name="useUnit" value="1" />
  1509. <label for="useUnit"><?php echo __('Append unit to data values'); ?></label>
  1510. <span class="unitInput" style="display:none;">
  1511. <input type="text" name="valueUnit" size="4" value="" />
  1512. </span>
  1513. <p>
  1514. <a href="#submitAddSeries"><b><?php echo __('Add this series'); ?></b></a>
  1515. <span id="clearSeriesLink" style="display:none;">
  1516. | <a href="#submitClearSeries"><?php echo __('Clear series'); ?></a>
  1517. </span>
  1518. </p>
  1519. <?php echo __('Series in Chart:'); ?><br/>
  1520. <span id="seriesPreview">
  1521. <i><?php echo __('None'); ?></i>
  1522. </span>
  1523. </div>
  1524. </div>
  1525. </div>
  1526. <!-- For generic use -->
  1527. <div id="emptyDialog" title="Dialog" style="display:none;">
  1528. </div>
  1529. <?php if (!PMA_DRIZZLE) { ?>
  1530. <div id="logAnalyseDialog" title="<?php echo __('Log statistics'); ?>" style="display:none;">
  1531. <p> <?php echo __('Selected time range:'); ?>
  1532. <input type="text" name="dateStart" class="datetimefield" value="" /> -
  1533. <input type="text" name="dateEnd" class="datetimefield" value="" /></p>
  1534. <input type="checkbox" id="limitTypes" value="1" checked="checked" />
  1535. <label for="limitTypes">
  1536. <?php echo __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements'); ?>
  1537. </label>
  1538. <br/>
  1539. <input type="checkbox" id="removeVariables" value="1" checked="checked" />
  1540. <label for="removeVariables">
  1541. <?php echo __('Remove variable data in INSERT statements for better grouping'); ?>
  1542. </label>
  1543. <?php
  1544. echo '<p>';
  1545. echo __('Choose from which log you want the statistics to be generated from.');
  1546. echo '</p><p>';
  1547. echo __('Results are grouped by query text.');
  1548. echo '</p>';
  1549. ?>
  1550. </div>
  1551. <div id="queryAnalyzerDialog" title="<?php echo __('Query analyzer'); ?>" style="display:none;">
  1552. <textarea id="sqlquery"> </textarea>
  1553. <p></p>
  1554. <div class="placeHolder"></div>
  1555. </div>
  1556. <?php } ?>
  1557. <table border="0" class="clearfloat" id="chartGrid">
  1558. </table>
  1559. <div id="logTable">
  1560. <br/>
  1561. </div>
  1562. <script type="text/javascript">
  1563. variableNames = [ <?php
  1564. $i=0;
  1565. foreach ($server_status as $name=>$value) {
  1566. if (is_numeric($value)) {
  1567. if ($i++ > 0) {
  1568. echo ", ";
  1569. }
  1570. echo "'" . $name . "'";
  1571. }
  1572. }
  1573. ?> ];
  1574. </script>
  1575. <?php
  1576. }
  1577. /* Builds a <select> list for refresh rates */
  1578. function refreshList($name, $defaultRate=5, $refreshRates=Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600))
  1579. {
  1580. ?>
  1581. <select name="<?php echo $name; ?>" id="id_<?php echo $name; ?>">
  1582. <?php
  1583. foreach ($refreshRates as $rate) {
  1584. $selected = ($rate == $defaultRate)?' selected="selected"':'';
  1585. if ($rate<60) {
  1586. echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d second', '%d seconds', $rate), $rate) . '</option>';
  1587. } else {
  1588. echo '<option value="' . $rate . '"' . $selected . '>' . sprintf(_ngettext('%d minute', '%d minutes', $rate/60), $rate/60) . '</option>';
  1589. }
  1590. }
  1591. ?>
  1592. </select>
  1593. <?php
  1594. }
  1595. /**
  1596. * cleanup of some deprecated values
  1597. *
  1598. * @param array &$server_status
  1599. */
  1600. function cleanDeprecated(&$server_status)
  1601. {
  1602. $deprecated = array(
  1603. 'Com_prepare_sql' => 'Com_stmt_prepare',
  1604. 'Com_execute_sql' => 'Com_stmt_execute',
  1605. 'Com_dealloc_sql' => 'Com_stmt_close',
  1606. );
  1607. foreach ($deprecated as $old => $new) {
  1608. if (isset($server_status[$old]) && isset($server_status[$new])) {
  1609. unset($server_status[$old]);
  1610. }
  1611. }
  1612. }
  1613. /**
  1614. * Sends the footer
  1615. */
  1616. require './libraries/footer.inc.php';
  1617. ?>