From b621d2b56ccd19cdb2515fc60a99ac8a31da4abb Mon Sep 17 00:00:00 2001
From: Rouslan Placella
Date: Wed, 5 Dec 2012 21:20:54 +0000
Subject: [PATCH] Split the server staus monitor features into a separate page
---
js/messages.php | 11 -
js/server_status.js | 429 -------
js/server_status_monitor.js | 189 +++-
libraries/Menu.class.php | 10 +
libraries/ServerStatusData.class.php | 53 +-
libraries/common.inc.php | 4 +
server_status.php | 1572 +++++---------------------
server_status_advisor.php | 11 +-
server_status_monitor.php | 733 ++++++++++++
server_status_queries.php | 4 +-
server_status_variables.php | 18 +-
themes/original/css/common.css.php | 4 -
themes/pmahomme/css/common.css.php | 4 -
13 files changed, 1205 insertions(+), 1837 deletions(-)
create mode 100644 server_status_monitor.php
diff --git a/js/messages.php b/js/messages.php
index 8c4f2fbb70..b713d6bf20 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -73,18 +73,7 @@ $js_messages['strThousandsSeparator'] = __(',');
/* l10n: Decimal separator */
$js_messages['strDecimalSeparator'] = __('.');
-$js_messages['strChartKBSent'] = __('KiB sent since last refresh');
-$js_messages['strChartKBReceived'] = __('KiB received since last refresh');
-$js_messages['strChartServerTraffic'] = __('Server traffic (in KiB)');
-$js_messages['strChartConnections'] = __('Connections since last refresh');
-$js_messages['strChartProcesses'] = __('Processes');
$js_messages['strChartConnectionsTitle'] = __('Connections / Processes');
-/* l10n: Questions is the name of a MySQL Status variable */
-$js_messages['strChartIssuedQueries'] = __('Questions since last refresh');
-/* l10n: Questions is the name of a MySQL Status variable */
-$js_messages['strChartIssuedQueriesTitle'] = __('Questions (executed statements by the server)');
-
-$js_messages['strChartQueryPie'] = __('Query statistics');
/* server status monitor */
$js_messages['strIncompatibleMonitorConfig'] = __('Local monitor configuration incompatible');
diff --git a/js/server_status.js b/js/server_status.js
index 838c288c73..e9fb3263c7 100644
--- a/js/server_status.js
+++ b/js/server_status.js
@@ -2,15 +2,6 @@
/**
* @fileoverview functions used in server status pages
* @name Server Status
- *
- * @requires jQuery
- * @requires jQueryUI
- * @requires jQueryCookie
- * @requires jQueryTablesorter
- * @requires jqPlot
- * @requires canvg
- * @requires js/functions.js
- *
*/
var pma_token,
@@ -20,16 +11,6 @@ var pma_token,
is_superuser,
server_db_isLocal;
-/**
- * Unbind all event handlers before tearing down a page
- */
-AJAX.registerTeardown('server_status.js', function() {
- $('a.popupLink').unbind('click');
- $(document).unbind('click'); // Am I sure about this? I guess not...
- $('div.buttonlinks select').unbind('click');
- $('div.buttonlinks a.tabRefresh').unbind('click');
-});
-
// Add a tablesorter parser to properly handle thousands seperated numbers and SI prefixes
AJAX.registerOnload('server_status.js', function() {
@@ -41,414 +22,4 @@ AJAX.registerOnload('server_status.js', function() {
is_superuser = $js_data_form.find("input[name=is_superuser]").val();
server_db_isLocal = $js_data_form.find("input[name=server_db_isLocal]").val();
- // Show all javascript related parts of the page
- $('#serverstatus .jsfeature').show();
-
- jQuery.tablesorter.addParser({
- id: "fancyNumber",
- is: function(s) {
- return /^[0-9]?[0-9,\.]*\s?(k|M|G|T|%)?$/.test(s);
- },
- format: function(s) {
- var num = jQuery.tablesorter.formatFloat(
- s.replace(PMA_messages['strThousandsSeparator'], '')
- .replace(PMA_messages['strDecimalSeparator'], '.')
- );
-
- var factor = 1;
- switch (s.charAt(s.length - 1)) {
- case '%': factor = -2; break;
- // Todo: Complete this list (as well as in the regexp a few lines up)
- case 'k': factor = 3; break;
- case 'M': factor = 6; break;
- case 'G': factor = 9; break;
- case 'T': factor = 12; break;
- }
-
- return num * Math.pow(10, factor);
- },
- type: "numeric"
- });
-
- jQuery.tablesorter.addParser({
- id: "withinSpanNumber",
- is: function(s) {
- return /(.*)?<\/span>/);
- return (res && res.length >= 3) ? res[2] : 0;
- },
- type: "numeric"
- });
-
- // faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check
- jQuery.tablesorter.addWidget({
- id: "fast-zebra",
- format: function (table) {
- if (table.config.debug) {
- var time = new Date();
- }
- $("tr:even", table.tBodies[0])
- .removeClass(table.config.widgetZebra.css[0])
- .addClass(table.config.widgetZebra.css[1]);
- $("tr:odd", table.tBodies[0])
- .removeClass(table.config.widgetZebra.css[1])
- .addClass(table.config.widgetZebra.css[0]);
- if (table.config.debug) {
- $.tablesorter.benchmark("Applying Fast-Zebra widget", time);
- }
- }
- });
-
- // Popup behaviour
- $('a.popupLink').click( function() {
- var $link = $(this);
-
- $('div.' + $link.attr('href').substr(1))
- .show()
- .offset({ top: $link.offset().top + $link.height() + 5, left: $link.offset().left })
- .addClass('openedPopup');
-
- return false;
- });
-
- $(document).click( function(event) {
- $('div.openedPopup').each(function() {
- var $cnt = $(this);
- var pos = $cnt.offset();
-
- // Hide if the mouseclick is outside the popupcontent
- if (event.pageX < pos.left
- || event.pageY < pos.top
- || event.pageX > pos.left + $cnt.outerWidth()
- || event.pageY > pos.top + $cnt.outerHeight()
- ) {
- $cnt.hide().removeClass('openedPopup');
- }
- });
- });
});
-
-AJAX.registerOnload('server_status.js', function() {
- // Filters for status variables
- var textFilter = null;
- var alertFilter = false;
- var categoryFilter = '';
- var odd_row = false;
- var text = ''; // Holds filter text
- var queryPieChart = null;
- var monitorLoaded = false;
-
- /* Chart configuration */
- // Defines what the tabs are currently displaying (realtime or data)
- var tabStatus = new Object();
- // Holds the current chart instances for each tab
- var tabChart = new Object();
- // Holds current live charts' timeouts
- var chart_replot_timers = new Object();
-
- /*** Table sort tooltip ***/
- PMA_createqTip($('table.sortable thead th'), PMA_messages['strSortHint']);
-
- $.ajaxSetup({
- cache: false
- });
-
- // Add tabs
- $('#serverStatusTabs').tabs({
- // Tab persistence
- cookie: { name: 'pma_serverStatusTabs', expires: 1 },
- show: function(event, ui) {
- // Fixes line break in the menu bar when the page overflows and scrollbar appears
- $('#topmenu').menuResizer('resize');
-
- // Initialize selected tab
- if (!$(ui.tab.hash).data('init-done')) {
- initTab($(ui.tab.hash), null);
- }
- // Load Server status monitor
- if (ui.tab.hash == '#statustabs_charting' && ! monitorLoaded) {
- $('div#statustabs_charting').append( //PMA_messages['strLoadingMonitor'] + ' ' +
- ' '
- );
- // Delay loading a bit so the tab loads and the user gets to see a ajax loading icon
- setTimeout(function() {
- var scripts = [
- {name:'jquery/timepicker.js',fire:0},
- {name:'jquery/jquery.json-2.2.js',fire:0},
- {name:'jquery/jquery.sortableTable.js',fire:0},
- {name:'server_status_monitor.js',fire:1}
- ];
- AJAX.scriptHandler.load(scripts);
- }, 50);
-
- monitorLoaded = true;
- }
- }
- });
-
- // Fixes wrong tab height with floated elements. See also http://bugs.jqueryui.com/ticket/5601
- $(".ui-widget-content:not(.ui-tabs):not(.ui-helper-clearfix)").addClass("ui-helper-clearfix");
-
- // Initialize each tab
- $('div.ui-tabs-panel').each(function() {
- var $tab = $(this);
- tabStatus[$tab.attr('id')] = 'static';
- // Initialize tabs after browser catches up with previous changes and displays tabs
- setTimeout(function() {
- initTab($tab, null);
- }, 0.5);
- });
-
- /** Realtime charting of variables **/
-
- function recursiveTimer($tab, type) {
- replotLiveChart($tab, type);
- chart_replot_timers[$tab.attr('id')] = setTimeout(function() {
- recursiveTimer($tab, type) }, ($('.refreshRate :selected', $tab).val() * 1000));
- }
-
- function getCurrentDataSet($tab, type) {
- var ret = null;
- var line1 = null;
- var line2 = null;
- var retval = null;
-
- $.ajax({
- async: false,
- url: 'server_status.php',
- type: 'post',
- data: {
- 'token' : PMA_commonParams.get('token'),
- 'server' : PMA_commonParams.get('server'),
- 'ajax_request' : true,
- 'chart_data' : true,
- 'type' : type
- },
- dataType: 'json',
- success: function(data) {
- ret = $.parseJSON(data.message);
- }
- });
- // get data based on chart type
- if(type == 'proc') {
- line1 = [ret.x, ret.y_conn - previous_y_line1[$tab.attr('id')]];
- line2 = [ret.x, ret.y_proc];
- previous_y_line1[$tab.attr('id')] = ret.y_conn;
- }
- else if(type == 'queries') {
- line1 = [ret.x, ret.y-previous_y_line1[$tab.attr('id')]];
- previous_y_line1[$tab.attr('id')] = ret.y;
- }
- else if(type == 'traffic') {
- ret.y_sent = ret.y_sent/1024;
- ret.y_received = ret.y_received/1024;
- line1 = [ret.x, ret.y_sent - previous_y_line1[$tab.attr('id')]];
- line2 = [ret.x, ret.y_received - previous_y_line2[$tab.attr('id')]];
- previous_y_line1[$tab.attr('id')] = ret.y_sent;
- previous_y_line2[$tab.attr('id')] = ret.y_received;
- }
-
- retval = [line1, line2];
- return retval;
- }
-
- function getSettings(type) {
-
- var settings = {
- grid: {
- drawBorder: false,
- shadow: false,
- background: 'rgba(0,0,0,0)'
- },
- axes: {
- xaxis: {
- renderer: $.jqplot.DateAxisRenderer,
- tickOptions: {
- formatString: '%H:%M:%S',
- showGridline: false
- }
- },
- yaxis: {
- autoscale:true,
- label: PMA_messages['strTotalCount'],
- labelRenderer: $.jqplot.CanvasAxisLabelRenderer
- }
- },
- seriesDefaults: {
- rendererOptions: {
- smooth: true
- }
- },
- legend: {
- show: true,
- location: 's', // compass direction, nw, n, ne, e, se, s, sw, w.
- xoffset: 12, // pixel offset of the legend box from the x (or x2) axis.
- yoffset: 12 // pixel offset of the legend box from the y (or y2) axis.
- }
- };
-
- var title_message;
- var x_legend = new Array();
- if(type == 'proc') {
- title_message = PMA_messages['strChartConnectionsTitle'];
- x_legend[0] = PMA_messages['strChartConnections'];
- x_legend[1] = PMA_messages['strChartProcesses'];
- settings.series = [ {label: x_legend[0]}, {label: x_legend[1]} ];
- }
- else if(type == 'queries') {
- title_message = PMA_messages['strChartIssuedQueriesTitle'];
- x_legend[0] = PMA_messages['strChartIssuedQueries'];
- settings.series = [ {label: x_legend[0]} ];
- }
- else if(type == 'traffic') {
- title_message = PMA_messages['strChartServerTraffic'];
- x_legend[0] = PMA_messages['strChartKBSent'];
- x_legend[1] = PMA_messages['strChartKBReceived'];
- settings.series = [ {label: x_legend[0]}, {label: x_legend[1]} ];
- }
- settings.title = title_message;
-
- return settings;
- }
-
- function replotLiveChart($tab, type) {
- var data_set = getCurrentDataSet($tab, type);
- if(type == 'proc' || type == 'traffic') {
- series[$tab.attr('id')][0].push(data_set[0]);
- series[$tab.attr('id')][1].push(data_set[1]);
- // update data set
- tabChart[$tab.attr('id')].series[0].data = series[$tab.attr('id')][0];
- tabChart[$tab.attr('id')].series[1].data = series[$tab.attr('id')][1];
- }
- else if(type == 'queries') {
- // there is just one line to be plotted
- series[$tab.attr('id')][0].push(data_set[0]);
- // update data set
- tabChart[$tab.attr('id')].series[0].data = series[$tab.attr('id')][0];
- }
- tabChart[$tab.attr('id')].resetAxesScale();
- var current_time = new Date().getTime();
- var data_points = $('.dataPointsNumber :selected', $tab).val();
- var refresh_rate = $('.refreshRate :selected', $tab).val() * 1000;
- // Min X would be decided based on refresh rate and number of data points
- var minX = current_time - (refresh_rate * data_points);
- var interval = (((current_time - minX)/data_points) / 1000);
- interval = (data_points > 20) ? (((current_time - minX)/20) / 1000) : interval;
- // update chart options
- tabChart[$tab.attr('id')]['axes']['xaxis']['max'] = current_time;
- tabChart[$tab.attr('id')]['axes']['xaxis']['min'] = minX;
- tabChart[$tab.attr('id')]['axes']['xaxis']['tickInterval'] = interval + " seconds";
- // replot
- tabChart[$tab.attr('id')].replot();
- }
-
- /* Adjust DOM / Add handlers to the tabs */
- function initTab(tab, data) {
- if ($(tab).data('init-done') && !data) {
- return;
- }
- $(tab).data('init-done', true);
- switch(tab.attr('id')) {
- case 'statustabs_traffic':
- if (data != null) {
- tab.find('.tabInnerContent').html(data.message);
- }
- PMA_showHints();
- break;
- }
- }
-
- // TODO: tablesorter shouldn't sort already sorted columns
- function initTableSorter(tabid) {
- var $table, opts;
- switch(tabid) {
- case 'statustabs_queries':
- $table = $('#serverstatusqueriesdetails');
- opts = {
- sortList: [[3, 1]],
- widgets: ['fast-zebra'],
- headers: {
- 1: { sorter: 'fancyNumber' },
- 2: { sorter: 'fancyNumber' }
- }
- };
- break;
- case 'statustabs_allvars':
- $table = $('#serverstatusvariables');
- opts = {
- sortList: [[0, 0]],
- widgets: ['fast-zebra'],
- headers: {
- 1: { sorter: 'withinSpanNumber' }
- }
- };
- break;
- }
- $table.tablesorter(opts);
- $table.find('tr:first th')
- .append(' ');
- }
-
- // Provides a nicely formatted and sorted tooltip of each datapoint of the query statistics
- function sortedQueriesPointInfo(queries, lastQueries){
- var max, maxIdx, num = 0;
- var queryKeys = new Array();
- var queryValues = new Array();
- var sumOther = 0;
- var sumTotal = 0;
-
- // Separate keys and values, then sort them
- $.each(queries.pointInfo, function(key, value) {
- if (value-lastQueries.pointInfo[key] > 0) {
- queryKeys.push(key);
- queryValues.push(value-lastQueries.pointInfo[key]);
- sumTotal += value-lastQueries.pointInfo[key];
- }
- });
- var numQueries = queryKeys.length;
- var pointInfo = '' + PMA_messages['strTotal'] + ': ' + sumTotal + ' ';
-
- while(queryKeys.length > 0) {
- max = 0;
- for (var i = 0; i < queryKeys.length; i++) {
- if (queryValues[i] > max) {
- max = queryValues[i];
- maxIdx = i;
- }
- }
- if (numQueries > 8 && num >= 6) {
- sumOther += queryValues[maxIdx];
- } else {
- pointInfo += queryKeys[maxIdx].substr(4).replace('_', ' ') + ': ' + queryValues[maxIdx] + ' ';
- }
-
- queryKeys.splice(maxIdx, 1);
- queryValues.splice(maxIdx, 1);
- num++;
- }
-
- if (sumOther>0) {
- pointInfo += PMA_messages['strOther'] + ': ' + sumOther;
- }
-
- return pointInfo;
- }
-});
-
-
-// Needs to be global as server_status_monitor.js uses it too
-function serverResponseError() {
- var btns = {};
- btns[PMA_messages['strReloadPage']] = function() {
- window.location.reload();
- };
- $('#emptyDialog').dialog({title: PMA_messages['strRefreshFailed']});
- $('#emptyDialog').html(
- PMA_getImage('s_attention.png') +
- PMA_messages['strInvalidResponseExplanation']
- );
- $('#emptyDialog').dialog({ buttons: btns });
-}
diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js
index d4799df235..30f5ada5cb 100644
--- a/js/server_status_monitor.js
+++ b/js/server_status_monitor.js
@@ -1,12 +1,57 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
-var runtime = {};
+var runtime = {},
+ server_time_diff,
+ server_os,
+ is_superuser,
+ server_db_isLocal;
+AJAX.registerOnload('server_status_monitor.js', function() {
+ var $js_data_form = $('#js_data');
+ server_time_diff = new Date().getTime() - $js_data_form.find("input[name=server_time]").val();
+ server_os = $js_data_form.find("input[name=server_os]").val();
+ is_superuser = $js_data_form.find("input[name=is_superuser]").val();
+ server_db_isLocal = $js_data_form.find("input[name=server_db_isLocal]").val();
+});
+
/**
* Unbind all event handlers before tearing down a page
*/
+AJAX.registerTeardown('server_status_monitor.js', function() {
+ $('a.popupLink').unbind('click');
+ $('body').unbind('click');
+});
+/**
+ * Popup behaviour
+ */
+AJAX.registerOnload('server_status_monitor.js', function() {
+ $('a.popupLink').click( function() {
+ var $link = $(this);
+ $('div.' + $link.attr('href').substr(1))
+ .show()
+ .offset({ top: $link.offset().top + $link.height() + 5, left: $link.offset().left })
+ .addClass('openedPopup');
+
+ return false;
+ });
+ $('body').click( function(event) {
+ $('div.openedPopup').each(function() {
+ var $cnt = $(this);
+ var pos = $cnt.offset();
+ // Hide if the mouseclick is outside the popupcontent
+ if (event.pageX < pos.left
+ || event.pageY < pos.top
+ || event.pageX > pos.left + $cnt.outerWidth()
+ || event.pageY > pos.top + $cnt.outerHeight()
+ ) {
+ $cnt.hide().removeClass('openedPopup');
+ }
+ });
+ });
+});
+
AJAX.registerTeardown('server_status_monitor.js', function() {
$('a[href="#rearrangeCharts"], a[href="#endChartEditMode"]').unbind('click');
- $('div#statustabs_charting div.popupContent select[name="chartColumns"]').unbind('change');
- $('div#statustabs_charting div.popupContent select[name="gridChartRefresh"]').unbind('change');
+ $('div.popupContent select[name="chartColumns"]').unbind('change');
+ $(' div.popupContent select[name="gridChartRefresh"]').unbind('change');
$('a[href="#addNewChart"]').unbind('click');
$('a[href="#exportMonitorConfig"]').unbind('click');
$('a[href="#importMonitorConfig"]').unbind('click');
@@ -22,15 +67,13 @@ AJAX.registerTeardown('server_status_monitor.js', function() {
$('a[href="#submitClearSeries"]').unbind('click');
$('a[href="#submitAddSeries"]').unbind('click');
// $("input#variableInput").destroy();
- clearTimeout(runtime.refreshTimeout);
- runtime.refreshTimeout = null;
- $.cookie('pma_serverStatusTabs', null);
+ destroyGrid();
});
AJAX.registerOnload('server_status_monitor.js', function() {
// Show tab links
- $('div#statustabs_charting div.tabLinks').show();
- $('div#statustabs_charting img#loadingMonitorIcon').remove();
+ $('div.tabLinks').show();
+ $('img#loadingMonitorIcon').remove();
// Codemirror is loaded on demand so we might need to initialize it
if (! codemirror_editor) {
var $elm = $('#sqlquery');
@@ -46,7 +89,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
);
}
}
- // Timepicker is loaded on demand so we need to initialize datetime fields from the 'load log' dialog
+ // Timepicker is loaded on demand so we need to initialize
+ // datetime fields from the 'load log' dialog
$('div#logAnalyseDialog .datetimefield').each(function() {
PMA_addDatepicker($(this));
});
@@ -58,9 +102,10 @@ AJAX.registerOnload('server_status_monitor.js', function() {
var newChart = null;
var chartSpacing;
- // Whenever the monitor object (runtime.charts) or the settings object (monitorSettings)
- // changes in a way incompatible to the previous version, increase this number
- // It will reset the users monitor and settings object in his localStorage to the default configuration
+ // Whenever the monitor object (runtime.charts) or the settings object
+ // (monitorSettings) changes in a way incompatible to the previous version,
+ // increase this number. It will reset the users monitor and settings object
+ // in his localStorage to the default configuration
var monitorProtocolVersion = '1.0';
// Runtime parameter of the monitor, is being fully set in initGrid()
@@ -75,7 +120,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
chartAI: 0,
// To play/pause the monitor
redrawCharts: false,
- // Object that contains a list of nodes that need to be retrieved from the server for chart updates
+ // Object that contains a list of nodes that need to be retrieved
+ // from the server for chart updates
dataList: [],
// Current max points per chart (needed for auto calculation)
gridMaxPoints: 20,
@@ -88,7 +134,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
var defaultMonitorSettings = {
columns: 3,
chartSize: { width: 295, height: 250 },
- // Max points in each chart. Settings it to 'auto' sets gridMaxPoints to (chartwidth - 40) / 12
+ // Max points in each chart. Settings it to 'auto' sets
+ // gridMaxPoints to (chartwidth - 40) / 12
gridMaxPoints: 'auto',
/* Refresh rate of all grid charts in ms */
gridRefresh: 5000
@@ -335,14 +382,15 @@ AJAX.registerOnload('server_status_monitor.js', function() {
editMode = false;
}
- // Icon graphics have zIndex 19, 20 and 21. Let's just hope nothing else has the same zIndex
+ // Icon graphics have zIndex 19, 20 and 21.
+ // Let's just hope nothing else has the same zIndex
$('table#chartGrid div svg').find('*[zIndex=20], *[zIndex=21], *[zIndex=19]').toggle(editMode);
$('a[href="#endChartEditMode"]').toggle(editMode);
if (editMode) {
// Close the settings popup
- $('#statustabs_charting .popupContent').hide().removeClass('openedPopup');
+ $('div.popupContent').hide().removeClass('openedPopup');
$("#chartGrid").sortableTable({
ignoreRect: {
@@ -427,7 +475,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
});
// global settings
- $('div#statustabs_charting div.popupContent select[name="chartColumns"]').change(function() {
+ $('div.popupContent select[name="chartColumns"]').change(function() {
monitorSettings.columns = parseInt(this.value);
var newSize = chartSize();
@@ -452,7 +500,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
numColumns++;
});
- // To little cells in one row => for each cell to little, move all cells backwards by 1
+ // To little cells in one row => for each cell to little,
+ // move all cells backwards by 1
if ($tr.next().length > 0) {
var cnt = monitorSettings.columns - $tr.find('td').length;
for (var i = 0; i < cnt; i++) {
@@ -492,7 +541,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
saveMonitor(); // Save settings
});
- $('div#statustabs_charting div.popupContent select[name="gridChartRefresh"]').change(function() {
+ $('div.popupContent select[name="gridChartRefresh"]').change(function() {
monitorSettings.gridRefresh = parseInt(this.value) * 1000;
clearTimeout(runtime.refreshTimeout);
@@ -522,7 +571,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
if (type == 'preset') {
newChart = presetCharts[$('div#addChartDialog select[name="presetCharts"]').prop('value')];
} else {
- // If user builds his own chart, it's being set/updated each time he adds a series
+ // If user builds his own chart, it's being set/updated
+ // each time he adds a series
// So here we only warn if he didn't add a series yet
if (! newChart || ! newChart.nodes || newChart.nodes.length == 0) {
alert(PMA_messages['strAddOneSeriesWarning']);
@@ -585,7 +635,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
$('', {
"class": "disableAjax",
method: "post",
- action: "file_echo.php?" + url_query + "&filename=1",
+ action: "file_echo.php?" + PMA_commonParams.get('common_query') + "&filename=1",
style: "display:none;"
})
.append(
@@ -602,7 +652,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
$('a[href="#importMonitorConfig"]').click(function() {
$('div#emptyDialog').dialog({title: PMA_messages['strImportDialogTitle']});
- $('div#emptyDialog').html(PMA_messages['strImportDialogMessage'] + ': ');
var dlgBtns = {};
@@ -704,7 +754,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
$.extend(vars, getvars);
}
- $.get('server_status.php?' + url_query, vars,
+ $.get('server_status_monitor.php?' + PMA_commonParams.get('common_query'), vars,
function(data) {
var logVars = $.parseJSON(data.message),
icon = PMA_getImage('s_success.png'), msg='', str='';
@@ -1008,30 +1058,6 @@ AJAX.registerOnload('server_status_monitor.js', function() {
refreshChartGrid();
}
- /* Destroys all monitor related resources */
- function destroyGrid() {
- if (runtime.charts) {
- $.each(runtime.charts, function(key, value) {
- try {
- value.chart.destroy();
- } catch(err) {}
- });
- }
-
- try {
- runtime.refreshRequest.abort();
- } catch(err) {}
- try {
- clearTimeout(runtime.refreshTimeout);
- } catch(err) {}
-
- $('table#chartGrid').html('');
-
- runtime.charts = null;
- runtime.chartAI = 0;
- monitorSettings = null;
- }
-
/* Calls destroyGrid() and initGrid(), but before doing so it saves the chart
* data from each chart and restores it after the monitor is initialized again */
function rebuildGrid() {
@@ -1370,7 +1396,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
/* Called in regular intervalls, this function updates the values of each chart in the grid */
function refreshChartGrid() {
/* Send to server */
- runtime.refreshRequest = $.post('server_status.php?' + url_query, {
+ runtime.refreshRequest = $.post('server_status_monitor.php?' + PMA_commonParams.get('common_query'), {
ajax_request: true,
chart_data: 1,
type: 'chartgrid',
@@ -1437,7 +1463,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
// Set y value, if defined
if (value != undefined) {
- elem.chart.series[j].data.push([chartData.x, value]);
+ elem.chart.series[j].data.push([chartData.x, value]);
if(value > elem.maxYLabel) {
elem.maxYLabel = value;
}
@@ -1472,7 +1498,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
});
}
- /* Function to get highest plotted point's y label, to scale the chart,
+ /* Function to get highest plotted point's y label, to scale the chart,
* TODO: make jqplot's autoscale:true work here
*/
function getMaxYLabel(dataValues) {
@@ -1488,7 +1514,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
if (prev == null) {
return undefined;
}
- // cur and prev are datapoint arrays, but containing only 1 element for cpu-linux
+ // cur and prev are datapoint arrays, but containing
+ // only 1 element for cpu-linux
cur = cur[0];
prev = prev[0];
@@ -1573,7 +1600,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
});
- logRequest = $.get('server_status.php?' + url_query,
+ logRequest = $.get('server_status_monitor.php?' + PMA_commonParams.get('common_query'),
{ ajax_request: true,
log_data: 1,
type: opts.src,
@@ -1655,10 +1682,12 @@ AJAX.registerOnload('server_status_monitor.js', function() {
}
);
- /* Handles the actions performed when the user uses any of the log table filters
- * which are the filter by name and grouping with ignoring data in WHERE clauses
+ /* Handles the actions performed when the user uses any of the
+ * log table filters which are the filter by name and grouping
+ * with ignoring data in WHERE clauses
*
- * @param boolean Should be true when the users enabled or disabled to group queries ignoring data in WHERE clauses
+ * @param boolean Should be true when the users enabled or disabled
+ * to group queries ignoring data in WHERE clauses
*/
function filterQueries(varFilterChange) {
var odd_row = false, cell, textFilter;
@@ -1699,7 +1728,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
// We just assume the sql text is always in the second last column, and that the total count is right of it
$('div#logTable table tbody tr td:nth-child(' + (runtime.logDataCols.length - 1) + ')').each(function() {
var $t = $(this);
- // If query is a SELECT and user enabled or disabled to group queries ignoring data in where statements, we
+ // If query is a SELECT and user enabled or disabled to group
+ // queries ignoring data in where statements, we
// need to re-calculate the sums of each row
if (varFilterChange && $t.html().match(/^SELECT/i)) {
if (noVars) {
@@ -1708,7 +1738,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
q = $t.text().replace(equalsFilter, '$1=...$6').trim();
q = q.replace(functionFilter, ' $1(...)');
- // Js does not specify a limit on property name length, so we can abuse it as index :-)
+ // Js does not specify a limit on property name length,
+ // so we can abuse it as index :-)
if (filteredQueries[q]) {
filteredQueries[q] += parseInt($t.next().text());
totalSum += parseInt($t.next().text());
@@ -1740,7 +1771,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
}
}
- // If not required to be hidden, do we need to hide because of a not matching text filter?
+ // If not required to be hidden, do we need
+ // to hide because of a not matching text filter?
if (! hide && (textFilter != null && ! textFilter.exec($t.text()))) {
hide = true;
}
@@ -1919,7 +1951,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
if (codemirror_editor) {
query = PMA_SQLPrettyPrint(query);
codemirror_editor.setValue(query);
- // Codemirror is bugged, it doesn't refresh properly sometimes. Following lines seem to fix that
+ // Codemirror is bugged, it doesn't refresh properly sometimes.
+ // Following lines seem to fix that
setTimeout(function() {
codemirror_editor.refresh();
},50);
@@ -1965,7 +1998,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
PMA_messages['strAnalyzing'] + ' ');
- $.post('server_status.php?' + url_query, {
+ $.post('server_status_monitor.php?' + PMA_commonParams.get('common_query'), {
ajax_request: true,
query_analyzer: true,
query: codemirror_editor ? codemirror_editor.getValue() : $('#sqlquery').val(),
@@ -2105,3 +2138,39 @@ AJAX.registerOnload('server_status_monitor.js', function() {
AJAX.registerOnload('server_status_monitor.js', function() {
$('a[href="#pauseCharts"]').trigger('click');
});
+
+// Needs to be global as server_status_monitor.js uses it too
+function serverResponseError() {
+ var btns = {};
+ btns[PMA_messages['strReloadPage']] = function() {
+ window.location.reload();
+ };
+ $('#emptyDialog').dialog({title: PMA_messages['strRefreshFailed']});
+ $('#emptyDialog').html(
+ PMA_getImage('s_attention.png') +
+ PMA_messages['strInvalidResponseExplanation']
+ );
+ $('#emptyDialog').dialog({ buttons: btns });
+}
+
+/* Destroys all monitor related resources */
+function destroyGrid() {
+ if (runtime.charts) {
+ $.each(runtime.charts, function(key, value) {
+ try {
+ value.chart.destroy();
+ } catch(err) {}
+ });
+ }
+
+ try {
+ runtime.refreshRequest.abort();
+ } catch(err) {}
+ try {
+ clearTimeout(runtime.refreshTimeout);
+ } catch(err) {}
+ $('table#chartGrid').html('');
+ runtime.charts = null;
+ runtime.chartAI = 0;
+ monitorSettings = null;
+}
diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php
index 201c0028cd..d954616f44 100644
--- a/libraries/Menu.class.php
+++ b/libraries/Menu.class.php
@@ -456,6 +456,16 @@ class PMA_Menu
$tabs['status']['icon'] = 's_status.png';
$tabs['status']['link'] = 'server_status.php';
$tabs['status']['text'] = __('Status');
+ $tabs['status']['active'] = in_array(
+ basename($GLOBALS['PMA_PHP_SELF']),
+ array(
+ 'server_status.php',
+ 'server_status_advisor.php',
+ 'server_status_monitor.php',
+ 'server_status_queries.php',
+ 'server_status_variables.php'
+ )
+ );
if ($is_superuser && ! PMA_DRIZZLE) {
$tabs['rights']['icon'] = 's_rights.png';
diff --git a/libraries/ServerStatusData.class.php b/libraries/ServerStatusData.class.php
index 85d507b05e..fc2cfa0ef8 100644
--- a/libraries/ServerStatusData.class.php
+++ b/libraries/ServerStatusData.class.php
@@ -308,23 +308,48 @@ class PMA_ServerStatusData {
*
* @return array
*/
- public static function getMenuHtml()
+ public function getMenuHtml()
{
- $retval = '';
-
-echo '';
-echo PMA_Util::showMySQLDocu('general-thread-states', 'general-thread-states');
-echo '
';
-echo '';
-echo PMA_Util::showMySQLDocu('explain-output', 'explain-output');
-echo '
';
-
/**
* start output
*/
+$response = PMA_Response::getInstance();
+$response->addHTML('');
+$response->addHTML($ServerStatusData->getMenuHtml());
+$response->addHTML(getServerTrafficHtml($ServerStatusData));
+$response->addHTML('
');
- /**
- * Does the common work
- */
-require 'libraries/server_common.inc.php';
-
-echo '';
-
-echo PMA_ServerStatusData::getMenuHtml();
-
-echo '
';
-echo '
';
-
-echo '
';
-printMonitor();
-echo '
';
-
-echo '
';
-echo '
';
+exit;
/**
* Prints server traffic information
*
* @return void
*/
-function printServerTraffic()
+function getServerTrafficHtml($ServerStatusData)
{
- global $server_status, $PMA_PHP_SELF;
- global $server_master_status, $server_slave_status, $replication_types;
-
- $hour_factor = 3600 / $server_status['Uptime'];
-
- /**
- * starttime calculation
- */
+ $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$start_time = PMA_DBI_fetch_value(
- 'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']
+ 'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']
);
- echo '';
-
- echo sprintf(
+ $retval = '';
+ $retval .= sprintf(
__('Network traffic since startup: %s'),
implode(
' ',
PMA_Util::formatByteDown(
- $server_status['Bytes_received'] + $server_status['Bytes_sent'],
+ $ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'],
3,
1
)
)
);
- echo ' ';
-
- echo ' ';
-
- printf(
+ $retval .= '';
+ $retval .= '
';
+ $retval .= sprintf(
__('This MySQL server has been running for %1$s. It started up on %2$s.'),
- PMA_Util::timespanFormat($server_status['Uptime']),
+ PMA_Util::timespanFormat($ServerStatusData->status['Uptime']),
PMA_Util::localisedDate($start_time)
) . "\n";
+ $retval .= '
';
- echo '
';
-
- if ($server_master_status || $server_slave_status) {
- echo '';
- if ($server_master_status && $server_slave_status) {
- echo __('This MySQL server works as master and slave in replication process.');
- } elseif ($server_master_status) {
- echo __('This MySQL server works as master in replication process.');
- } elseif ($server_slave_status) {
- echo __('This MySQL server works as slave in replication process.');
+ if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
+ $retval .= '
';
+ if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) {
+ $retval .= __(
+ 'This MySQL server works as master and '
+ . 'slave in replication process.'
+ );
+ } elseif ($GLOBALS['server_master_status']) {
+ $retval .= __(
+ 'This MySQL server works as master '
+ . 'in replication process.'
+ );
+ } elseif ($GLOBALS['server_slave_status']) {
+ $retval .= __(
+ 'This MySQL server works as slave '
+ . 'in replication process.'
+ );
}
- echo ' ';
- echo __('For further information about replication status on the server, please visit the replication section .');
- echo '
';
+ $retval .= ' ';
+ $retval .= __(
+ 'For further information about replication status on the server, '
+ . 'please visit the replication section .'
+ );
+ $retval .= '';
}
/*
* if the server works as master or slave in replication process,
* display useful information
*/
- if ($server_master_status || $server_slave_status) {
- echo ' ';
-
- echo ' ' . __('Replication status') . ' ';
-
- foreach ($replication_types as $type) {
+ if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
+ $retval .= ' ';
+ $retval .= ' ' . __('Replication status') . ' ';
+ foreach ($GLOBALS['replication_types'] as $type) {
if (${"server_{$type}_status"}) {
PMA_replication_print_status_table($type);
}
}
unset($types);
}
- ?>
-
-
-
-
- ø
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ $retval .= '';
+ $retval .= '';
+ $retval .= '';
+ $retval .= '';
+ $retval .= __('Traffic') . ' ';
+ $retval .= PMA_Util::showHint(
+ __(
+ 'On a busy server, the byte counters may overrun, so those statistics '
+ . 'as reported by the MySQL server may be incorrect.'
+ )
+ );
+ $retval .= ' ';
+ $retval .= 'ø ' . __('per hour') . ' ';
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '';
+ $retval .= '' . __('Received') . ' ';
+ $retval .= '';
+ $retval .= implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ $ServerStatusData->status['Bytes_received'], 3, 1
+ )
+ );
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ $ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1
+ )
+ );
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '' . __('Sent') . ' ';
+ $retval .= '';
+ $retval .= implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ $ServerStatusData->status['Bytes_sent'], 3, 1
+ )
+ );
+ $retval .= ' ';
+ $retval .= 'status['Bytes_sent'] * $hour_factor, 3, 1
+ )
+ );
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '' . __('Total') . ' ';
+ $retval .= '';
+ $retval .= implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ $ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1
+ )
+ );
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ ($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'])
+ * $hour_factor, 3, 1
+ )
+ );
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '
';
-
-
-
-
- ø
- %
-
-
-
-
-
-
- ---
- ---
-
-
-
-
-
- 0
- ? PMA_Util::formatNumber(
- $server_status['Aborted_connects'] * 100 / $server_status['Connections'],
- 0, 2, true
- ) . '%'
- : '--- '; ?>
-
-
-
-
-
- 0
- ? PMA_Util::formatNumber(
- $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
- 0, 2, true
- ) . '%'
- : '--- '; ?>
-
-
-
-
-
- %
-
-
-
- ';
+ $retval .= '';
+ $retval .= '';
+ $retval .= '' . __('Connections') . ' ';
+ $retval .= 'ø ' . __('per hour') . ' ';
+ $retval .= '% ';
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '';
+ $retval .= '' . __('max. concurrent connections') . ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Max_used_connections'], 0
+ );
+ $retval .= ' ';
+ $retval .= '--- ';
+ $retval .= '--- ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '' . __('Failed attempts') . ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Aborted_connects'], 4, 1, true
+ );
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true
+ );
+ $retval .= ' ';
+ $retval .= '';
+ if ($ServerStatusData->status['Connections'] > 0) {
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Aborted_connects'] * 100 / $ServerStatusData->status['Connections'],
+ 0, 2, true
+ );
+ $retval .= '%';
+ } else {
+ $retval .= '--- ';
+ }
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '' . __('Aborted') . ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Aborted_clients'], 4, 1, true
+ );
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true
+ );
+ $retval .= ' ';
+ $retval .= '';
+ if ($ServerStatusData->status['Connections'] > 0) {
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Aborted_clients'] * 100 / $ServerStatusData->status['Connections'],
+ 0, 2, true
+ );
+ $retval .= '%';
+ } else {
+ $retval .= '--- ';
+ }
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= '' . __('Total') . ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Connections'], 4, 0
+ );
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(
+ $ServerStatusData->status['Connections'] * $hour_factor, 4, 2
+ );
+ $retval .= ' ';
+ $retval .= '';
+ $retval .= PMA_Util::formatNumber(100, 0, 2);
+ $retval .= '% ';
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '';
$url_params = array();
@@ -1085,8 +348,8 @@ function printServerTraffic()
" . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info
FROM data_dictionary.PROCESSLIST p
" . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
- if (!empty($_REQUEST['order_by_field'])
- && !empty($_REQUEST['sort_order'])
+ if (! empty($_REQUEST['order_by_field'])
+ && ! empty($_REQUEST['sort_order'])
) {
$sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' . $_REQUEST['sort_order'];
}
@@ -1094,8 +357,8 @@ function printServerTraffic()
$sql_query = $show_full_sql
? 'SHOW FULL PROCESSLIST'
: 'SHOW PROCESSLIST';
- if (!empty($_REQUEST['order_by_field'])
- && !empty($_REQUEST['sort_order'])
+ if (! empty($_REQUEST['order_by_field'])
+ && ! empty($_REQUEST['sort_order'])
) {
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `'
. $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
@@ -1107,15 +370,14 @@ function printServerTraffic()
/**
* Displays the page
*/
- echo '';
- echo '';
- echo '';
- echo '' . __('Processes') . ' ';
-
+ $retval .= '';
+ $retval .= '';
+ $retval .= '';
+ $retval .= '' . __('Processes') . ' ';
foreach ($sortable_columns as $column) {
- $is_sorted = !empty($_REQUEST['order_by_field'])
- && !empty($_REQUEST['sort_order'])
+ $is_sorted = ! empty($_REQUEST['order_by_field'])
+ && ! empty($_REQUEST['sort_order'])
&& ($_REQUEST['order_by_field'] == $column['order_by_field']);
$column['sort_order'] = ($is_sorted
@@ -1133,61 +395,61 @@ function printServerTraffic()
}
}
- echo '';
- echo '';
+ $retval .= '>';
- echo $column['column_name'];
+ $retval .= $column['column_name'];
if ($is_sorted) {
- echo ' ';
- echo ' ';
}
- echo ' ';
+ $retval .= '';
if (! PMA_DRIZZLE && (0 === --$sortable_columns_count)) {
- echo '';
- echo ' ';
+ $retval .= ' ';
- echo ' ';
+ $retval .= '">';
+ $retval .= '';
}
- echo ' ';
+ $retval .= '';
}
- echo ' ';
- echo ' ';
- echo '';
+ $retval .= '';
+ $retval .= '';
+ $retval .= ' ';
$odd_row = true;
while ($process = PMA_DBI_fetch_assoc($result)) {
// Array keys need to modify due to the way it has used
// to display column values
- if (!empty($_REQUEST['order_by_field'])
- && !empty($_REQUEST['sort_order'])
+ if (! empty($_REQUEST['order_by_field'])
+ && ! empty($_REQUEST['sort_order'])
) {
foreach (array_keys($process) as $key) {
$new_key = ucfirst(strtolower($key));
@@ -1198,347 +460,35 @@ function printServerTraffic()
$url_params['kill'] = $process['Id'];
$kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
- ?>
-
-
-
-
-
- ' . __('None') . '' : $process['db']); ?>
-
-
-
-
- ';
+ $retval .= ' ' . __('Kill') . ' ';
+ $retval .= '' . $process['Id'] . ' ';
+ $retval .= '' . $process['User'] . ' ';
+ $retval .= '' . $process['Host'] . ' ';
+ $retval .= '' . ((! isset($process['db']) || ! strlen($process['db'])) ? '' . __('None') . ' ' : $process['db']) . ' ';
+ $retval .= '' . $process['Command'] . ' ';
+ $retval .= '' . $process['Time'] . ' ';
+ $retval .= '' . (empty($process['State']) ? '---' : $process['State']) . ' ';
+ $retval .= '';
+
if (empty($process['Info'])) {
- echo '---';
+ $retval .= '---';
} else {
if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
- echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
+ $retval .= htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
} else {
- echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
+ $retval .= PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
}
}
- ?>
-
-
- ';
+ $retval .= '';
$odd_row = ! $odd_row;
}
- ?>
-
-
- ';
+ $retval .= '
';
-/**
- * Prints html with monitor
- *
- * @return void
- */
-function printMonitor()
-{
- global $server_status, $server_db_isLocal;
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ';
- echo __('Using the monitor:');
- echo '
';
- 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.');
- echo '
';
- 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.');
- echo '
';
- ?>
-
-
- ';
- echo __('Please note:');
- echo ' ';
- 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.');
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Processes
- Questions
- Connections
- Bytes_sent
- Bytes_received
- Threads_connected
- Created_tmp_disk_tables
- Handler_read_first
- Innodb_buffer_pool_wait_free
- Key_reads
- Open_tables
- Select_full_join
- Slow_queries
-
-
-
-
-
-
-
-
-
-
- ( , )
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- list for refresh rates
- *
- * @param string $name Name of select
- * @param int $defaultRate Currently chosen rate
- * @param array $refreshRates List of refresh rates
- *
- * @return HTML code with select
- */
-function PMA_getRefreshList($name,
- $defaultRate = 5,
- $refreshRates = Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)
-) {
- $return = '';
- foreach ($refreshRates as $rate) {
- $selected = ($rate == $defaultRate)?' selected="selected"':'';
- $return .= '';
- if ($rate < 60) {
- $return .= sprintf(_ngettext('%d second', '%d seconds', $rate), $rate);
- } else {
- $rate = $rate / 60;
- $return .= sprintf(_ngettext('%d minute', '%d minutes', $rate), $rate);
- }
- $return .= ' ';
- }
- $return .= ' ';
- return $return;
-}
-
-/**
- * Builds a list for number of data points to be displayed
- *
- * @param string $name name of select
- * @param integer $defaultValue chosen value
- * @param array $values list of values
- *
- * @return string with html code
- */
-function getDataPointsNumberList(
- $name, $defaultValue = 12, $values = Array(8, 10, 12, 15, 20, 25, 30, 40)
-) {
- $html_output = '';
- foreach ($values as $number) {
- $selected = ($number == $defaultValue)?' selected="selected"':'';
- $html_output .= ''
- . sprintf(_ngettext('%d second', '%d points', $number), $number)
- . ' ';
- }
-
- $html_output .= ' ';
- return $html_output;
-}
-
-/**
- * cleanup of some deprecated values
- *
- * @param array &$server_status status array to process
- *
- * @return void
- */
-function cleanDeprecated(&$server_status)
-{
- $deprecated = array(
- 'Com_prepare_sql' => 'Com_stmt_prepare',
- 'Com_execute_sql' => 'Com_stmt_execute',
- 'Com_dealloc_sql' => 'Com_stmt_close',
- );
-
- foreach ($deprecated as $old => $new) {
- if (isset($server_status[$old]) && isset($server_status[$new])) {
- unset($server_status[$old]);
- }
- }
+ return $retval;
}
?>
diff --git a/server_status_advisor.php b/server_status_advisor.php
index a697207077..1b79819e2b 100644
--- a/server_status_advisor.php
+++ b/server_status_advisor.php
@@ -9,13 +9,22 @@
require_once 'libraries/common.inc.php';
require_once 'libraries/Advisor.class.php';
require_once 'libraries/ServerStatusData.class.php';
+if (PMA_DRIZZLE) {
+ $server_master_status = false;
+ $server_slave_status = false;
+} else {
+ include_once 'libraries/replication.inc.php';
+ include_once 'libraries/replication_gui.lib.php';
+}
+
+$ServerStatusData = new PMA_ServerStatusData('server_status_advisor.php');
$response = PMA_Response::getInstance();
$scripts = $response->getHeader()->getScripts();
$scripts->addFile('server_status_advisor.js');
$output = '';
-$output .= PMA_ServerStatusData::getMenuHtml();
+$output .= $ServerStatusData->getMenuHtml();
$output .= '
';
$output .= PMA_Util::getIcon('b_help.png', __('Instructions'));
$output .= ' ';
diff --git a/server_status_monitor.php b/server_status_monitor.php
new file mode 100644
index 0000000000..945313d609
--- /dev/null
+++ b/server_status_monitor.php
@@ -0,0 +1,733 @@
+ $chartNodes) {
+ // For each data series
+ foreach ($chartNodes as $node_id => $nodeDataPoints) {
+ // For each data point in the series (usually just 1)
+ foreach ($nodeDataPoints as $point_id => $dataPoint) {
+ $pName = $dataPoint['name'];
+
+ switch ($dataPoint['type']) {
+ /* We only collect the status and server variables here to
+ * read them all in one query,
+ * and only afterwards assign them.
+ * Also do some white list filtering on the names
+ */
+ case 'servervar':
+ if (! preg_match('/[^a-zA-Z_]+/', $pName)) {
+ $serverVars[] = $pName;
+ }
+ break;
+
+ case 'statusvar':
+ if (! preg_match('/[^a-zA-Z_]+/', $pName)) {
+ $statusVars[] = $pName;
+ }
+ break;
+
+ case 'proc':
+ $result = PMA_DBI_query('SHOW PROCESSLIST');
+ $ret[$chart_id][$node_id][$point_id]['value']
+ = PMA_DBI_num_rows($result);
+ break;
+
+ case 'cpu':
+ if (!$sysinfo) {
+ include_once 'libraries/sysinfo.lib.php';
+ $sysinfo = PMA_getSysInfo();
+ }
+ if (!$cpuload) {
+ $cpuload = $sysinfo->loadavg();
+ }
+
+ if (PMA_getSysInfoOs() == 'Linux') {
+ $ret[$chart_id][$node_id][$point_id]['idle']
+ = $cpuload['idle'];
+ $ret[$chart_id][$node_id][$point_id]['busy']
+ = $cpuload['busy'];
+ } else {
+ $ret[$chart_id][$node_id][$point_id]['value']
+ = $cpuload['loadavg'];
+ }
+
+ break;
+
+ case 'memory':
+ if (!$sysinfo) {
+ include_once 'libraries/sysinfo.lib.php';
+ $sysinfo = PMA_getSysInfo();
+ }
+ if (!$memory) {
+ $memory = $sysinfo->memory();
+ }
+
+ $ret[$chart_id][$node_id][$point_id]['value']
+ = $memory[$pName];
+ break;
+ } /* switch */
+ } /* foreach */
+ } /* foreach */
+ } /* foreach */
+
+ // Retrieve all required status variables
+ if (count($statusVars)) {
+ $statusVarValues = PMA_DBI_fetch_result(
+ "SHOW GLOBAL STATUS WHERE Variable_name='"
+ . implode("' OR Variable_name='", $statusVars) . "'",
+ 0,
+ 1
+ );
+ } else {
+ $statusVarValues = array();
+ }
+
+ // Retrieve all required server variables
+ if (count($serverVars)) {
+ $serverVarValues = PMA_DBI_fetch_result(
+ "SHOW GLOBAL VARIABLES WHERE Variable_name='"
+ . implode("' OR Variable_name='", $serverVars) . "'",
+ 0,
+ 1
+ );
+ } else {
+ $serverVarValues = array();
+ }
+
+ // ...and now assign them
+ foreach ($ret as $chart_id => $chartNodes) {
+ foreach ($chartNodes as $node_id => $nodeDataPoints) {
+ foreach ($nodeDataPoints as $point_id => $dataPoint) {
+ switch($dataPoint['type']) {
+ case 'statusvar':
+ $ret[$chart_id][$node_id][$point_id]['value']
+ = $statusVarValues[$dataPoint['name']];
+ break;
+ case 'servervar':
+ $ret[$chart_id][$node_id][$point_id]['value']
+ = $serverVarValues[$dataPoint['name']];
+ break;
+ }
+ }
+ }
+ }
+
+ $ret['x'] = microtime(true) * 1000;
+
+ exit(json_encode($ret));
+ }
+ }
+
+ if (isset($_REQUEST['log_data'])) {
+ if (PMA_MYSQL_INT_VERSION < 50106) {
+ // Table logging is only available since 5.1.6
+ exit('""');
+ }
+
+ $start = intval($_REQUEST['time_start']);
+ $end = intval($_REQUEST['time_end']);
+
+ if ($_REQUEST['type'] == 'slow') {
+ $q = 'SELECT start_time, user_host, ';
+ $q .= 'Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, ';
+ $q .= 'Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, ';
+ $q .= 'SUM(rows_sent) AS rows_sent, ';
+ $q .= 'SUM(rows_examined) AS rows_examined, db, sql_text, ';
+ $q .= 'COUNT(sql_text) AS \'#\' ';
+ $q .= 'FROM `mysql`.`slow_log` ';
+ $q .= 'WHERE start_time > FROM_UNIXTIME(' . $start . ') ';
+ $q .= 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
+
+ $result = PMA_DBI_try_query($q);
+
+ $return = array('rows' => array(), 'sum' => array());
+ $type = '';
+
+ while ($row = PMA_DBI_fetch_assoc($result)) {
+ $type = strtolower(
+ substr($row['sql_text'], 0, strpos($row['sql_text'], ' '))
+ );
+
+ switch($type) {
+ case 'insert':
+ case 'update':
+ //Cut off big inserts and updates, but append byte count instead
+ if (strlen($row['sql_text']) > 220) {
+ $implode_sql_text = implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ strlen($row['sql_text']), 2, 2
+ )
+ );
+ $row['sql_text'] = substr($row['sql_text'], 0, 200)
+ . '... [' . $implode_sql_text . ']';
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (! isset($return['sum'][$type])) {
+ $return['sum'][$type] = 0;
+ }
+ $return['sum'][$type] += $row['#'];
+ $return['rows'][] = $row;
+ }
+
+ $return['sum']['TOTAL'] = array_sum($return['sum']);
+ $return['numRows'] = count($return['rows']);
+
+ PMA_DBI_free_result($result);
+
+ exit(json_encode($return));
+ }
+
+ if ($_REQUEST['type'] == 'general') {
+ $limitTypes = '';
+ if (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes']) {
+ $limitTypes
+ = 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ';
+ }
+
+ $q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, ';
+ $q .= 'server_id, argument, count(argument) as \'#\' ';
+ $q .= 'FROM `mysql`.`general_log` ';
+ $q .= 'WHERE command_type=\'Query\' ';
+ $q .= 'AND event_time > FROM_UNIXTIME(' . $start . ') ';
+ $q .= 'AND event_time < FROM_UNIXTIME(' . $end . ') ';
+ $q .= $limitTypes . 'GROUP by argument'; // HAVING count > 1';
+
+ $result = PMA_DBI_try_query($q);
+
+ $return = array('rows' => array(), 'sum' => array());
+ $type = '';
+ $insertTables = array();
+ $insertTablesFirst = -1;
+ $i = 0;
+ $removeVars = isset($_REQUEST['removeVariables'])
+ && $_REQUEST['removeVariables'];
+
+ while ($row = PMA_DBI_fetch_assoc($result)) {
+ preg_match('/^(\w+)\s/', $row['argument'], $match);
+ $type = strtolower($match[1]);
+
+ if (! isset($return['sum'][$type])) {
+ $return['sum'][$type] = 0;
+ }
+ $return['sum'][$type] += $row['#'];
+
+ switch($type) {
+ case 'insert':
+ // Group inserts if selected
+ if ($removeVars
+ && preg_match(
+ '/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',
+ $row['argument'], $matches
+ )
+ ) {
+ $insertTables[$matches[2]]++;
+ if ($insertTables[$matches[2]] > 1) {
+ $return['rows'][$insertTablesFirst]['#']
+ = $insertTables[$matches[2]];
+
+ // Add a ... to the end of this query to indicate that
+ // there's been other queries
+ $temp = $return['rows'][$insertTablesFirst]['argument'];
+ if ($temp[strlen($temp) - 1] != '.') {
+ $return['rows'][$insertTablesFirst]['argument']
+ .= '
...';
+ }
+
+ // Group this value, thus do not add to the result list
+ continue 2;
+ } else {
+ $insertTablesFirst = $i;
+ $insertTables[$matches[2]] += $row['#'] - 1;
+ }
+ }
+ // No break here
+
+ case 'update':
+ // Cut off big inserts and updates,
+ // but append byte count therefor
+ if (strlen($row['argument']) > 220) {
+ $row['argument'] = substr($row['argument'], 0, 200)
+ . '... ['
+ . implode(
+ ' ',
+ PMA_Util::formatByteDown(
+ strlen($row['argument'])
+ ),
+ 2,
+ 2
+ )
+ . ']';
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ $return['rows'][] = $row;
+ $i++;
+ }
+
+ $return['sum']['TOTAL'] = array_sum($return['sum']);
+ $return['numRows'] = count($return['rows']);
+
+ PMA_DBI_free_result($result);
+
+ exit(json_encode($return));
+ }
+ }
+
+ if (isset($_REQUEST['logging_vars'])) {
+ if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
+ $value = PMA_Util::sqlAddSlashes($_REQUEST['varValue']);
+ if (! is_numeric($value)) {
+ $value="'" . $value . "'";
+ }
+
+ if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) {
+ PMA_DBI_query(
+ 'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value
+ );
+ }
+
+ }
+
+ $loggingVars = PMA_DBI_fetch_result(
+ 'SHOW GLOBAL VARIABLES WHERE Variable_name IN'
+ . ' ("general_log","slow_query_log","long_query_time","log_output")',
+ 0,
+ 1
+ );
+ exit(json_encode($loggingVars));
+ }
+
+ if (isset($_REQUEST['query_analyzer'])) {
+ $return = array();
+
+ if (strlen($_REQUEST['database'])) {
+ PMA_DBI_select_db($_REQUEST['database']);
+ }
+
+ if ($profiling = PMA_Util::profilingSupported()) {
+ PMA_DBI_query('SET PROFILING=1;');
+ }
+
+ // Do not cache query
+ $query = preg_replace(
+ '/^(\s*SELECT)/i',
+ '\\1 SQL_NO_CACHE',
+ $_REQUEST['query']
+ );
+
+ $result = PMA_DBI_try_query($query);
+ $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
+
+ $result = PMA_DBI_try_query('EXPLAIN ' . $query);
+ while ($row = PMA_DBI_fetch_assoc($result)) {
+ $return['explain'][] = $row;
+ }
+
+ // In case an error happened
+ $return['error'] = PMA_DBI_getError();
+
+ PMA_DBI_free_result($result);
+
+ if ($profiling) {
+ $return['profiling'] = array();
+ $result = PMA_DBI_try_query(
+ 'SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING'
+ . ' WHERE QUERY_ID=1 ORDER BY seq'
+ );
+ while ($row = PMA_DBI_fetch_assoc($result)) {
+ $return['profiling'][]= $row;
+ }
+ PMA_DBI_free_result($result);
+ }
+
+ exit(json_encode($return));
+ }
+}
+
+/**
+ * JS Includes
+ */
+$header = $response->getHeader();
+$scripts = $header->getScripts();
+$scripts->addFile('server_status_monitor.js');
+$scripts->addFile('jquery/jquery.tablesorter.js');
+$scripts->addFile('jquery/jquery.json-2.2.js');
+$scripts->addFile('jquery/jquery.sortableTable.js');
+$scripts->addFile('jquery/timepicker.js');
+/* < IE 9 doesn't support canvas natively */
+if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
+ $scripts->addFile('jqplot/excanvas.js');
+}
+$scripts->addFile('canvg/canvg.js');
+// for charting
+$scripts->addFile('jqplot/jquery.jqplot.js');
+$scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js');
+$scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js');
+$scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
+$scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js');
+$scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
+$scripts->addFile('jqplot/plugins/jqplot.cursor.js');
+$scripts->addFile('date.js');
+
+/**
+ * start output
+ */
+$ServerStatusData = new PMA_ServerStatusData('server_status_monitor.php');
+
+echo '
';
+echo $ServerStatusData->getMenuHtml();
+echo getPrintMonitorHtml($ServerStatusData);
+/**
+ * Define some data needed on the client side
+ */
+$input = '
';
+echo '
';
+echo '
';
+echo PMA_Util::showMySQLDocu('general-thread-states', 'general-thread-states');
+echo '
';
+echo '
';
+echo PMA_Util::showMySQLDocu('explain-output', 'explain-output');
+echo '
';
+echo '
';
+
+exit;
+
+/**
+ * Prints html with monitor
+ *
+ * @return void
+ */
+function getPrintMonitorHtml($ServerStatusData)
+{
+ $retval = '
';
+
+ $retval .= '';
+
+ $retval .= '
';
+ $retval .= __(
+ '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%'
+ );
+
+ if (PMA_MYSQL_INT_VERSION < 50106) {
+ $retval .= '
';
+ $retval .= PMA_Util::getImage('s_attention.png');
+ $retval .= __(
+ '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.'
+ );
+ $retval .= '
';
+ } else {
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= __('Using the monitor:');
+ $retval .= ' ';
+ $retval .= __(
+ '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.'
+ );
+ $retval .= '
';
+ $retval .= __(
+ '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.');
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= PMA_Util::getImage('s_attention.png');
+ $retval .= '';
+ $retval .= __('Please note:');
+ $retval .= ' ';
+ $retval .= __(
+ '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.'
+ );
+ $retval .= '
';
+ $retval .= '
';
+ }
+ $retval .= '
';
+
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
' . __('Preset chart') . ' ';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
' . __('Status variable(s)') . ' ';
+ $retval .= '
';
+ $retval .= '
' . __('Select series:') . ' ';
+ $retval .= '
';
+ $retval .= '' . __('Commonly monitored') . ' ';
+ $retval .= 'Processes ';
+ $retval .= 'Questions ';
+ $retval .= 'Connections ';
+ $retval .= 'Bytes_sent ';
+ $retval .= 'Bytes_received ';
+ $retval .= 'Threads_connected ';
+ $retval .= 'Created_tmp_disk_tables ';
+ $retval .= 'Handler_read_first ';
+ $retval .= 'Innodb_buffer_pool_wait_free ';
+ $retval .= 'Key_reads ';
+ $retval .= 'Open_tables ';
+ $retval .= 'Select_full_join ';
+ $retval .= 'Slow_queries ';
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= __('or type variable name:');
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= ' ';
+ $retval .= '(' . __('KiB') . ' , ' . __('MiB') . ' )';
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= '
' . __('Append unit to data values') . ' ';
+ $retval .= '
';
+ $retval .= ' ';
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= '' . __('Add this series') . ' ';
+ $retval .= '';
+ $retval .= ' | ' . __('Clear series') . ' ';
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= __('Series in Chart:');
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '' . __('None') . ' ';
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+
+ $retval .= '
';
+
+ if (! PMA_DRIZZLE) {
+ $retval .= '
';
+ $retval .= '
' . __('Selected time range:');
+ $retval .= ' - ';
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements');
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= __('Remove variable data in INSERT statements for better grouping');
+ $retval .= ' ';
+ $retval .= '
';
+ $retval .= __('Choose from which log you want the statistics to be generated from.');
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= __('Results are grouped by query text.');
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= '
';
+ }
+
+ $retval .= '
';
+ $retval .= '
';
+ $retval .= ' ';
+ $retval .= '
';
+
+ $retval .= '';
+
+ return $retval;
+}
+
+/**
+ * Builds a
list for refresh rates
+ *
+ * @param string $name Name of select
+ * @param int $defaultRate Currently chosen rate
+ * @param array $refreshRates List of refresh rates
+ *
+ * @return HTML code with select
+ */
+function PMA_getRefreshList($name,
+ $defaultRate = 5,
+ $refreshRates = Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)
+) {
+ $return = '';
+ foreach ($refreshRates as $rate) {
+ $selected = ($rate == $defaultRate)?' selected="selected"':'';
+ $return .= '';
+ if ($rate < 60) {
+ $return .= sprintf(_ngettext('%d second', '%d seconds', $rate), $rate);
+ } else {
+ $rate = $rate / 60;
+ $return .= sprintf(_ngettext('%d minute', '%d minutes', $rate), $rate);
+ }
+ $return .= ' ';
+ }
+ $return .= ' ';
+ return $return;
+}
+
+?>
diff --git a/server_status_queries.php b/server_status_queries.php
index 5ab6f0864b..37d7908859 100644
--- a/server_status_queries.php
+++ b/server_status_queries.php
@@ -16,7 +16,7 @@ if (PMA_DRIZZLE) {
include_once 'libraries/replication_gui.lib.php';
}
-$ServerStatusData = new PMA_ServerStatusData('server_status_qyuries.php');
+$ServerStatusData = new PMA_ServerStatusData('server_status_queries.php');
$response = PMA_Response::getInstance();
$header = $response->getHeader();
@@ -38,7 +38,7 @@ $scripts->addFile('jqplot/plugins/jqplot.cursor.js');
// Add the html content to the response
$response->addHTML('');
-$response->addHTML(PMA_ServerStatusData::getMenuHtml());
+$response->addHTML($ServerStatusData->getMenuHtml());
$response->addHTML(getQueryStatisticsHtml($ServerStatusData));
$response->addHTML('
');
exit;
diff --git a/server_status_variables.php b/server_status_variables.php
index 4314482313..d6d8a2a225 100644
--- a/server_status_variables.php
+++ b/server_status_variables.php
@@ -16,6 +16,22 @@ if (PMA_DRIZZLE) {
include_once 'libraries/replication_gui.lib.php';
}
+/**
+ * flush status variables if requested
+ */
+if (isset($_REQUEST['flush'])) {
+ $_flush_commands = array(
+ 'STATUS',
+ 'TABLES',
+ 'QUERY CACHE',
+ );
+
+ if (in_array($_REQUEST['flush'], $_flush_commands)) {
+ PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';');
+ }
+ unset($_flush_commands);
+}
+
$ServerStatusData = new PMA_ServerStatusData('server_status_variables.php');
$response = PMA_Response::getInstance();
@@ -24,7 +40,7 @@ $scripts = $header->getScripts();
$scripts->addFile('server_status_variables.js');
$response->addHTML('');
-$response->addHTML(PMA_ServerStatusData::getMenuHtml());
+$response->addHTML($ServerStatusData->getMenuHtml());
$response->addHTML(getFilterHtml($ServerStatusData));
$response->addHTML(getLinkSuggestionsHtml($ServerStatusData));
$response->addHTML(getVariablesTableHtml($ServerStatusData));
diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php
index 5dcd19e261..4221682db3 100644
--- a/themes/original/css/common.css.php
+++ b/themes/original/css/common.css.php
@@ -1017,10 +1017,6 @@ img.sortableIcon {
white-space: nowrap;
}
-.jsfeature {
- display: none; /* Made visible with js */
-}
-
/* Also used for the variables page */
fieldset#tableFilter {
margin-bottom:1em;
diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php
index 126c21e8f3..32a9a42b4e 100644
--- a/themes/pmahomme/css/common.css.php
+++ b/themes/pmahomme/css/common.css.php
@@ -1262,10 +1262,6 @@ img.sortableIcon {
white-space: nowrap;
}
-.jsfeature {
- display: none; /* Made visible with js */
-}
-
/* Also used for the variables page */
fieldset#tableFilter {
margin-bottom: 1em;