Translated using Weblate (Indonesian)
[phpmyadmin.git] / server_status_monitor.php
blob814b92a54d6449ecf1608122021e3e162d7e6f88
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Server status monitor feature
6 * @package PhpMyAdmin
7 */
9 require_once 'libraries/common.inc.php';
10 require_once 'libraries/server_common.inc.php';
11 require_once 'libraries/ServerStatusData.class.php';
12 if (PMA_DRIZZLE) {
13 $server_master_status = false;
14 $server_slave_status = false;
15 } else {
16 include_once 'libraries/replication.inc.php';
17 include_once 'libraries/replication_gui.lib.php';
20 /**
21 * Ajax request
23 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
24 // Send with correct charset
25 header('Content-Type: text/html; charset=UTF-8');
27 // real-time charting data
28 if (isset($_REQUEST['chart_data'])) {
29 switch($_REQUEST['type']) {
30 case 'chartgrid': // Data for the monitor
31 $ret = json_decode($_REQUEST['requiredData'], true);
32 $statusVars = array();
33 $serverVars = array();
34 $sysinfo = $cpuload = $memory = 0;
35 $pName = '';
37 /* Accumulate all required variables and data */
38 // For each chart
39 foreach ($ret as $chart_id => $chartNodes) {
40 // For each data series
41 foreach ($chartNodes as $node_id => $nodeDataPoints) {
42 // For each data point in the series (usually just 1)
43 foreach ($nodeDataPoints as $point_id => $dataPoint) {
44 $pName = $dataPoint['name'];
46 switch ($dataPoint['type']) {
47 /* We only collect the status and server variables here to
48 * read them all in one query,
49 * and only afterwards assign them.
50 * Also do some white list filtering on the names
52 case 'servervar':
53 if (! preg_match('/[^a-zA-Z_]+/', $pName)) {
54 $serverVars[] = $pName;
56 break;
58 case 'statusvar':
59 if (! preg_match('/[^a-zA-Z_]+/', $pName)) {
60 $statusVars[] = $pName;
62 break;
64 case 'proc':
65 $result = $GLOBALS['dbi']->query('SHOW PROCESSLIST');
66 $ret[$chart_id][$node_id][$point_id]['value']
67 = $GLOBALS['dbi']->numRows($result);
68 break;
70 case 'cpu':
71 if (!$sysinfo) {
72 include_once 'libraries/sysinfo.lib.php';
73 $sysinfo = PMA_getSysInfo();
75 if (!$cpuload) {
76 $cpuload = $sysinfo->loadavg();
79 if (PMA_getSysInfoOs() == 'Linux') {
80 $ret[$chart_id][$node_id][$point_id]['idle']
81 = $cpuload['idle'];
82 $ret[$chart_id][$node_id][$point_id]['busy']
83 = $cpuload['busy'];
84 } else {
85 $ret[$chart_id][$node_id][$point_id]['value']
86 = $cpuload['loadavg'];
89 break;
91 case 'memory':
92 if (!$sysinfo) {
93 include_once 'libraries/sysinfo.lib.php';
94 $sysinfo = PMA_getSysInfo();
96 if (!$memory) {
97 $memory = $sysinfo->memory();
100 $ret[$chart_id][$node_id][$point_id]['value']
101 = $memory[$pName];
102 break;
103 } /* switch */
104 } /* foreach */
105 } /* foreach */
106 } /* foreach */
108 // Retrieve all required status variables
109 if (count($statusVars)) {
110 $statusVarValues = $GLOBALS['dbi']->fetchResult(
111 "SHOW GLOBAL STATUS WHERE Variable_name='"
112 . implode("' OR Variable_name='", $statusVars) . "'",
116 } else {
117 $statusVarValues = array();
120 // Retrieve all required server variables
121 if (count($serverVars)) {
122 $serverVarValues = $GLOBALS['dbi']->fetchResult(
123 "SHOW GLOBAL VARIABLES WHERE Variable_name='"
124 . implode("' OR Variable_name='", $serverVars) . "'",
128 } else {
129 $serverVarValues = array();
132 // ...and now assign them
133 foreach ($ret as $chart_id => $chartNodes) {
134 foreach ($chartNodes as $node_id => $nodeDataPoints) {
135 foreach ($nodeDataPoints as $point_id => $dataPoint) {
136 switch($dataPoint['type']) {
137 case 'statusvar':
138 $ret[$chart_id][$node_id][$point_id]['value']
139 = $statusVarValues[$dataPoint['name']];
140 break;
141 case 'servervar':
142 $ret[$chart_id][$node_id][$point_id]['value']
143 = $serverVarValues[$dataPoint['name']];
144 break;
150 $ret['x'] = microtime(true) * 1000;
152 PMA_Response::getInstance()->addJSON('message', $ret);
153 exit;
157 if (isset($_REQUEST['log_data'])) {
158 if (PMA_MYSQL_INT_VERSION < 50106) {
159 // Table logging is only available since 5.1.6
160 exit('""');
163 $start = intval($_REQUEST['time_start']);
164 $end = intval($_REQUEST['time_end']);
166 if ($_REQUEST['type'] == 'slow') {
167 $q = 'SELECT start_time, user_host, ';
168 $q .= 'Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, ';
169 $q .= 'Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, ';
170 $q .= 'SUM(rows_sent) AS rows_sent, ';
171 $q .= 'SUM(rows_examined) AS rows_examined, db, sql_text, ';
172 $q .= 'COUNT(sql_text) AS \'#\' ';
173 $q .= 'FROM `mysql`.`slow_log` ';
174 $q .= 'WHERE start_time > FROM_UNIXTIME(' . $start . ') ';
175 $q .= 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
177 $result = $GLOBALS['dbi']->tryQuery($q);
179 $return = array('rows' => array(), 'sum' => array());
180 $type = '';
182 while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
183 $type = strtolower(
184 substr($row['sql_text'], 0, strpos($row['sql_text'], ' '))
187 switch($type) {
188 case 'insert':
189 case 'update':
190 //Cut off big inserts and updates, but append byte count instead
191 if (strlen($row['sql_text']) > 220) {
192 $implode_sql_text = implode(
193 ' ',
194 PMA_Util::formatByteDown(
195 strlen($row['sql_text']), 2, 2
198 $row['sql_text'] = substr($row['sql_text'], 0, 200)
199 . '... [' . $implode_sql_text . ']';
201 break;
202 default:
203 break;
206 if (! isset($return['sum'][$type])) {
207 $return['sum'][$type] = 0;
209 $return['sum'][$type] += $row['#'];
210 $return['rows'][] = $row;
213 $return['sum']['TOTAL'] = array_sum($return['sum']);
214 $return['numRows'] = count($return['rows']);
216 $GLOBALS['dbi']->freeResult($result);
218 PMA_Response::getInstance()->addJSON('message', $return);
219 exit;
222 if ($_REQUEST['type'] == 'general') {
223 $limitTypes = '';
224 if (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes']) {
225 $limitTypes
226 = 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ';
229 $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, ';
230 $q .= 'server_id, argument, count(argument) as \'#\' ';
231 $q .= 'FROM `mysql`.`general_log` ';
232 $q .= 'WHERE command_type=\'Query\' ';
233 $q .= 'AND event_time > FROM_UNIXTIME(' . $start . ') ';
234 $q .= 'AND event_time < FROM_UNIXTIME(' . $end . ') ';
235 $q .= $limitTypes . 'GROUP by argument'; // HAVING count > 1';
237 $result = $GLOBALS['dbi']->tryQuery($q);
239 $return = array('rows' => array(), 'sum' => array());
240 $type = '';
241 $insertTables = array();
242 $insertTablesFirst = -1;
243 $i = 0;
244 $removeVars = isset($_REQUEST['removeVariables'])
245 && $_REQUEST['removeVariables'];
247 while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
248 preg_match('/^(\w+)\s/', $row['argument'], $match);
249 $type = strtolower($match[1]);
251 if (! isset($return['sum'][$type])) {
252 $return['sum'][$type] = 0;
254 $return['sum'][$type] += $row['#'];
256 switch($type) {
257 case 'insert':
258 // Group inserts if selected
259 if ($removeVars
260 && preg_match(
261 '/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',
262 $row['argument'], $matches
265 $insertTables[$matches[2]]++;
266 if ($insertTables[$matches[2]] > 1) {
267 $return['rows'][$insertTablesFirst]['#']
268 = $insertTables[$matches[2]];
270 // Add a ... to the end of this query to indicate that
271 // there's been other queries
272 $temp = $return['rows'][$insertTablesFirst]['argument'];
273 if ($temp[strlen($temp) - 1] != '.') {
274 $return['rows'][$insertTablesFirst]['argument']
275 .= '<br/>...';
278 // Group this value, thus do not add to the result list
279 continue 2;
280 } else {
281 $insertTablesFirst = $i;
282 $insertTables[$matches[2]] += $row['#'] - 1;
285 // No break here
287 case 'update':
288 // Cut off big inserts and updates,
289 // but append byte count therefor
290 if (strlen($row['argument']) > 220) {
291 $row['argument'] = substr($row['argument'], 0, 200)
292 . '... ['
293 . implode(
294 ' ',
295 PMA_Util::formatByteDown(
296 strlen($row['argument']),
301 . ']';
303 break;
305 default:
306 break;
309 $return['rows'][] = $row;
310 $i++;
313 $return['sum']['TOTAL'] = array_sum($return['sum']);
314 $return['numRows'] = count($return['rows']);
316 $GLOBALS['dbi']->freeResult($result);
318 PMA_Response::getInstance()->addJSON('message', $return);
319 exit;
323 if (isset($_REQUEST['logging_vars'])) {
324 if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
325 $value = PMA_Util::sqlAddSlashes($_REQUEST['varValue']);
326 if (! is_numeric($value)) {
327 $value="'" . $value . "'";
330 if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) {
331 $GLOBALS['dbi']->query(
332 'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value
338 $loggingVars = $GLOBALS['dbi']->fetchResult(
339 'SHOW GLOBAL VARIABLES WHERE Variable_name IN'
340 . ' ("general_log","slow_query_log","long_query_time","log_output")',
344 PMA_Response::getInstance()->addJSON('message', $loggingVars);
345 exit;
348 if (isset($_REQUEST['query_analyzer'])) {
349 $return = array();
351 if (strlen($_REQUEST['database'])) {
352 $GLOBALS['dbi']->selectDb($_REQUEST['database']);
355 if ($profiling = PMA_Util::profilingSupported()) {
356 $GLOBALS['dbi']->query('SET PROFILING=1;');
359 // Do not cache query
360 $query = preg_replace(
361 '/^(\s*SELECT)/i',
362 '\\1 SQL_NO_CACHE',
363 $_REQUEST['query']
366 $result = $GLOBALS['dbi']->tryQuery($query);
367 $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
369 $result = $GLOBALS['dbi']->tryQuery('EXPLAIN ' . $query);
370 while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
371 $return['explain'][] = $row;
374 // In case an error happened
375 $return['error'] = $GLOBALS['dbi']->getError();
377 $GLOBALS['dbi']->freeResult($result);
379 if ($profiling) {
380 $return['profiling'] = array();
381 $result = $GLOBALS['dbi']->tryQuery(
382 'SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING'
383 . ' WHERE QUERY_ID=1 ORDER BY seq'
385 while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
386 $return['profiling'][]= $row;
388 $GLOBALS['dbi']->freeResult($result);
391 PMA_Response::getInstance()->addJSON('message', $return);
392 exit;
397 * JS Includes
399 $header = $response->getHeader();
400 $scripts = $header->getScripts();
401 $scripts->addFile('jquery/jquery.tablesorter.js');
402 $scripts->addFile('jquery/jquery.json-2.4.js');
403 $scripts->addFile('jquery/jquery.sortableTable.js');
404 $scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
405 /* < IE 9 doesn't support canvas natively */
406 if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
407 $scripts->addFile('jqplot/excanvas.js');
409 $scripts->addFile('canvg/canvg.js');
410 // for charting
411 $scripts->addFile('jqplot/jquery.jqplot.js');
412 $scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js');
413 $scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js');
414 $scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
415 $scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js');
416 $scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
417 $scripts->addFile('jqplot/plugins/jqplot.cursor.js');
418 $scripts->addFile('jqplot/plugins/jqplot.byteFormatter.js');
419 $scripts->addFile('date.js');
421 $scripts->addFile('server_status_monitor.js');
422 $scripts->addFile('server_status_sorter.js');
426 * start output
428 $ServerStatusData = new PMA_ServerStatusData();
431 * Output
433 $response->addHTML('<div>');
434 $response->addHTML($ServerStatusData->getMenuHtml());
435 $response->addHTML(PMA_getMonitorHtml($ServerStatusData));
436 $response->addHTML(PMA_getClientSideDataAndLinksHtml($ServerStatusData));
437 $response->addHTML('</div>');
438 exit;
441 * Prints html with monitor
443 * @param object $ServerStatusData An instance of the PMA_ServerStatusData class
445 * @return string
447 function PMA_getMonitorHtml($ServerStatusData)
449 $retval = PMA_getTabLinksHtml();
450 $retval .= PMA_getPopContentHtml();
452 $retval .= '<div id="monitorInstructionsDialog" title="';
453 $retval .= __('Monitor Instructions') . '" style="display:none;">';
454 $retval .= __(
455 'The phpMyAdmin Monitor can assist you in optimizing the server'
456 . ' configuration and track down time intensive queries. For the latter you'
457 . ' will need to set log_output to \'TABLE\' and have either the'
458 . ' slow_query_log or general_log enabled. Note however, that the'
459 . ' general_log produces a lot of data and increases server load'
460 . ' by up to 15%.'
463 if (PMA_MYSQL_INT_VERSION < 50106) {
464 $retval .= '<p>';
465 $retval .= PMA_Util::getImage('s_attention.png');
466 $retval .= __(
467 'Unfortunately your Database server does not support logging to table,'
468 . ' which is a requirement for analyzing the database logs with'
469 . ' phpMyAdmin. Logging to table is supported by MySQL 5.1.6 and'
470 . ' onwards. You may still use the server charting features however.'
472 $retval .= '</p>';
473 } else {
474 $retval .= '<p></p>';
475 $retval .= '<img class="ajaxIcon" src="';
476 $retval .= $GLOBALS['pmaThemeImage'] . 'ajax_clock_small.gif"';
477 $retval .= ' alt="' . __('Loading') . '" />';
478 $retval .= '<div class="ajaxContent"></div>';
479 $retval .= '<div class="monitorUse" style="display:none;">';
480 $retval .= '<p></p>';
481 $retval .= '<strong>';
482 $retval .= __('Using the monitor:');
483 $retval .= '</strong><p>';
484 $retval .= __(
485 'Your browser will refresh all displayed charts in a regular interval.'
486 . ' You may add charts and change the refresh rate under \'Settings\','
487 . ' or remove any chart using the cog icon on each respective chart.'
489 $retval .= '</p><p>';
490 $retval .= __(
491 'To display queries from the logs, select the relevant time span on any'
492 . ' chart by holding down the left mouse button and panning over the'
493 . ' chart. Once confirmed, this will load a table of grouped queries,'
494 . ' there you may click on any occurring SELECT statements to further'
495 . ' analyze them.'
497 $retval .= '</p>';
498 $retval .= '<p>';
499 $retval .= PMA_Util::getImage('s_attention.png');
500 $retval .= '<strong>';
501 $retval .= __('Please note:');
502 $retval .= '</strong><br />';
503 $retval .= __(
504 'Enabling the general_log may increase the server load by'
505 . ' 5-15%. Also be aware that generating statistics from the logs is a'
506 . ' load intensive task, so it is advisable to select only a small time'
507 . ' span and to disable the general_log and empty its table once'
508 . ' monitoring is not required any more.'
510 $retval .= '</p>';
511 $retval .= '</div>';
513 $retval .= '</div>';
515 $retval .= '<div id="addChartDialog" title="' . __('Add chart') . '" style="display:none;">';
516 $retval .= '<div id="tabGridVariables">';
517 $retval .= '<p><input type="text" name="chartTitle" value="' . __('Chart Title') . '" /></p>';
518 $retval .= '<input type="radio" name="chartType" value="preset" id="chartPreset" />';
519 $retval .= '<label for="chartPreset">' . __('Preset chart') . '</label>';
520 $retval .= '<select name="presetCharts"></select><br/>';
521 $retval .= '<input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked" />';
522 $retval .= '<label for="chartStatusVar">';
523 $retval .= __('Status variable(s)');
524 $retval .= '</label><br/>';
525 $retval .= '<div id="chartVariableSettings">';
526 $retval .= '<label for="chartSeries">' . __('Select series:') . '</label><br />';
527 $retval .= '<select id="chartSeries" name="varChartList" size="1">';
528 $retval .= '<option>' . __('Commonly monitored') . '</option>';
529 $retval .= '<option>Processes</option>';
530 $retval .= '<option>Questions</option>';
531 $retval .= '<option>Connections</option>';
532 $retval .= '<option>Bytes_sent</option>';
533 $retval .= '<option>Bytes_received</option>';
534 $retval .= '<option>Threads_connected</option>';
535 $retval .= '<option>Created_tmp_disk_tables</option>';
536 $retval .= '<option>Handler_read_first</option>';
537 $retval .= '<option>Innodb_buffer_pool_wait_free</option>';
538 $retval .= '<option>Key_reads</option>';
539 $retval .= '<option>Open_tables</option>';
540 $retval .= '<option>Select_full_join</option>';
541 $retval .= '<option>Slow_queries</option>';
542 $retval .= '</select><br />';
543 $retval .= '<label for="variableInput">';
544 $retval .= __('or type variable name:');
545 $retval .= ' </label>';
546 $retval .= '<input type="text" name="variableInput" id="variableInput" />';
547 $retval .= '<p></p>';
548 $retval .= '<input type="checkbox" name="differentialValue"';
549 $retval .= ' id="differentialValue" value="differential" checked="checked" />';
550 $retval .= '<label for="differentialValue">';
551 $retval .= __('Display as differential value');
552 $retval .= '</label><br />';
553 $retval .= '<input type="checkbox" id="useDivisor" name="useDivisor" value="1" />';
554 $retval .= '<label for="useDivisor">' . __('Apply a divisor') . '</label>';
555 $retval .= '<span class="divisorInput" style="display:none;">';
556 $retval .= '<input type="text" name="valueDivisor" size="4" value="1" />';
557 $retval .= '(<a href="#kibDivisor">' . __('KiB') . '</a>, ';
558 $retval .= '<a href="#mibDivisor">' . __('MiB') . '</a>)';
559 $retval .= '</span><br />';
560 $retval .= '<input type="checkbox" id="useUnit" name="useUnit" value="1" />';
561 $retval .= '<label for="useUnit">';
562 $retval .= __('Append unit to data values');
563 $retval .= '</label>';
564 $retval .= '<span class="unitInput" style="display:none;">';
565 $retval .= '<input type="text" name="valueUnit" size="4" value="" />';
566 $retval .= '</span>';
567 $retval .= '<p>';
568 $retval .= '<a href="#submitAddSeries"><b>' . __('Add this series') . '</b></a>';
569 $retval .= '<span id="clearSeriesLink" style="display:none;">';
570 $retval .= ' | <a href="#submitClearSeries">' . __('Clear series') . '</a>';
571 $retval .= '</span>';
572 $retval .= '</p>';
573 $retval .= __('Series in Chart:');
574 $retval .= '<br/>';
575 $retval .= '<span id="seriesPreview">';
576 $retval .= '<i>' . __('None') . '</i>';
577 $retval .= '</span>';
578 $retval .= '</div>';
579 $retval .= '</div>';
580 $retval .= '</div>';
582 if (! PMA_DRIZZLE) {
583 $retval .= '<div id="logAnalyseDialog" title="';
584 $retval .= __('Log statistics') . '" style="display:none;">';
585 $retval .= '<p>' . __('Selected time range:');
586 $retval .= '<input type="text" name="dateStart" class="datetimefield" value="" /> - ';
587 $retval .= '<input type="text" name="dateEnd" class="datetimefield" value="" />';
588 $retval .= '</p>';
589 $retval .= '<input type="checkbox" id="limitTypes" value="1" checked="checked" />';
590 $retval .= '<label for="limitTypes">';
591 $retval .= __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements');
592 $retval .= '</label>';
593 $retval .= '<br/>';
594 $retval .= '<input type="checkbox" id="removeVariables" value="1" checked="checked" />';
595 $retval .= '<label for="removeVariables">';
596 $retval .= __('Remove variable data in INSERT statements for better grouping');
597 $retval .= '</label>';
598 $retval .= '<p>';
599 $retval .= __('Choose from which log you want the statistics to be generated from.');
600 $retval .= '</p>';
601 $retval .= '<p>';
602 $retval .= __('Results are grouped by query text.');
603 $retval .= '</p>';
604 $retval .= '</div>';
605 $retval .= '<div id="queryAnalyzerDialog" title="';
606 $retval .= __('Query analyzer') . '" style="display:none;">';
607 $retval .= '<textarea id="sqlquery"> </textarea>';
608 $retval .= '<p></p>';
609 $retval .= '<div class="placeHolder"></div>';
610 $retval .= '</div>';
613 $retval .= '<table class="clearfloat" id="chartGrid"></table>';
614 $retval .= '<div id="logTable">';
615 $retval .= '<br/>';
616 $retval .= '</div>';
618 $retval .= '<script type="text/javascript">';
619 $retval .= 'variableNames = [ ';
620 $i=0;
621 foreach ($ServerStatusData->status as $name=>$value) {
622 if (is_numeric($value)) {
623 if ($i++ > 0) {
624 $retval .= ", ";
626 $retval .= "'" . $name . "'";
629 $retval .= '];';
630 $retval .= '</script>';
632 return $retval;
636 * Builds a <select> list for refresh rates
638 * @param string $name Name of select
639 * @param int $defaultRate Currently chosen rate
640 * @param array $refreshRates List of refresh rates
642 * @return string
644 function PMA_getRefreshList($name,
645 $defaultRate = 5,
646 $refreshRates = Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)
648 $return = '<select name="' . $name . '" id="id_' . $name
649 . '" class="refreshRate">';
650 foreach ($refreshRates as $rate) {
651 $selected = ($rate == $defaultRate)?' selected="selected"':'';
652 $return .= '<option value="' . $rate . '"' . $selected . '>';
653 if ($rate < 60) {
654 $return .= sprintf(_ngettext('%d second', '%d seconds', $rate), $rate);
655 } else {
656 $rate = $rate / 60;
657 $return .= sprintf(_ngettext('%d minute', '%d minutes', $rate), $rate);
659 $return .= '</option>';
661 $return .= '</select>';
662 return $return;
666 * Returns html with Tab Links
668 * @return string
670 function PMA_getTabLinksHtml()
672 $retval = '<div class="tabLinks">';
673 $retval .= '<a href="#pauseCharts">';
674 $retval .= PMA_Util::getImage('play.png') . __('Start Monitor');
675 $retval .= '</a>';
676 $retval .= '<a href="#settingsPopup" class="popupLink">';
677 $retval .= PMA_Util::getImage('s_cog.png') . __('Settings');
678 $retval .= '</a>';
679 if (! PMA_DRIZZLE) {
680 $retval .= '<a href="#monitorInstructionsDialog">';
681 $retval .= PMA_Util::getImage('b_help.png') . __('Instructions/Setup');
683 $retval .= '<a href="#endChartEditMode" style="display:none;">';
684 $retval .= PMA_Util::getImage('s_okay.png');
685 $retval .= __('Done dragging (rearranging) charts');
686 $retval .= '</a>';
687 $retval .= '</div>';
689 return $retval;
693 * Returns html with Pop Content
695 * @return string
697 function PMA_getPopContentHtml()
699 $retval = '<div class="popupContent settingsPopup">';
700 $retval .= '<a href="#addNewChart">';
701 $retval .= PMA_Util::getImage('b_chart.png') . __('Add chart');
702 $retval .= '</a>';
703 $retval .= '<a href="#rearrangeCharts">';
704 $retval .= PMA_Util::getImage('b_tblops.png') . __('Enable charts dragging');
705 $retval .= '</a>';
706 $retval .= '<div class="clearfloat paddingtop"></div>';
707 $retval .= '<div class="floatleft">';
708 $retval .= __('Refresh rate') . '<br />';
709 $retval .= PMA_getRefreshList(
710 'gridChartRefresh',
712 Array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200)
714 $retval .= '<br />';
715 $retval .= '</div>';
716 $retval .= '<div class="floatleft">';
717 $retval .= __('Chart columns');
718 $retval .= '<br />';
719 $retval .= '<select name="chartColumns">';
720 $retval .= '<option>1</option>';
721 $retval .= '<option>2</option>';
722 $retval .= '<option>3</option>';
723 $retval .= '<option>4</option>';
724 $retval .= '<option>5</option>';
725 $retval .= '<option>6</option>';
726 $retval .= '<option>7</option>';
727 $retval .= '<option>8</option>';
728 $retval .= '<option>9</option>';
729 $retval .= '<option>10</option>';
730 $retval .= '</select>';
731 $retval .= '</div>';
732 $retval .= '<div class="clearfloat paddingtop">';
733 $retval .= '<b>' . __('Chart arrangement') . '</b> ';
734 $retval .= PMA_Util::showHint(
736 'The arrangement of the charts is stored to the browsers local storage. '
737 . 'You may want to export it if you have a complicated set up.'
740 $retval .= '<br/>';
741 $retval .= '<a class="ajax" href="#importMonitorConfig">';
742 $retval .= __('Import');
743 $retval .= '</a>';
744 $retval .= '&nbsp;&nbsp;';
745 $retval .= '<a class="disableAjax" href="#exportMonitorConfig">';
746 $retval .= __('Export');
747 $retval .= '</a>';
748 $retval .= '&nbsp;&nbsp;';
749 $retval .= '<a href="#clearMonitorConfig">';
750 $retval .= __('Reset to default');
751 $retval .= '</a>';
752 $retval .= '</div>';
753 $retval .= '</div>';
755 return $retval;
760 * Define some data and links needed on the client side
762 * @param object $ServerStatusData An instance of the PMA_ServerStatusData class
764 * @return string
766 function PMA_getClientSideDataAndLinksHtml($ServerStatusData)
769 * Define some data needed on the client side
771 $input = '<input type="hidden" name="%s" value="%s" />';
772 $form = '<form id="js_data" class="hide">';
773 $form .= sprintf($input, 'server_time', microtime(true) * 1000);
774 $form .= sprintf($input, 'server_os', PHP_OS);
775 $form .= sprintf($input, 'is_superuser', $GLOBALS['dbi']->isSuperuser());
776 $form .= sprintf($input, 'server_db_isLocal', $ServerStatusData->db_isLocal);
777 $form .= '</form>';
779 * Define some links used on client side
781 $links = '<div id="profiling_docu" class="hide">';
782 $links .= PMA_Util::showMySQLDocu('general-thread-states', 'general-thread-states');
783 $links .= '</div>';
784 $links .= '<div id="explain_docu" class="hide">';
785 $links .= PMA_Util::showMySQLDocu('explain-output', 'explain-output');
786 $links .= '</div>';
788 return $form . $links;