Merge branch 'master' of github.com:phpmyadmin/phpmyadmin
This commit is contained in:
commit
68b61d9275
46
js/jqplot/plugins/jqplot.byteFormatter.js
Normal file
46
js/jqplot/plugins/jqplot.byteFormatter.js
Normal file
@ -0,0 +1,46 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* jqplot formatter for byte values
|
||||
*
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
(function($) {
|
||||
"use strict";
|
||||
var formatByte = function (val, index) {
|
||||
var units = [
|
||||
PMA_messages.strB,
|
||||
PMA_messages.strKiB,
|
||||
PMA_messages.strMiB,
|
||||
PMA_messages.strGiB,
|
||||
PMA_messages.strTiB,
|
||||
PMA_messages.strPiB,
|
||||
PMA_messages.strEiB
|
||||
];
|
||||
while (val >= 1024 && index <= 6) {
|
||||
val /= 1024;
|
||||
index++;
|
||||
}
|
||||
var format = '%.1f';
|
||||
if (Math.floor(val) === val) {
|
||||
format = '%.0f';
|
||||
}
|
||||
return $.jqplot.sprintf(
|
||||
format + ' ' + units[index], val
|
||||
);
|
||||
};
|
||||
/**
|
||||
* The index indicates what unit the incoming data will be in.
|
||||
* 0 for bytes, 1 for kilobytes and so on...
|
||||
*/
|
||||
$.jqplot.byteFormatter = function (index) {
|
||||
index = index || 0;
|
||||
return function (format, val) {
|
||||
if (typeof val === 'number') {
|
||||
val = parseFloat(val) || 0;
|
||||
return formatByte(val, index);
|
||||
} else {
|
||||
return String(val);
|
||||
}
|
||||
};
|
||||
};
|
||||
})(jQuery);
|
||||
@ -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');
|
||||
@ -97,8 +86,6 @@ $js_messages['strQueryCacheUsed'] = __('Query cache used');
|
||||
$js_messages['strSystemCPUUsage'] = __('System CPU Usage');
|
||||
$js_messages['strSystemMemory'] = __('System memory');
|
||||
$js_messages['strSystemSwap'] = __('System swap');
|
||||
$js_messages['strMiB'] = __('MiB');
|
||||
$js_messages['strKiB'] = __('KiB');
|
||||
|
||||
$js_messages['strAverageLoad'] = __('Average load');
|
||||
$js_messages['strTotalMemory'] = __('Total memory');
|
||||
|
||||
@ -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,26 +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');
|
||||
$('div.buttonlinks a.livetrafficLink').unbind('click');
|
||||
$('div.buttonlinks a.liveconnectionsLink').unbind('click');
|
||||
$('div.buttonlinks a.livequeriesLink').unbind('click');
|
||||
|
||||
$('#filterAlert').unbind('change');
|
||||
$('#filterText').unbind('keyup');
|
||||
$('#filterCategory').unbind('change');
|
||||
$('input#dontFormat').unbind('change');
|
||||
$('a[href="#openAdvisorInstructions"]').unbind('click');
|
||||
$('a[href="#startAnalyzer"]').unbind('click');
|
||||
});
|
||||
|
||||
// Add a tablesorter parser to properly handle thousands seperated numbers and SI prefixes
|
||||
AJAX.registerOnload('server_status.js', function() {
|
||||
|
||||
@ -51,787 +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 class="original"/.test(s);
|
||||
},
|
||||
format: function(s, table, html) {
|
||||
var res = html.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/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);
|
||||
}
|
||||
// Replot on tab switching
|
||||
if (ui.tab.hash == '#statustabs_traffic' && tabChart['statustabs_traffic'] != null) {
|
||||
recursiveTimer($('#statustabs_traffic'), "traffic");
|
||||
}
|
||||
else if (ui.tab.hash == '#statustabs_queries' && tabChart['statustabs_queries'] != null) {
|
||||
recursiveTimer($('#statustabs_queries'), "queries");
|
||||
}
|
||||
// Load Server status monitor
|
||||
if (ui.tab.hash == '#statustabs_charting' && ! monitorLoaded) {
|
||||
$('div#statustabs_charting').append( //PMA_messages['strLoadingMonitor'] + ' ' +
|
||||
'<img class="ajaxIcon" id="loadingMonitorIcon" src="' +
|
||||
pmaThemeImage + 'ajax_clock_small.gif" alt="">'
|
||||
);
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Run the advisor immediately when the user clicks the tab, but only when this is the first time
|
||||
if (ui.tab.hash == '#statustabs_advisor' && $('table#rulesFired').length == 0) {
|
||||
// Start with a small delay because the click event hasn't been setup yet
|
||||
setTimeout(function() {
|
||||
$('a[href="#startAnalyzer"]').trigger('click');
|
||||
}, 25);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
// Handles refresh rate changing
|
||||
$('.buttonlinks .refreshRate').change(function() {
|
||||
|
||||
var $tab = $(this).parents('div.ui-tabs-panel');
|
||||
clearTimeout(chart_replot_timers[$tab.attr('id')]);
|
||||
var tabstat = tabStatus[$tab.attr('id')];
|
||||
|
||||
if(tabstat == 'livequeries') {
|
||||
recursiveTimer($tab, 'queries');
|
||||
} else if(tabstat == 'livetraffic') {
|
||||
recursiveTimer($tab, 'traffic');
|
||||
} else if(tabstat == 'liveconnections') {
|
||||
recursiveTimer($tab, 'proc');
|
||||
}
|
||||
|
||||
var chart = tabChart[$(this).parents('div.ui-tabs-panel').attr('id')];
|
||||
// Clear current timeout and set timeout with the new refresh rate
|
||||
clearTimeout(chart_activeTimeouts[chart.options.chart.renderTo]);
|
||||
if (chart.options.realtime.postRequest) {
|
||||
chart.options.realtime.postRequest.abort();
|
||||
}
|
||||
|
||||
chart.options.realtime.refreshRate = 1000*parseInt(this.value);
|
||||
|
||||
chart.xAxis[0].setExtremes(
|
||||
new Date().getTime() - server_time_diff - chart.options.realtime.numMaxPoints * chart.options.realtime.refreshRate,
|
||||
new Date().getTime() - server_time_diff,
|
||||
true
|
||||
);
|
||||
|
||||
chart_activeTimeouts[chart.options.chart.renderTo] = setTimeout(
|
||||
chart.options.realtime.timeoutCallBack,
|
||||
chart.options.realtime.refreshRate
|
||||
);
|
||||
});
|
||||
|
||||
// Ajax refresh of variables (always the first element in each tab)
|
||||
$('div.buttonlinks a.tabRefresh').click(function() {
|
||||
// ui-tabs-panel class is added by the jquery tabs feature
|
||||
var tab = $(this).parents('div.ui-tabs-panel');
|
||||
var that = this;
|
||||
|
||||
// Show ajax load icon
|
||||
$(this).find('img').show();
|
||||
|
||||
$.get($(this).attr('href'), { ajax_request: 1 }, function(data) {
|
||||
$(that).find('img').hide();
|
||||
initTab(tab, data);
|
||||
});
|
||||
|
||||
tabStatus[tab.attr('id')] = 'data';
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
/** Realtime charting of variables **/
|
||||
|
||||
// variables to hold previous y data value to calculate difference
|
||||
var previous_y_line1 = new Object();
|
||||
var previous_y_line2 = new Object();
|
||||
var series = new Object();
|
||||
|
||||
// Live traffic charting
|
||||
$('div.buttonlinks a.livetrafficLink').click(function() {
|
||||
// ui-tabs-panel class is added by the jquery tabs feature
|
||||
var $tab = $(this).parents('div.ui-tabs-panel');
|
||||
var tabstat = tabStatus[$tab.attr('id')];
|
||||
|
||||
if (tabstat == 'static' || tabstat == 'liveconnections') {
|
||||
|
||||
setupLiveChart($tab, this, getSettings('traffic'));
|
||||
var set_previous = getCurrentDataSet($tab, 'traffic');
|
||||
tabChart[$tab.attr('id')] = $.jqplot($tab.attr('id') + '_chart_cnt', [[[0,0]],[[0,0]]], getSettings('traffic'));
|
||||
recursiveTimer($tab, 'traffic');
|
||||
|
||||
if (tabstat == 'liveconnections') {
|
||||
$tab.find('.buttonlinks a.liveconnectionsLink').html(PMA_messages['strLiveConnChart']);
|
||||
}
|
||||
tabStatus[$tab.attr('id')] = 'livetraffic';
|
||||
} else {
|
||||
$(this).html(PMA_messages['strLiveTrafficChart']);
|
||||
setupLiveChart($tab, this, null);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Live connection/process charting
|
||||
$('div.buttonlinks a.liveconnectionsLink').click(function() {
|
||||
var $tab = $(this).parents('div.ui-tabs-panel');
|
||||
var tabstat = tabStatus[$tab.attr('id')];
|
||||
|
||||
if (tabstat == 'static' || tabstat == 'livetraffic') {
|
||||
|
||||
setupLiveChart($tab, this, getSettings('proc'));
|
||||
var set_previous = getCurrentDataSet($tab, 'proc');
|
||||
tabChart[$tab.attr('id')] = $.jqplot($tab.attr('id') + '_chart_cnt', [[[0,0]],[[0,0]]], getSettings('proc'));
|
||||
recursiveTimer($tab, 'proc');
|
||||
if (tabstat == 'livetraffic') {
|
||||
$tab.find('.buttonlinks a.livetrafficLink').html(PMA_messages['strLiveTrafficChart']);
|
||||
}
|
||||
tabStatus[$tab.attr('id')] = 'liveconnections';
|
||||
} else {
|
||||
$(this).html(PMA_messages['strLiveConnChart']);
|
||||
setupLiveChart($tab, this, null);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Live query statistics
|
||||
$('div.buttonlinks a.livequeriesLink').click(function() {
|
||||
var $tab = $(this).parents('div.ui-tabs-panel');
|
||||
if (tabStatus[$tab.attr('id')] == 'static') {
|
||||
|
||||
setupLiveChart($tab, this, getSettings('queries'));
|
||||
var set_previous = getCurrentDataSet($tab, 'queries');
|
||||
tabChart[$tab.attr('id')] = $.jqplot($tab.attr('id') + '_chart_cnt', [[0,0]], getSettings('queries'));
|
||||
recursiveTimer($tab, 'queries');
|
||||
tabStatus[$tab.attr('id')] = 'livequeries';
|
||||
|
||||
} else {
|
||||
$(this).html(PMA_messages['strLiveQueryChart']);
|
||||
setupLiveChart($tab, this, null);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
function setupLiveChart($tab, link, settings) {
|
||||
if (settings != null) {
|
||||
// Loading a chart with existing chart => remove old chart first
|
||||
if (tabStatus[$tab.attr('id')] != 'static') {
|
||||
clearTimeout(chart_activeTimeouts[$tab.attr('id') + "_chart_cnt"]);
|
||||
chart_activeTimeouts[$tab.attr('id') + "_chart_cnt"] = null;
|
||||
delete tabChart[$tab.attr('id')];
|
||||
// Also reset the select list
|
||||
$tab.find('.buttonlinks select').get(0).selectedIndex = 2;
|
||||
}
|
||||
|
||||
if (! settings.chart) settings.chart = {};
|
||||
settings.chart.renderTo = $tab.attr('id') + "_chart_cnt";
|
||||
|
||||
if($('#' + $tab.attr('id') + '_chart_cnt').length == 0) {
|
||||
$tab.find('.tabInnerContent')
|
||||
.hide()
|
||||
.after('<div class="liveChart" id="' + $tab.attr('id') + '_chart_cnt"></div>');
|
||||
}
|
||||
$(link).html(PMA_messages['strStaticData']);
|
||||
$tab.find('.buttonlinks a.tabRefresh').hide();
|
||||
$tab.find('.buttonlinks .refreshList').show();
|
||||
} else {
|
||||
clearTimeout(chart_activeTimeouts[$tab.attr('id') + "_chart_cnt"]);
|
||||
chart_activeTimeouts[$tab.attr('id') + "_chart_cnt"] = null;
|
||||
$tab.find('.tabInnerContent').show();
|
||||
$tab.find('div#' + $tab.attr('id') + '_chart_cnt').remove();
|
||||
tabStatus[$tab.attr('id')] = 'static';
|
||||
delete tabChart[$tab.attr('id')];
|
||||
$tab.find('.buttonlinks a.tabRefresh').show();
|
||||
$tab.find('.buttonlinks select').get(0).selectedIndex = 2;
|
||||
$tab.find('.buttonlinks .refreshList').hide();
|
||||
}
|
||||
clearTimeout(chart_replot_timers[$tab.attr('id')]);
|
||||
previous_y_line1[$tab.attr('id')] = 0;
|
||||
previous_y_line2[$tab.attr('id')] = 0;
|
||||
series[$tab.attr('id')] = new Array();
|
||||
series[$tab.attr('id')][0] = new Array();
|
||||
series[$tab.attr('id')][1] = new Array();
|
||||
}
|
||||
|
||||
/* 3 Filtering functions */
|
||||
$('#filterAlert').change(function() {
|
||||
alertFilter = this.checked;
|
||||
filterVariables();
|
||||
});
|
||||
|
||||
$('#filterText').keyup(function(e) {
|
||||
var word = $(this).val().replace(/_/g, ' ');
|
||||
|
||||
if (word.length == 0) {
|
||||
textFilter = null;
|
||||
} else {
|
||||
textFilter = new RegExp("(^| )" + word, 'i');
|
||||
}
|
||||
|
||||
text = word;
|
||||
|
||||
filterVariables();
|
||||
});
|
||||
|
||||
$('#filterCategory').change(function() {
|
||||
categoryFilter = $(this).val();
|
||||
filterVariables();
|
||||
});
|
||||
|
||||
$('input#dontFormat').change(function() {
|
||||
// Hiding the table while changing values speeds up the process a lot
|
||||
$('#serverstatusvariables').hide();
|
||||
$('#serverstatusvariables td.value span.original').toggle(this.checked);
|
||||
$('#serverstatusvariables td.value span.formatted').toggle(! this.checked);
|
||||
$('#serverstatusvariables').show();
|
||||
});
|
||||
|
||||
/* 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;
|
||||
case 'statustabs_queries':
|
||||
if (data != null) {
|
||||
queryPieChart.destroy();
|
||||
tab.find('.tabInnerContent').html(data.message);
|
||||
}
|
||||
|
||||
// Build query statistics chart
|
||||
var cdata = new Array();
|
||||
$.each(jQuery.parseJSON($('#serverstatusquerieschart span').html()), function(key, value) {
|
||||
cdata.push([key, parseInt(value)]);
|
||||
});
|
||||
|
||||
queryPieChart = PMA_createProfilingChartJqplot(
|
||||
'serverstatusquerieschart',
|
||||
cdata
|
||||
);
|
||||
|
||||
initTableSorter(tab.attr('id'));
|
||||
break;
|
||||
|
||||
case 'statustabs_allvars':
|
||||
if (data != null) {
|
||||
tab.find('.tabInnerContent').html(data.message);
|
||||
filterVariables();
|
||||
}
|
||||
initTableSorter(tab.attr('id'));
|
||||
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('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');
|
||||
}
|
||||
|
||||
/* Filters the status variables by name/category/alert in the variables tab */
|
||||
function filterVariables() {
|
||||
var useful_links = 0;
|
||||
var section = text;
|
||||
|
||||
if (categoryFilter.length > 0) {
|
||||
section = categoryFilter;
|
||||
}
|
||||
|
||||
if (section.length > 1) {
|
||||
$('#linkSuggestions span').each(function() {
|
||||
if ($(this).attr('class').indexOf('status_' + section) != -1) {
|
||||
useful_links++;
|
||||
$(this).css('display', '');
|
||||
} else {
|
||||
$(this).css('display', 'none');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (useful_links > 0) {
|
||||
$('#linkSuggestions').css('display', '');
|
||||
} else {
|
||||
$('#linkSuggestions').css('display', 'none');
|
||||
}
|
||||
|
||||
odd_row = false;
|
||||
$('#serverstatusvariables th.name').each(function() {
|
||||
if ((textFilter == null || textFilter.exec($(this).text()))
|
||||
&& (! alertFilter || $(this).next().find('span.attention').length>0)
|
||||
&& (categoryFilter.length == 0 || $(this).parent().hasClass('s_' + categoryFilter))
|
||||
) {
|
||||
odd_row = ! odd_row;
|
||||
$(this).parent().css('display', '');
|
||||
if (odd_row) {
|
||||
$(this).parent().addClass('odd');
|
||||
$(this).parent().removeClass('even');
|
||||
} else {
|
||||
$(this).parent().addClass('even');
|
||||
$(this).parent().removeClass('odd');
|
||||
}
|
||||
} else {
|
||||
$(this).parent().css('display', 'none');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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 = '<b>' + PMA_messages['strTotal'] + ': ' + sumTotal + '</b><br>';
|
||||
|
||||
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] + '<br>';
|
||||
}
|
||||
|
||||
queryKeys.splice(maxIdx, 1);
|
||||
queryValues.splice(maxIdx, 1);
|
||||
num++;
|
||||
}
|
||||
|
||||
if (sumOther>0) {
|
||||
pointInfo += PMA_messages['strOther'] + ': ' + sumOther;
|
||||
}
|
||||
|
||||
return pointInfo;
|
||||
}
|
||||
|
||||
/**** Server config advisor ****/
|
||||
|
||||
$('a[href="#openAdvisorInstructions"]').click(function() {
|
||||
var dlgBtns = {};
|
||||
|
||||
dlgBtns[PMA_messages['strClose']] = function() {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
$('#advisorInstructionsDialog').attr('title', PMA_messages['strAdvisorSystem']);
|
||||
$('#advisorInstructionsDialog').dialog({
|
||||
width: 700,
|
||||
buttons: dlgBtns
|
||||
});
|
||||
});
|
||||
|
||||
$('a[href="#startAnalyzer"]').click(function() {
|
||||
var $cnt = $('#statustabs_advisor .tabInnerContent');
|
||||
$cnt.html('<img class="ajaxIcon" src="' + pmaThemeImage + 'ajax_clock_small.gif" alt="">');
|
||||
|
||||
$.get('server_status.php?' + url_query, { ajax_request: true, advisor: true }, function(data) {
|
||||
var $tbody, $tr, str, even = true;
|
||||
|
||||
data = $.parseJSON(data.message);
|
||||
|
||||
$cnt.html('');
|
||||
|
||||
if (data.parse.errors.length > 0) {
|
||||
$cnt.append('<b>Rules file not well formed, following errors were found:</b><br />- ');
|
||||
$cnt.append(data.parse.errors.join('<br/>- '));
|
||||
$cnt.append('<p></p>');
|
||||
}
|
||||
|
||||
if (data.run.errors.length > 0) {
|
||||
$cnt.append('<b>Errors occured while executing rule expressions:</b><br />- ');
|
||||
$cnt.append(data.run.errors.join('<br/>- '));
|
||||
$cnt.append('<p></p>');
|
||||
}
|
||||
|
||||
if (data.run.fired.length > 0) {
|
||||
$cnt.append('<p><b>' + PMA_messages['strPerformanceIssues'] + '</b></p>');
|
||||
$cnt.append('<table class="data" id="rulesFired" border="0"><thead><tr>' +
|
||||
'<th>' + PMA_messages['strIssuse'] + '</th><th>' + PMA_messages['strRecommendation'] +
|
||||
'</th></tr></thead><tbody></tbody></table>');
|
||||
$tbody = $cnt.find('table#rulesFired');
|
||||
|
||||
var rc_stripped;
|
||||
|
||||
$.each(data.run.fired, function(key, value) {
|
||||
// recommendation may contain links, don't show those in overview table (clicking on them redirects the user)
|
||||
rc_stripped = $.trim($('<div>').html(value.recommendation).text());
|
||||
$tbody.append($tr = $('<tr class="linkElem noclick ' + (even ? 'even' : 'odd') + '"><td>' +
|
||||
value.issue + '</td><td>' + rc_stripped + ' </td></tr>'));
|
||||
even = !even;
|
||||
$tr.data('rule', value);
|
||||
|
||||
$tr.click(function() {
|
||||
var rule = $(this).data('rule');
|
||||
$('div#emptyDialog').dialog({title: PMA_messages['strRuleDetails']});
|
||||
$('div#emptyDialog').html(
|
||||
'<p><b>' + PMA_messages['strIssuse'] + ':</b><br />' + rule.issue + '</p>' +
|
||||
'<p><b>' + PMA_messages['strRecommendation'] + ':</b><br />' + rule.recommendation + '</p>' +
|
||||
'<p><b>' + PMA_messages['strJustification'] + ':</b><br />' + rule.justification + '</p>' +
|
||||
'<p><b>' + PMA_messages['strFormula'] + ':</b><br />' + rule.formula + '</p>' +
|
||||
'<p><b>' + PMA_messages['strTest'] + ':</b><br />' + rule.test + '</p>'
|
||||
);
|
||||
|
||||
var dlgBtns = {};
|
||||
dlgBtns[PMA_messages['strClose']] = function() {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
$('div#emptyDialog').dialog({ width: 600, buttons: dlgBtns });
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// 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 });
|
||||
}
|
||||
|
||||
86
js/server_status_advisor.js
Normal file
86
js/server_status_advisor.js
Normal file
@ -0,0 +1,86 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Server Status Advisor
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('server_status_advisor.js', function() {
|
||||
$('a[href="#openAdvisorInstructions"]').unbind('click');
|
||||
$('#statustabs_advisor').html('');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('server_status_advisor.js', function() {
|
||||
/**** Server config advisor ****/
|
||||
|
||||
$('a[href="#openAdvisorInstructions"]').click(function() {
|
||||
var dlgBtns = {};
|
||||
dlgBtns[PMA_messages['strClose']] = function() {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
$('#advisorInstructionsDialog').dialog({
|
||||
title: PMA_messages['strAdvisorSystem'],
|
||||
width: 700,
|
||||
buttons: dlgBtns
|
||||
});
|
||||
});
|
||||
|
||||
var $cnt = $('#statustabs_advisor');
|
||||
var $tbody, $tr, str, even = true;
|
||||
|
||||
data = $.parseJSON($('#advisorData').text());
|
||||
$cnt.html('');
|
||||
|
||||
if (data.parse.errors.length > 0) {
|
||||
$cnt.append('<b>Rules file not well formed, following errors were found:</b><br />- ');
|
||||
$cnt.append(data.parse.errors.join('<br/>- '));
|
||||
$cnt.append('<p></p>');
|
||||
}
|
||||
|
||||
if (data.run.errors.length > 0) {
|
||||
$cnt.append('<b>Errors occured while executing rule expressions:</b><br />- ');
|
||||
$cnt.append(data.run.errors.join('<br/>- '));
|
||||
$cnt.append('<p></p>');
|
||||
}
|
||||
|
||||
if (data.run.fired.length > 0) {
|
||||
$cnt.append('<p><b>' + PMA_messages['strPerformanceIssues'] + '</b></p>');
|
||||
$cnt.append('<table class="data" id="rulesFired" border="0"><thead><tr>' +
|
||||
'<th>' + PMA_messages['strIssuse'] + '</th><th>' + PMA_messages['strRecommendation'] +
|
||||
'</th></tr></thead><tbody></tbody></table>');
|
||||
$tbody = $cnt.find('table#rulesFired');
|
||||
|
||||
var rc_stripped;
|
||||
|
||||
$.each(data.run.fired, function(key, value) {
|
||||
// recommendation may contain links, don't show those in overview table (clicking on them redirects the user)
|
||||
rc_stripped = $.trim($('<div>').html(value.recommendation).text());
|
||||
$tbody.append($tr = $('<tr class="linkElem noclick ' + (even ? 'even' : 'odd') + '"><td>' +
|
||||
value.issue + '</td><td>' + rc_stripped + ' </td></tr>'));
|
||||
even = !even;
|
||||
$tr.data('rule', value);
|
||||
|
||||
$tr.click(function() {
|
||||
var rule = $(this).data('rule');
|
||||
$('div#emptyDialog').dialog({title: PMA_messages['strRuleDetails']});
|
||||
$('div#emptyDialog').html(
|
||||
'<p><b>' + PMA_messages['strIssuse'] + ':</b><br />' + rule.issue + '</p>' +
|
||||
'<p><b>' + PMA_messages['strRecommendation'] + ':</b><br />' + rule.recommendation + '</p>' +
|
||||
'<p><b>' + PMA_messages['strJustification'] + ':</b><br />' + rule.justification + '</p>' +
|
||||
'<p><b>' + PMA_messages['strFormula'] + ':</b><br />' + rule.formula + '</p>' +
|
||||
'<p><b>' + PMA_messages['strTest'] + ':</b><br />' + rule.test + '</p>'
|
||||
);
|
||||
|
||||
var dlgBtns = {};
|
||||
dlgBtns[PMA_messages['strClose']] = function() {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
||||
$('div#emptyDialog').dialog({ width: 600, buttons: dlgBtns });
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -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,15 @@ 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);
|
||||
$('#chartPreset').unbind('click');
|
||||
$('#chartStatusVar').unbind('click');
|
||||
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 +91,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));
|
||||
});
|
||||
@ -54,13 +100,14 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
/**** Monitor charting implementation ****/
|
||||
/* Saves the previous ajax response for differential values */
|
||||
var oldChartData = null;
|
||||
// Holds about to created chart
|
||||
// Holds about to be created chart
|
||||
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 +122,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 +136,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
|
||||
@ -145,20 +194,18 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
nodes: [ {
|
||||
dataPoints: [{ type: 'cpu', name: 'loadavg'}]
|
||||
} ],
|
||||
maxYLabel: 0
|
||||
maxYLabel: 100
|
||||
},
|
||||
|
||||
'memory': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
series: [ {
|
||||
label: PMA_messages['strTotalMemory'],
|
||||
fill:true,
|
||||
stackSeries: true
|
||||
fill:true
|
||||
}, {
|
||||
dataType: 'memory',
|
||||
label: PMA_messages['strUsedMemory'],
|
||||
fill:true,
|
||||
stackSeries: true
|
||||
fill:true
|
||||
} ],
|
||||
nodes: [{ dataPoints: [{ type: 'memory', name: 'MemTotal' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'MemUsed' }], valueDivisor: 1024 }
|
||||
@ -170,12 +217,10 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
series: [ {
|
||||
label: PMA_messages['strTotalSwap'],
|
||||
fill:true,
|
||||
stackSeries: true
|
||||
fill:true
|
||||
}, {
|
||||
label: PMA_messages['strUsedSwap'],
|
||||
fill:true,
|
||||
stackSeries: true
|
||||
fill:true
|
||||
} ],
|
||||
nodes: [{ dataPoints: [{ type: 'memory', name: 'SwapTotal' }]},
|
||||
{ dataPoints: [{ type: 'memory', name: 'SwapUsed' }]}
|
||||
@ -198,15 +243,15 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
'memory': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
series: [
|
||||
{ label: PMA_messages['strUsedMemory'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strCachedMemory'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strBufferedMemory'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strFreeMemory'], fill:true, stackSeries: true}
|
||||
{ label: PMA_messages['strBufferedMemory'], fill:true},
|
||||
{ label: PMA_messages['strUsedMemory'], fill:true},
|
||||
{ label: PMA_messages['strCachedMemory'], fill:true},
|
||||
{ label: PMA_messages['strFreeMemory'], fill:true}
|
||||
],
|
||||
nodes: [
|
||||
{ dataPoints: [{ type: 'memory', name: 'Buffers' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'MemUsed' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'Cached' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'Buffers' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'MemFree' }], valueDivisor: 1024 }
|
||||
],
|
||||
maxYLabel: 0
|
||||
@ -214,13 +259,13 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
'swap': {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
series: [
|
||||
{ label: PMA_messages['strUsedSwap'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strCachedSwap'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strFreeSwap'], fill:true, stackSeries: true}
|
||||
{ label: PMA_messages['strCachedSwap'], fill:true},
|
||||
{ label: PMA_messages['strUsedSwap'], fill:true},
|
||||
{ label: PMA_messages['strFreeSwap'], fill:true}
|
||||
],
|
||||
nodes: [
|
||||
{ dataPoints: [{ type: 'memory', name: 'SwapUsed' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'SwapCached' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'SwapUsed' }], valueDivisor: 1024 },
|
||||
{ dataPoints: [{ type: 'memory', name: 'SwapFree' }], valueDivisor: 1024 }
|
||||
],
|
||||
maxYLabel: 0
|
||||
@ -243,8 +288,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
'memory': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
series: [
|
||||
{ label: PMA_messages['strUsedMemory'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strFreeMemory'], fill:true, stackSeries: true}
|
||||
{ label: PMA_messages['strUsedMemory'], fill:true },
|
||||
{ label: PMA_messages['strFreeMemory'], fill:true }
|
||||
],
|
||||
nodes: [
|
||||
{ dataPoints: [{ type: 'memory', name: 'MemUsed' }], valueDivisor: 1024 },
|
||||
@ -255,8 +300,8 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
'swap': {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
series: [
|
||||
{ label: PMA_messages['strUsedSwap'], fill:true, stackSeries: true},
|
||||
{ label: PMA_messages['strFreeSwap'], fill:true, stackSeries: true}
|
||||
{ label: PMA_messages['strUsedSwap'], fill:true },
|
||||
{ label: PMA_messages['strFreeSwap'], fill:true }
|
||||
],
|
||||
nodes: [
|
||||
{ dataPoints: [{ type: 'memory', name: 'SwapUsed' }], valueDivisor: 1024 },
|
||||
@ -335,14 +380,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 +473,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 +498,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 +539,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 +569,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']);
|
||||
@ -554,8 +602,25 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
$presetList.append('<option value="' + key + '">' + value.title + '</option>');
|
||||
});
|
||||
$presetList.change(function() {
|
||||
$('input#chartPreset').trigger('click');
|
||||
$('input[name="chartTitle"]').val(presetCharts[$(this).val()].title);
|
||||
$('input[name="chartTitle"]').val(
|
||||
$presetList.find(':selected').text()
|
||||
);
|
||||
$('#chartPreset').prop('checked', true);
|
||||
})
|
||||
$('#chartPreset').click(function () {
|
||||
$('input[name="chartTitle"]').val(
|
||||
$presetList.find(':selected').text()
|
||||
);
|
||||
});
|
||||
$('#chartStatusVar').click(function () {
|
||||
$('input[name="chartTitle"]').val(
|
||||
$('#chartSeries').find(':selected').text().replace(/_/, " ")
|
||||
);
|
||||
});
|
||||
$('#chartSeries').change(function () {
|
||||
$('input[name="chartTitle"]').val(
|
||||
$('#chartSeries').find(':selected').text().replace(/_/, " ")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -585,7 +650,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
$('<form />', {
|
||||
"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 +667,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'] + ':<br/><form action="file_echo.php?' + url_query + '&import=1" method="post" enctype="multipart/form-data">' +
|
||||
$('div#emptyDialog').html(PMA_messages['strImportDialogMessage'] + ':<br/><form action="file_echo.php?' + PMA_commonParams.get('common_query') + '&import=1" method="post" enctype="multipart/form-data">' +
|
||||
'<input type="file" name="file"> <input type="hidden" name="import" value="1"> </form>');
|
||||
|
||||
var dlgBtns = {};
|
||||
@ -704,10 +769,15 @@ 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='';
|
||||
var logVars;
|
||||
if (data.success == true) {
|
||||
logVars = data.message;
|
||||
} else {
|
||||
return serverResponseError();
|
||||
}
|
||||
var icon = PMA_getImage('s_success.png'), msg='', str='';
|
||||
|
||||
if (logVars['general_log'] == 'ON') {
|
||||
if (logVars['slow_query_log'] == 'ON') {
|
||||
@ -1008,30 +1078,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() {
|
||||
@ -1103,11 +1149,31 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
}
|
||||
},
|
||||
highlighter: {
|
||||
show: true,
|
||||
showTooltip: false
|
||||
show: true,
|
||||
showTooltip: true,
|
||||
tooltipAxes: 'y',
|
||||
useAxesFormatters: true
|
||||
}
|
||||
};
|
||||
|
||||
if (settings.title === PMA_messages['strSystemCPUUsage']
|
||||
|| settings.title === PMA_messages['strQueryCacheEfficiency']) {
|
||||
settings.axes.yaxis.tickOptions = {
|
||||
formatString: "%d %%"
|
||||
};
|
||||
} else if (settings.title === PMA_messages['strSystemMemory']
|
||||
|| settings.title === PMA_messages['strSystemSwap']
|
||||
) {
|
||||
settings.stackSeries = true;
|
||||
settings.axes.yaxis.tickOptions = {
|
||||
formatter: $.jqplot.byteFormatter(2) // MiB
|
||||
};
|
||||
} else if (settings.title === PMA_messages['strTraffic']) {
|
||||
settings.axes.yaxis.tickOptions = {
|
||||
formatter: $.jqplot.byteFormatter(1) // KiB
|
||||
};
|
||||
}
|
||||
|
||||
settings.series = chartObj.series;
|
||||
|
||||
if ($('#' + 'gridchart' + runtime.chartAI).length == 0) {
|
||||
@ -1127,6 +1193,28 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
}
|
||||
|
||||
chartObj.chart = $.jqplot('gridchart' + runtime.chartAI, series, settings);
|
||||
var $legend = $('<div />').css('padding', '0.5em');
|
||||
for (var i in chartObj.chart.series) {
|
||||
$legend.append(
|
||||
$('<div />').append(
|
||||
$('<div>').css({
|
||||
width: '1em',
|
||||
height: '1em',
|
||||
background: chartObj.chart.seriesColors[i]
|
||||
}).addClass('floatleft')
|
||||
).append(
|
||||
$('<div>').text(
|
||||
chartObj.chart.series[i].label
|
||||
).addClass('floatleft')
|
||||
).append(
|
||||
$('<div class="clearfloat">')
|
||||
).addClass('floatleft')
|
||||
);
|
||||
}
|
||||
$('#gridchart' + runtime.chartAI)
|
||||
.css('overflow', 'hidden')
|
||||
.parent()
|
||||
.append($legend);
|
||||
|
||||
if (initialize != true) {
|
||||
runtime.charts['c' + runtime.chartAI] = chartObj;
|
||||
@ -1173,37 +1261,9 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
});
|
||||
|
||||
$('#gridchart' + runtime.chartAI).bind('jqplotMouseMove', function(ev, gridpos, datapos, neighbor, plot) {
|
||||
|
||||
if (neighbor != null) {
|
||||
if ($('#tooltip_box').length) {
|
||||
$('#tooltip_box')
|
||||
.css({
|
||||
left: ev.pageX + 15,
|
||||
top: ev.pageY + 15,
|
||||
padding:'5px'
|
||||
})
|
||||
.fadeIn();
|
||||
}
|
||||
var xVal = new Date(Math.ceil(neighbor.data[0]));
|
||||
var xValHours = xVal.getHours();
|
||||
(xValHours < 10) ? (xValHours = "0" + xValHours) : "";
|
||||
|
||||
var xValMinutes = xVal.getMinutes();
|
||||
(xValMinutes < 10) ? (xValMinutes = "0" + xValMinutes) : "";
|
||||
|
||||
var xValSeconds = xVal.getSeconds();
|
||||
(xValSeconds < 10) ? (xValSeconds = "0" + xValSeconds) : "";
|
||||
|
||||
xVal = xValHours + ":" + xValMinutes + ":" + xValSeconds;
|
||||
var s = '<b>' + xVal + '<br/>' + neighbor.data[1] + '</b>';
|
||||
|
||||
$('#tooltip_box').html(s);
|
||||
}
|
||||
|
||||
if (! drawTimeSpan) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectionStartX != undefined) {
|
||||
$('#selection_box')
|
||||
.css({
|
||||
@ -1213,26 +1273,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#gridchart' + runtime.chartAI).bind('jqplotMouseEnter', function(ev, gridpos, datapos, neighbor, plot) {
|
||||
if ($('#tooltip_box').length) {
|
||||
tooltipBox.remove();
|
||||
}
|
||||
tooltipBox = $('<div style="z-index:1000;height:40px;position:absolute;background-color:#FFFFFD;opacity:0.8;filter:alpha(opacity=80);">');
|
||||
$(document.body).append(tooltipBox);
|
||||
tooltipBox
|
||||
.attr({id: 'tooltip_box'})
|
||||
.css({
|
||||
top: ev.pageY + 15,
|
||||
left: ev.pageX + 15
|
||||
})
|
||||
.fadeIn();
|
||||
});
|
||||
|
||||
$('#gridchart' + runtime.chartAI).bind('jqplotMouseLeave', function(ev, gridpos, datapos, neighbor, plot) {
|
||||
if ($('#tooltip_box').length) {
|
||||
tooltipBox.remove();
|
||||
}
|
||||
drawTimeSpan = false;
|
||||
});
|
||||
|
||||
@ -1370,20 +1411,21 @@ 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',
|
||||
requiredData: $.toJSON(runtime.dataList)
|
||||
}, function(data) {
|
||||
var chartData;
|
||||
try {
|
||||
chartData = $.parseJSON(data.message);
|
||||
} catch(err) {
|
||||
if (data.success == true) {
|
||||
chartData = data.message;
|
||||
} else {
|
||||
return serverResponseError();
|
||||
}
|
||||
var value, i = 0;
|
||||
var diff;
|
||||
var total;
|
||||
|
||||
/* Update values in each graph */
|
||||
$.each(runtime.charts, function(orderKey, elem) {
|
||||
@ -1393,6 +1435,7 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
return;
|
||||
}
|
||||
// Draw all series
|
||||
total = 0;
|
||||
for (var j = 0; j < elem.nodes.length; j++) {
|
||||
// Update x-axis
|
||||
if (i == 0 && j == 0) {
|
||||
@ -1437,7 +1480,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;
|
||||
}
|
||||
@ -1451,14 +1494,30 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
elem.chart.series[j].data.shift();
|
||||
}
|
||||
}
|
||||
if (elem.title === PMA_messages['strSystemMemory']
|
||||
|| elem.title === PMA_messages['strSystemSwap']
|
||||
) {
|
||||
total += value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update chart options
|
||||
elem.chart['axes']['xaxis']['max'] = runtime.xmax;
|
||||
elem.chart['axes']['xaxis']['min'] = runtime.xmin;
|
||||
elem.chart['axes']['yaxis']['max'] = Math.ceil(elem.maxYLabel*1.2);
|
||||
elem.chart['axes']['yaxis']['tickInterval'] = Math.ceil(elem.maxYLabel*1.2)/5;
|
||||
if (elem.title !== PMA_messages['strSystemCPUUsage']
|
||||
&& elem.title !== PMA_messages['strQueryCacheEfficiency']
|
||||
&& elem.title !== PMA_messages['strSystemMemory']
|
||||
&& elem.title !== PMA_messages['strSystemSwap']
|
||||
) {
|
||||
elem.chart['axes']['yaxis']['max'] = Math.ceil(elem.maxYLabel*1.1);
|
||||
elem.chart['axes']['yaxis']['tickInterval'] = Math.ceil(elem.maxYLabel*1.1/5);
|
||||
} else if (elem.title === PMA_messages['strSystemMemory']
|
||||
|| elem.title === PMA_messages['strSystemSwap']
|
||||
) {
|
||||
elem.chart['axes']['yaxis']['max'] = Math.ceil(total * 1.1 / 100) * 100;
|
||||
elem.chart['axes']['yaxis']['tickInterval'] = Math.ceil(total * 1.1 / 5);
|
||||
}
|
||||
i++;
|
||||
|
||||
if (runtime.redrawCharts) {
|
||||
@ -1472,7 +1531,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 +1547,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 +1633,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,
|
||||
@ -1584,9 +1644,9 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
},
|
||||
function(data) {
|
||||
var logData;
|
||||
try {
|
||||
logData = $.parseJSON(data.message);
|
||||
} catch(err) {
|
||||
if (data.success == true) {
|
||||
logData = data.message;
|
||||
} else {
|
||||
return serverResponseError();
|
||||
}
|
||||
|
||||
@ -1655,10 +1715,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 +1761,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 +1771,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 +1804,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 +1984,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,20 +2031,19 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
PMA_messages['strAnalyzing'] + ' <img class="ajaxIcon" src="' +
|
||||
pmaThemeImage + 'ajax_clock_small.gif" alt="">');
|
||||
|
||||
$.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(),
|
||||
database: db
|
||||
}, function(data) {
|
||||
data = $.parseJSON(data.message);
|
||||
var totalTime = 0;
|
||||
|
||||
if (data.error) {
|
||||
if (data.success == true) {
|
||||
data = data.message;
|
||||
} else {
|
||||
$('div#queryAnalyzerDialog div.placeHolder').html('<div class="error">' + data.error + '</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
var totalTime = 0;
|
||||
// Float sux, I'll use table :(
|
||||
$('div#queryAnalyzerDialog div.placeHolder')
|
||||
.html('<table width="100%" border="0"><tr><td class="explain"></td><td class="chart"></td></tr></table>');
|
||||
@ -2034,22 +2099,22 @@ AJAX.registerOnload('server_status_monitor.js', function() {
|
||||
|
||||
numberTable += '<tr><td>' + data.profiling[i].state + ' </td><td> ' + PMA_prettyProfilingNum(duration, 2) + '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Only put those values in the pie which are > 2%
|
||||
for (var i = 0, l = data.profiling.length; i < l; i++) {
|
||||
duration = parseFloat(data.profiling[i].duration);
|
||||
|
||||
|
||||
if (duration / totalTime > 0.02) {
|
||||
chartData.push([PMA_prettyProfilingNum(duration, 2) + ' ' + data.profiling[i].state, duration]);
|
||||
} else {
|
||||
otherTime += duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (otherTime > 0) {
|
||||
chartData.push([PMA_prettyProfilingNum(otherTime, 2) + ' ' + PMA_messages['strOther'], otherTime]);
|
||||
}
|
||||
|
||||
|
||||
numberTable += '<tr><td><b>' + PMA_messages['strTotalTime'] + '</b></td><td>' + PMA_prettyProfilingNum(totalTime, 2) + '</td></tr>';
|
||||
numberTable += '</tbody></table>';
|
||||
|
||||
@ -2105,3 +2170,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;
|
||||
}
|
||||
|
||||
39
js/server_status_queries.js
Normal file
39
js/server_status_queries.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('server_status_queries.js', function() {
|
||||
var queryPieChart = $('#serverstatusquerieschart').data('queryPieChart');
|
||||
if (queryPieChart) {
|
||||
queryPieChart.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
AJAX.registerOnload('server_status_queries.js', function() {
|
||||
// Build query statistics chart
|
||||
var cdata = [];
|
||||
try {
|
||||
$.each(jQuery.parseJSON($('#serverstatusquerieschart_data').text()), function(key, value) {
|
||||
cdata.push([key, parseInt(value)]);
|
||||
});
|
||||
$('#serverstatusquerieschart').data(
|
||||
'queryPieChart',
|
||||
PMA_createProfilingChartJqplot(
|
||||
'serverstatusquerieschart',
|
||||
cdata
|
||||
)
|
||||
);
|
||||
} catch (exception) {
|
||||
// Could not load chart, no big deal...
|
||||
}
|
||||
|
||||
/*** Table sort tooltip ***/
|
||||
PMA_createqTip(
|
||||
$('table.sortable').children('thead').children('tr').has('th'),
|
||||
PMA_messages['strSortHint']
|
||||
);
|
||||
initTableSorter('statustabs_queries');
|
||||
});
|
||||
89
js/server_status_sorter.js
Normal file
89
js/server_status_sorter.js
Normal file
@ -0,0 +1,89 @@
|
||||
// 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('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$.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"
|
||||
});
|
||||
|
||||
$.tablesorter.addParser({
|
||||
id: "withinSpanNumber",
|
||||
is: function(s) {
|
||||
return /<span class="original"/.test(s);
|
||||
},
|
||||
format: function(s, table, html) {
|
||||
var res = html.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/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
|
||||
$.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
109
js/server_status_variables.js
Normal file
109
js/server_status_variables.js
Normal file
@ -0,0 +1,109 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
AJAX.registerTeardown('server_status_variables.js', function() {
|
||||
$('#filterAlert').unbind('change');
|
||||
$('#filterText').unbind('keyup');
|
||||
$('#filterCategory').unbind('change');
|
||||
$('#dontFormat').unbind('change');
|
||||
});
|
||||
|
||||
AJAX.registerOnload('server_status_variables.js', function() {
|
||||
/*** Table sort tooltip ***/
|
||||
PMA_createqTip(
|
||||
$('table.sortable').children('thead').children('tr').has('th'),
|
||||
PMA_messages['strSortHint']
|
||||
);
|
||||
initTableSorter('statustabs_allvars');
|
||||
|
||||
// Filters for status variables
|
||||
var textFilter = null;
|
||||
var alertFilter = $('#filterAlert').prop('checked');
|
||||
var categoryFilter = $('#filterCategory').find(':selected').val();
|
||||
var odd_row = false;
|
||||
var text = ''; // Holds filter text
|
||||
|
||||
/* 3 Filtering functions */
|
||||
$('#filterAlert').change(function() {
|
||||
alertFilter = this.checked;
|
||||
filterVariables();
|
||||
});
|
||||
|
||||
$('#filterCategory').change(function() {
|
||||
categoryFilter = $(this).val();
|
||||
filterVariables();
|
||||
});
|
||||
|
||||
$('#dontFormat').change(function() {
|
||||
// Hiding the table while changing values speeds up the process a lot
|
||||
$('#serverstatusvariables').hide();
|
||||
$('#serverstatusvariables td.value span.original').toggle(this.checked);
|
||||
$('#serverstatusvariables td.value span.formatted').toggle(! this.checked);
|
||||
$('#serverstatusvariables').show();
|
||||
}).trigger('change');
|
||||
|
||||
$('#filterText').keyup(function(e) {
|
||||
var word = $(this).val().replace(/_/g, ' ');
|
||||
if (word.length == 0) {
|
||||
textFilter = null;
|
||||
} else {
|
||||
textFilter = new RegExp("(^| )" + word, 'i');
|
||||
}
|
||||
text = word;
|
||||
filterVariables();
|
||||
}).trigger('keyup');
|
||||
|
||||
/* Filters the status variables by name/category/alert in the variables tab */
|
||||
function filterVariables() {
|
||||
var useful_links = 0;
|
||||
var section = text;
|
||||
|
||||
if (categoryFilter.length > 0) {
|
||||
section = categoryFilter;
|
||||
}
|
||||
|
||||
if (section.length > 1) {
|
||||
$('#linkSuggestions span').each(function() {
|
||||
if ($(this).attr('class').indexOf('status_' + section) != -1) {
|
||||
useful_links++;
|
||||
$(this).css('display', '');
|
||||
} else {
|
||||
$(this).css('display', 'none');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (useful_links > 0) {
|
||||
$('#linkSuggestions').css('display', '');
|
||||
} else {
|
||||
$('#linkSuggestions').css('display', 'none');
|
||||
}
|
||||
|
||||
odd_row = false;
|
||||
$('#serverstatusvariables th.name').each(function() {
|
||||
if ((textFilter == null || textFilter.exec($(this).text()))
|
||||
&& (! alertFilter || $(this).next().find('span.attention').length>0)
|
||||
&& (categoryFilter.length == 0 || $(this).parent().hasClass('s_' + categoryFilter))
|
||||
) {
|
||||
odd_row = ! odd_row;
|
||||
$(this).parent().css('display', '');
|
||||
if (odd_row) {
|
||||
$(this).parent().addClass('odd');
|
||||
$(this).parent().removeClass('even');
|
||||
} else {
|
||||
$(this).parent().addClass('even');
|
||||
$(this).parent().removeClass('odd');
|
||||
}
|
||||
} else {
|
||||
$(this).parent().css('display', 'none');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -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';
|
||||
|
||||
382
libraries/ServerStatusData.class.php
Normal file
382
libraries/ServerStatusData.class.php
Normal file
@ -0,0 +1,382 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* PMA_ServerStatusData class
|
||||
* Used by server_status_*.php pages
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
/**
|
||||
* This class provides data about the server status
|
||||
*
|
||||
* All properties of the class are read-only
|
||||
*
|
||||
* TODO: Use lazy initialisation for some of the properties
|
||||
* since not all of the server_status_*.php pages need
|
||||
* all the data that this class provides.
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class PMA_ServerStatusData
|
||||
{
|
||||
public $status;
|
||||
public $sections;
|
||||
public $variables;
|
||||
public $used_queries;
|
||||
public $allocationMap;
|
||||
public $links;
|
||||
public $db_isLocal;
|
||||
public $section;
|
||||
public $categoryUsed;
|
||||
public $selfUrl;
|
||||
|
||||
/**
|
||||
* An empty setter makes the above properties read-only
|
||||
*
|
||||
* @param string $a key
|
||||
* @param mixed $b value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __set($a, $b)
|
||||
{
|
||||
// Discard everything
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->selfUrl = basename($GLOBALS['PMA_PHP_SELF']);
|
||||
/**
|
||||
* get status from server
|
||||
*/
|
||||
$server_status = PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1);
|
||||
if (PMA_DRIZZLE) {
|
||||
// Drizzle doesn't put query statistics into variables, add it
|
||||
$sql = "SELECT concat('Com_', variable_name), variable_value
|
||||
FROM data_dictionary.GLOBAL_STATEMENTS";
|
||||
$statements = PMA_DBI_fetch_result($sql, 0, 1);
|
||||
$server_status = array_merge($server_status, $statements);
|
||||
}
|
||||
|
||||
/**
|
||||
* for some calculations we require also some server settings
|
||||
*/
|
||||
$server_variables = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1);
|
||||
|
||||
/**
|
||||
* cleanup of some deprecated values
|
||||
*/
|
||||
$server_status = self::cleanDeprecated($server_status);
|
||||
|
||||
/**
|
||||
* calculate some values
|
||||
*/
|
||||
// Key_buffer_fraction
|
||||
if (isset($server_status['Key_blocks_unused'])
|
||||
&& isset($server_variables['key_cache_block_size'])
|
||||
&& isset($server_variables['key_buffer_size'])
|
||||
) {
|
||||
$server_status['Key_buffer_fraction_%']
|
||||
= 100
|
||||
- $server_status['Key_blocks_unused']
|
||||
* $server_variables['key_cache_block_size']
|
||||
/ $server_variables['key_buffer_size']
|
||||
* 100;
|
||||
} elseif (isset($server_status['Key_blocks_used'])
|
||||
&& isset($server_variables['key_buffer_size'])) {
|
||||
$server_status['Key_buffer_fraction_%']
|
||||
= $server_status['Key_blocks_used']
|
||||
* 1024
|
||||
/ $server_variables['key_buffer_size'];
|
||||
}
|
||||
|
||||
// Ratio for key read/write
|
||||
if (isset($server_status['Key_writes'])
|
||||
&& isset($server_status['Key_write_requests'])
|
||||
&& $server_status['Key_write_requests'] > 0
|
||||
) {
|
||||
$server_status['Key_write_ratio_%']
|
||||
= 100 * $server_status['Key_writes'] / $server_status['Key_write_requests'];
|
||||
}
|
||||
|
||||
if (isset($server_status['Key_reads'])
|
||||
&& isset($server_status['Key_read_requests'])
|
||||
&& $server_status['Key_read_requests'] > 0
|
||||
) {
|
||||
$server_status['Key_read_ratio_%']
|
||||
= 100 * $server_status['Key_reads'] / $server_status['Key_read_requests'];
|
||||
}
|
||||
|
||||
// Threads_cache_hitrate
|
||||
if (isset($server_status['Threads_created'])
|
||||
&& isset($server_status['Connections'])
|
||||
&& $server_status['Connections'] > 0
|
||||
) {
|
||||
|
||||
$server_status['Threads_cache_hitrate_%']
|
||||
= 100 - $server_status['Threads_created']
|
||||
/ $server_status['Connections'] * 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* split variables in sections
|
||||
*/
|
||||
$allocations = array(
|
||||
// variable name => section
|
||||
// variable names match when they begin with the given string
|
||||
|
||||
'Com_' => 'com',
|
||||
'Innodb_' => 'innodb',
|
||||
'Ndb_' => 'ndb',
|
||||
'Handler_' => 'handler',
|
||||
'Qcache_' => 'qcache',
|
||||
'Threads_' => 'threads',
|
||||
'Slow_launch_threads' => 'threads',
|
||||
|
||||
'Binlog_cache_' => 'binlog_cache',
|
||||
'Created_tmp_' => 'created_tmp',
|
||||
'Key_' => 'key',
|
||||
|
||||
'Delayed_' => 'delayed',
|
||||
'Not_flushed_delayed_rows' => 'delayed',
|
||||
|
||||
'Flush_commands' => 'query',
|
||||
'Last_query_cost' => 'query',
|
||||
'Slow_queries' => 'query',
|
||||
'Queries' => 'query',
|
||||
'Prepared_stmt_count' => 'query',
|
||||
|
||||
'Select_' => 'select',
|
||||
'Sort_' => 'sort',
|
||||
|
||||
'Open_tables' => 'table',
|
||||
'Opened_tables' => 'table',
|
||||
'Open_table_definitions' => 'table',
|
||||
'Opened_table_definitions' => 'table',
|
||||
'Table_locks_' => 'table',
|
||||
|
||||
'Rpl_status' => 'repl',
|
||||
'Slave_' => 'repl',
|
||||
|
||||
'Tc_' => 'tc',
|
||||
|
||||
'Ssl_' => 'ssl',
|
||||
|
||||
'Open_files' => 'files',
|
||||
'Open_streams' => 'files',
|
||||
'Opened_files' => 'files',
|
||||
);
|
||||
|
||||
$sections = array(
|
||||
// section => section name (description)
|
||||
'com' => 'Com',
|
||||
'query' => __('SQL query'),
|
||||
'innodb' => 'InnoDB',
|
||||
'ndb' => 'NDB',
|
||||
'handler' => __('Handler'),
|
||||
'qcache' => __('Query cache'),
|
||||
'threads' => __('Threads'),
|
||||
'binlog_cache' => __('Binary log'),
|
||||
'created_tmp' => __('Temporary data'),
|
||||
'delayed' => __('Delayed inserts'),
|
||||
'key' => __('Key cache'),
|
||||
'select' => __('Joins'),
|
||||
'repl' => __('Replication'),
|
||||
'sort' => __('Sorting'),
|
||||
'table' => __('Tables'),
|
||||
'tc' => __('Transaction coordinator'),
|
||||
'files' => __('Files'),
|
||||
'ssl' => 'SSL',
|
||||
'other' => __('Other')
|
||||
);
|
||||
|
||||
/**
|
||||
* define some needfull links/commands
|
||||
*/
|
||||
// variable or section name => (name => url)
|
||||
$links = array();
|
||||
|
||||
$links['table'][__('Flush (close) all tables')]
|
||||
= $this->selfUrl . '?flush=TABLES&' . PMA_generate_common_url();
|
||||
$links['table'][__('Show open tables')]
|
||||
= 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') .
|
||||
'&goto=' . $this->selfUrl . '&' . PMA_generate_common_url();
|
||||
|
||||
if ($GLOBALS['server_master_status']) {
|
||||
$links['repl'][__('Show slave hosts')]
|
||||
= 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS')
|
||||
. '&goto=' . $this->selfUrl . '&'
|
||||
. PMA_generate_common_url();
|
||||
$links['repl'][__('Show master status')] = '#replication_master';
|
||||
}
|
||||
if ($GLOBALS['server_slave_status']) {
|
||||
$links['repl'][__('Show slave status')] = '#replication_slave';
|
||||
}
|
||||
|
||||
$links['repl']['doc'] = 'replication';
|
||||
|
||||
$links['qcache'][__('Flush query cache')]
|
||||
= $this->selfUrl . '?flush=' . urlencode('QUERY CACHE') . '&' .
|
||||
PMA_generate_common_url();
|
||||
$links['qcache']['doc'] = 'query_cache';
|
||||
|
||||
//$links['threads'][__('Show processes')]
|
||||
// = 'server_processlist.php?' . PMA_generate_common_url();
|
||||
$links['threads']['doc'] = 'mysql_threads';
|
||||
|
||||
$links['key']['doc'] = 'myisam_key_cache';
|
||||
|
||||
$links['binlog_cache']['doc'] = 'binary_log';
|
||||
|
||||
$links['Slow_queries']['doc'] = 'slow_query_log';
|
||||
|
||||
$links['innodb'][__('Variables')]
|
||||
= 'server_engines.php?engine=InnoDB&' . PMA_generate_common_url();
|
||||
$links['innodb'][__('InnoDB Status')]
|
||||
= 'server_engines.php?engine=InnoDB&page=Status&' .
|
||||
PMA_generate_common_url();
|
||||
$links['innodb']['doc'] = 'innodb';
|
||||
|
||||
|
||||
// Variable to contain all com_ variables (query statistics)
|
||||
$used_queries = array();
|
||||
|
||||
// Variable to map variable names to their respective section name
|
||||
// (used for js category filtering)
|
||||
$allocationMap = array();
|
||||
|
||||
// Variable to mark used sections
|
||||
$categoryUsed = array();
|
||||
|
||||
// sort vars into arrays
|
||||
foreach ($server_status as $name => $value) {
|
||||
$section_found = false;
|
||||
foreach ($allocations as $filter => $section) {
|
||||
if (strpos($name, $filter) !== false) {
|
||||
$allocationMap[$name] = $section;
|
||||
$categoryUsed[$section] = true;
|
||||
$section_found = true;
|
||||
if ($section == 'com' && $value > 0) {
|
||||
$used_queries[$name] = $value;
|
||||
}
|
||||
break; // Only exits inner loop
|
||||
}
|
||||
}
|
||||
if (!$section_found) {
|
||||
$allocationMap[$name] = 'other';
|
||||
$categoryUsed['other'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (PMA_DRIZZLE) {
|
||||
$used_queries = PMA_DBI_fetch_result(
|
||||
'SELECT * FROM data_dictionary.global_statements',
|
||||
0,
|
||||
1
|
||||
);
|
||||
unset($used_queries['admin_commands']);
|
||||
} else {
|
||||
// admin commands are not queries (e.g. they include COM_PING,
|
||||
// which is excluded from $server_status['Questions'])
|
||||
unset($used_queries['Com_admin_commands']);
|
||||
}
|
||||
|
||||
// Set all class properties
|
||||
$this->db_isLocal = false;
|
||||
if (strtolower($GLOBALS['cfg']['Server']['host']) === 'localhost'
|
||||
|| $GLOBALS['cfg']['Server']['host'] === '127.0.0.1'
|
||||
|| $GLOBALS['cfg']['Server']['host'] === '::1'
|
||||
) {
|
||||
$this->db_isLocal = true;
|
||||
}
|
||||
$this->status = $server_status;
|
||||
$this->sections = $sections;
|
||||
$this->variables = $server_variables;
|
||||
$this->used_queries = $used_queries;
|
||||
$this->allocationMap = $allocationMap;
|
||||
$this->links = $links;
|
||||
$this->categoryUsed = $categoryUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* cleanup of some deprecated values
|
||||
*
|
||||
* @param array $server_status status array to process
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static 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 $server_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* cleanup of some deprecated values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMenuHtml()
|
||||
{
|
||||
$url_params = PMA_generate_common_url();
|
||||
$items = array(
|
||||
array(
|
||||
'name' => __('Server'),
|
||||
'url' => 'server_status.php'
|
||||
),
|
||||
array(
|
||||
'name' => __('Query statistics'),
|
||||
'url' => 'server_status_queries.php'
|
||||
),
|
||||
array(
|
||||
'name' => __('All status variables'),
|
||||
'url' => 'server_status_variables.php'
|
||||
),
|
||||
array(
|
||||
'name' => __('Monitor'),
|
||||
'url' => 'server_status_monitor.php'
|
||||
),
|
||||
array(
|
||||
'name' => __('Advisor'),
|
||||
'url' => 'server_status_advisor.php'
|
||||
)
|
||||
);
|
||||
|
||||
$retval = '<ul id="topmenu2">';
|
||||
foreach ($items as $item) {
|
||||
$class = '';
|
||||
if ($item['url'] === $this->selfUrl) {
|
||||
$class = ' class="tabactive"';
|
||||
}
|
||||
$retval .= '<li>';
|
||||
$retval .= '<a' . $class;
|
||||
$retval .= ' href="' . $item['url'] . '?' . $url_params . '">';
|
||||
$retval .= $item['name'];
|
||||
$retval .= '</a>';
|
||||
$retval .= '</li>';
|
||||
}
|
||||
$retval .= '</ul>';
|
||||
$retval .= '<div class="clearfloat"></div>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -391,6 +391,10 @@ $goto_whitelist = array(
|
||||
'server_processlist.php',
|
||||
'server_sql.php',
|
||||
'server_status.php',
|
||||
'server_status_advisor.php',
|
||||
'server_status_monitor.php',
|
||||
'server_status_queries.php',
|
||||
'server_status_variables.php',
|
||||
'server_variables.php',
|
||||
'sql.php',
|
||||
'tbl_addfield.php',
|
||||
|
||||
2154
server_status.php
2154
server_status.php
File diff suppressed because it is too large
Load Diff
75
server_status_advisor.php
Normal file
75
server_status_advisor.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* displays the advisor feature
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
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 = '<div>';
|
||||
$output .= $ServerStatusData->getMenuHtml();
|
||||
$output .= '<a href="#openAdvisorInstructions">';
|
||||
$output .= PMA_Util::getIcon('b_help.png', __('Instructions'));
|
||||
$output .= '</a>';
|
||||
$output .= '<div id="statustabs_advisor"></div>';
|
||||
$output .= '<div id="advisorInstructionsDialog" style="display:none;">';
|
||||
$output .= '<p>';
|
||||
$output .= __(
|
||||
'The Advisor system can provide recommendations '
|
||||
. 'on server variables by analyzing the server status variables.'
|
||||
);
|
||||
$output .= '</p>';
|
||||
$output .= '<p>';
|
||||
$output .= __(
|
||||
'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.'
|
||||
);
|
||||
$output .= '</p>';
|
||||
$output .= '<p>';
|
||||
$output .= __(
|
||||
'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.'
|
||||
);
|
||||
$output .= '</p>';
|
||||
$output .= '<p>';
|
||||
$output .= __(
|
||||
'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.'
|
||||
);
|
||||
$output .= '</p>';
|
||||
$output .= '</div>';
|
||||
$output .= '<div id="emptyDialog" style="display:none;"></div>';
|
||||
$output .= '<div id="advisorData" style="display:none;">';
|
||||
$advisor = new Advisor();
|
||||
$output .= htmlspecialchars(
|
||||
json_encode(
|
||||
$advisor->run()
|
||||
)
|
||||
);
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
$response->addHTML($output);
|
||||
|
||||
?>
|
||||
758
server_status_monitor.php
Normal file
758
server_status_monitor.php
Normal file
@ -0,0 +1,758 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Server status monitor feature
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/server_common.inc.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';
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax request
|
||||
*/
|
||||
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
// Send with correct charset
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
// real-time charting data
|
||||
if (isset($_REQUEST['chart_data'])) {
|
||||
switch($_REQUEST['type']) {
|
||||
case 'chartgrid': // Data for the monitor
|
||||
$ret = json_decode($_REQUEST['requiredData'], true);
|
||||
$statusVars = array();
|
||||
$serverVars = array();
|
||||
$sysinfo = $cpuload = $memory = 0;
|
||||
$pName = '';
|
||||
|
||||
/* Accumulate all required variables and data */
|
||||
// For each chart
|
||||
foreach ($ret as $chart_id => $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;
|
||||
|
||||
PMA_Response::getInstance()->addJSON('message', $ret);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
PMA_Response::getInstance()->addJSON('message', $return);
|
||||
exit;
|
||||
}
|
||||
|
||||
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']
|
||||
.= '<br/>...';
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
PMA_Response::getInstance()->addJSON('message', $return);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
PMA_Response::getInstance()->addJSON('message', $loggingVars);
|
||||
exit;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
PMA_Response::getInstance()->addJSON('message', $return);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JS Includes
|
||||
*/
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$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('jqplot/plugins/jqplot.byteFormatter.js');
|
||||
$scripts->addFile('date.js');
|
||||
|
||||
$scripts->addFile('server_status_monitor.js');
|
||||
$scripts->addFile('server_status_sorter.js');
|
||||
|
||||
|
||||
/**
|
||||
* start output
|
||||
*/
|
||||
$ServerStatusData = new PMA_ServerStatusData();
|
||||
|
||||
/**
|
||||
* Define some data needed on the client side
|
||||
*/
|
||||
$input = '<input type="hidden" name="%s" value="%s" />';
|
||||
$form = '<form id="js_data" class="hide">';
|
||||
$form .= sprintf($input, 'server_time', microtime(true) * 1000);
|
||||
$form .= sprintf($input, 'server_os', PHP_OS);
|
||||
$form .= sprintf($input, 'is_superuser', PMA_isSuperuser());
|
||||
$form .= sprintf($input, 'server_db_isLocal', $ServerStatusData->db_isLocal);
|
||||
$form .= '</form>';
|
||||
/**
|
||||
* Define some links used on client side
|
||||
*/
|
||||
$links = '<div id="profiling_docu" class="hide">';
|
||||
$links .= PMA_Util::showMySQLDocu('general-thread-states', 'general-thread-states');
|
||||
$links .= '</div>';
|
||||
$links .= '<div id="explain_docu" class="hide">';
|
||||
$links .= PMA_Util::showMySQLDocu('explain-output', 'explain-output');
|
||||
$links .= '</div>';
|
||||
|
||||
/**
|
||||
* Output
|
||||
*/
|
||||
$response->addHTML('<div>');
|
||||
$response->addHTML($ServerStatusData->getMenuHtml());
|
||||
$response->addHTML(getPrintMonitorHtml($ServerStatusData));
|
||||
$response->addHTML($form);
|
||||
$response->addHTML($links);
|
||||
$response->addHTML('</div>');
|
||||
exit;
|
||||
|
||||
/**
|
||||
* Prints html with monitor
|
||||
*
|
||||
* @param object $ServerStatusData An instance of the PMA_ServerStatusData class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getPrintMonitorHtml($ServerStatusData)
|
||||
{
|
||||
$retval = '<div class="tabLinks">';
|
||||
$retval .= '<a href="#pauseCharts">';
|
||||
$retval .= PMA_Util::getImage('play.png') . __('Start Monitor');
|
||||
$retval .= '</a>';
|
||||
$retval .= '<a href="#settingsPopup" class="popupLink">';
|
||||
$retval .= PMA_Util::getImage('s_cog.png') . __('Settings');
|
||||
$retval .= '</a>';
|
||||
if (! PMA_DRIZZLE) {
|
||||
$retval .= '<a href="#monitorInstructionsDialog">';
|
||||
$retval .= PMA_Util::getImage('b_help.png') . __('Instructions/Setup');
|
||||
}
|
||||
$retval .= '<a href="#endChartEditMode" style="display:none;">';
|
||||
$retval .= PMA_Util::getImage('s_okay.png');
|
||||
$retval .= __('Done rearranging/editing charts');
|
||||
$retval .= '</a>';
|
||||
$retval .= '</div>';
|
||||
|
||||
$retval .= '<div class="popupContent settingsPopup">';
|
||||
$retval .= '<a href="#addNewChart">';
|
||||
$retval .= PMA_Util::getImage('b_chart.png') . __('Add chart');
|
||||
$retval .= '</a>';
|
||||
$retval .= '<a href="#rearrangeCharts">';
|
||||
$retval .= PMA_Util::getImage('b_tblops.png') . __('Rearrange/edit charts');
|
||||
$retval .= '</a>';
|
||||
$retval .= '<div class="clearfloat paddingtop"></div>';
|
||||
$retval .= '<div class="floatleft">';
|
||||
$retval .= __('Refresh rate') . '<br />';
|
||||
$retval .= PMA_getRefreshList(
|
||||
'gridChartRefresh',
|
||||
5,
|
||||
Array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200)
|
||||
);
|
||||
$retval .= '<br />';
|
||||
$retval .= '</div>';
|
||||
$retval .= '<div class="floatleft">';
|
||||
$retval .= __('Chart columns');
|
||||
$retval .= '<br />';
|
||||
$retval .= '<select name="chartColumns">';
|
||||
$retval .= '<option>1</option>';
|
||||
$retval .= '<option>2</option>';
|
||||
$retval .= '<option>3</option>';
|
||||
$retval .= '<option>4</option>';
|
||||
$retval .= '<option>5</option>';
|
||||
$retval .= '<option>6</option>';
|
||||
$retval .= '<option>7</option>';
|
||||
$retval .= '<option>8</option>';
|
||||
$retval .= '<option>9</option>';
|
||||
$retval .= '<option>10</option>';
|
||||
$retval .= '</select>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '<div class="clearfloat paddingtop">';
|
||||
$retval .= '<b>' . __('Chart arrangement') . '</b> ';
|
||||
$retval .= PMA_Util::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.'
|
||||
)
|
||||
);
|
||||
$retval .= '<br/>';
|
||||
$retval .= '<a class="ajax" href="#importMonitorConfig">';
|
||||
$retval .= __('Import');
|
||||
$retval .= '</a>';
|
||||
$retval .= ' ';
|
||||
$retval .= '<a class="disableAjax" href="#exportMonitorConfig">';
|
||||
$retval .= __('Export');
|
||||
$retval .= '</a>';
|
||||
$retval .= ' ';
|
||||
$retval .= '<a href="#clearMonitorConfig">';
|
||||
$retval .= __('Reset to default');
|
||||
$retval .= '</a>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '</div>';
|
||||
|
||||
$retval .= '<div id="monitorInstructionsDialog" title="';
|
||||
$retval .= __('Monitor Instructions') . '" style="display:none;">';
|
||||
$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 .= '<p>';
|
||||
$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 .= '</p>';
|
||||
} else {
|
||||
$retval .= '<p></p>';
|
||||
$retval .= '<img class="ajaxIcon" src="';
|
||||
$retval .= $GLOBALS['pmaThemeImage'] . 'ajax_clock_small.gif"';
|
||||
$retval .= ' alt="' . __('Loading') . '" />';
|
||||
$retval .= '<div class="ajaxContent"></div>';
|
||||
$retval .= '<div class="monitorUse" style="display:none;">';
|
||||
$retval .= '<p></p>';
|
||||
$retval .= '<strong>';
|
||||
$retval .= __('Using the monitor:');
|
||||
$retval .= '</strong><p>';
|
||||
$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 .= '</p><p>';
|
||||
$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 .= '</p>';
|
||||
$retval .= '<p>';
|
||||
$retval .= PMA_Util::getImage('s_attention.png');
|
||||
$retval .= '<strong>';
|
||||
$retval .= __('Please note:');
|
||||
$retval .= '</strong><br />';
|
||||
$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 .= '</p>';
|
||||
$retval .= '</div>';
|
||||
}
|
||||
$retval .= '</div>';
|
||||
|
||||
$retval .= '<div id="addChartDialog" title="' . __('Add chart') . '" style="display:none;">';
|
||||
$retval .= '<div id="tabGridVariables">';
|
||||
$retval .= '<p><input type="text" name="chartTitle" value="' . __('Chart Title') . '" /></p>';
|
||||
$retval .= '<input type="radio" name="chartType" value="preset" id="chartPreset" />';
|
||||
$retval .= '<label for="chartPreset">' . __('Preset chart') . '</label>';
|
||||
$retval .= '<select name="presetCharts"></select><br/>';
|
||||
$retval .= '<input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked" />';
|
||||
$retval .= '<label for="chartStatusVar">';
|
||||
$retval .= __('Status variable(s)');
|
||||
$retval .= '</label><br/>';
|
||||
$retval .= '<div id="chartVariableSettings">';
|
||||
$retval .= '<label for="chartSeries">' . __('Select series:') . '</label><br />';
|
||||
$retval .= '<select id="chartSeries" name="varChartList" size="1">';
|
||||
$retval .= '<option>' . __('Commonly monitored') . '</option>';
|
||||
$retval .= '<option>Processes</option>';
|
||||
$retval .= '<option>Questions</option>';
|
||||
$retval .= '<option>Connections</option>';
|
||||
$retval .= '<option>Bytes_sent</option>';
|
||||
$retval .= '<option>Bytes_received</option>';
|
||||
$retval .= '<option>Threads_connected</option>';
|
||||
$retval .= '<option>Created_tmp_disk_tables</option>';
|
||||
$retval .= '<option>Handler_read_first</option>';
|
||||
$retval .= '<option>Innodb_buffer_pool_wait_free</option>';
|
||||
$retval .= '<option>Key_reads</option>';
|
||||
$retval .= '<option>Open_tables</option>';
|
||||
$retval .= '<option>Select_full_join</option>';
|
||||
$retval .= '<option>Slow_queries</option>';
|
||||
$retval .= '</select><br />';
|
||||
$retval .= '<label for="variableInput">';
|
||||
$retval .= __('or type variable name:');
|
||||
$retval .= ' </label>';
|
||||
$retval .= '<input type="text" name="variableInput" id="variableInput" />';
|
||||
$retval .= '<p></p>';
|
||||
$retval .= '<input type="checkbox" name="differentialValue"';
|
||||
$retval .= ' id="differentialValue" value="differential" checked="checked" />';
|
||||
$retval .= '<label for="differentialValue">';
|
||||
$retval .= __('Display as differential value');
|
||||
$retval .= '</label><br />';
|
||||
$retval .= '<input type="checkbox" id="useDivisor" name="useDivisor" value="1" />';
|
||||
$retval .= '<label for="useDivisor">' . __('Apply a divisor') . '</label>';
|
||||
$retval .= '<span class="divisorInput" style="display:none;">';
|
||||
$retval .= '<input type="text" name="valueDivisor" size="4" value="1" />';
|
||||
$retval .= '(<a href="#kibDivisor">' . __('KiB') . '</a>, ';
|
||||
$retval .= '<a href="#mibDivisor">' . __('MiB') . '</a>)';
|
||||
$retval .= '</span><br />';
|
||||
$retval .= '<input type="checkbox" id="useUnit" name="useUnit" value="1" />';
|
||||
$retval .= '<label for="useUnit">';
|
||||
$retval .= __('Append unit to data values');
|
||||
$retval .= '</label>';
|
||||
$retval .= '<span class="unitInput" style="display:none;">';
|
||||
$retval .= '<input type="text" name="valueUnit" size="4" value="" />';
|
||||
$retval .= '</span>';
|
||||
$retval .= '<p>';
|
||||
$retval .= '<a href="#submitAddSeries"><b>' . __('Add this series') . '</b></a>';
|
||||
$retval .= '<span id="clearSeriesLink" style="display:none;">';
|
||||
$retval .= ' | <a href="#submitClearSeries">' . __('Clear series') . '</a>';
|
||||
$retval .= '</span>';
|
||||
$retval .= '</p>';
|
||||
$retval .= __('Series in Chart:');
|
||||
$retval .= '<br/>';
|
||||
$retval .= '<span id="seriesPreview">';
|
||||
$retval .= '<i>' . __('None') . '</i>';
|
||||
$retval .= '</span>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '</div>';
|
||||
|
||||
$retval .= '<div id="emptyDialog" title="Dialog" style="display:none;"></div>';
|
||||
|
||||
if (! PMA_DRIZZLE) {
|
||||
$retval .= '<div id="logAnalyseDialog" title="';
|
||||
$retval .= __('Log statistics') . '" style="display:none;">';
|
||||
$retval .= '<p>' . __('Selected time range:');
|
||||
$retval .= '<input type="text" name="dateStart" class="datetimefield" value="" /> - ';
|
||||
$retval .= '<input type="text" name="dateEnd" class="datetimefield" value="" />';
|
||||
$retval .= '</p>';
|
||||
$retval .= '<input type="checkbox" id="limitTypes" value="1" checked="checked" />';
|
||||
$retval .= '<label for="limitTypes">';
|
||||
$retval .= __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements');
|
||||
$retval .= '</label>';
|
||||
$retval .= '<br/>';
|
||||
$retval .= '<input type="checkbox" id="removeVariables" value="1" checked="checked" />';
|
||||
$retval .= '<label for="removeVariables">';
|
||||
$retval .= __('Remove variable data in INSERT statements for better grouping');
|
||||
$retval .= '</label>';
|
||||
$retval .= '<p>';
|
||||
$retval .= __('Choose from which log you want the statistics to be generated from.');
|
||||
$retval .= '</p>';
|
||||
$retval .= '<p>';
|
||||
$retval .= __('Results are grouped by query text.');
|
||||
$retval .= '</p>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '<div id="queryAnalyzerDialog" title="';
|
||||
$retval .= __('Query analyzer') . '" style="display:none;">';
|
||||
$retval .= '<textarea id="sqlquery"> </textarea>';
|
||||
$retval .= '<p></p>';
|
||||
$retval .= '<div class="placeHolder"></div>';
|
||||
$retval .= '</div>';
|
||||
}
|
||||
|
||||
$retval .= '<table class="clearfloat" id="chartGrid"></table>';
|
||||
$retval .= '<div id="logTable">';
|
||||
$retval .= '<br/>';
|
||||
$retval .= '</div>';
|
||||
|
||||
$retval .= '<script type="text/javascript">';
|
||||
$retval .= 'variableNames = [ ';
|
||||
$i=0;
|
||||
foreach ($ServerStatusData->status as $name=>$value) {
|
||||
if (is_numeric($value)) {
|
||||
if ($i++ > 0) {
|
||||
$retval .= ", ";
|
||||
}
|
||||
$retval .= "'" . $name . "'";
|
||||
}
|
||||
}
|
||||
$retval .= '];';
|
||||
$retval .= '</script>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a <select> list for refresh rates
|
||||
*
|
||||
* @param string $name Name of select
|
||||
* @param int $defaultRate Currently chosen rate
|
||||
* @param array $refreshRates List of refresh rates
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getRefreshList($name,
|
||||
$defaultRate = 5,
|
||||
$refreshRates = Array(1, 2, 5, 10, 20, 40, 60, 120, 300, 600)
|
||||
) {
|
||||
$return = '<select name="' . $name . '" id="id_' . $name
|
||||
. '" class="refreshRate">';
|
||||
foreach ($refreshRates as $rate) {
|
||||
$selected = ($rate == $defaultRate)?' selected="selected"':'';
|
||||
$return .= '<option value="' . $rate . '"' . $selected . '>';
|
||||
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 .= '</option>';
|
||||
}
|
||||
$return .= '</select>';
|
||||
return $return;
|
||||
}
|
||||
|
||||
?>
|
||||
163
server_status_queries.php
Normal file
163
server_status_queries.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Displays query statistics for the server
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/server_common.inc.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();
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('server_status_queries.js');
|
||||
/* < IE 9 doesn't support canvas natively */
|
||||
if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
|
||||
$scripts->addFile('jqplot/excanvas.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('jquery/jquery.tablesorter.js');
|
||||
$scripts->addFile('server_status_sorter.js');
|
||||
|
||||
// Add the html content to the response
|
||||
$response->addHTML('<div>');
|
||||
$response->addHTML($ServerStatusData->getMenuHtml());
|
||||
$response->addHTML(getQueryStatisticsHtml($ServerStatusData));
|
||||
$response->addHTML('</div>');
|
||||
exit;
|
||||
|
||||
/**
|
||||
* Returns the html content for the query statistics
|
||||
*
|
||||
* @param object $ServerStatusData An instance of the PMA_ServerStatusData class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getQueryStatisticsHtml($ServerStatusData)
|
||||
{
|
||||
$retval = '';
|
||||
|
||||
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
|
||||
$used_queries = $ServerStatusData->used_queries;
|
||||
$total_queries = array_sum($used_queries);
|
||||
|
||||
$retval .= '<h3 id="serverstatusqueries">';
|
||||
/* l10n: Questions is the name of a MySQL Status variable */
|
||||
$retval .= sprintf(
|
||||
__('Questions since startup: %s'),
|
||||
PMA_Util::formatNumber($total_queries, 0)
|
||||
);
|
||||
$retval .= ' ';
|
||||
$retval .= PMA_Util::showMySQLDocu(
|
||||
'server-status-variables',
|
||||
'server-status-variables',
|
||||
false,
|
||||
'statvar_Questions'
|
||||
);
|
||||
$retval .= '<br />';
|
||||
$retval .= '<span>';
|
||||
$retval .= 'ø ' . __('per hour') . ': ';
|
||||
$retval .= PMA_Util::formatNumber($total_queries * $hour_factor, 0);
|
||||
$retval .= '<br />';
|
||||
$retval .= 'ø ' . __('per minute') . ': ';
|
||||
$retval .= PMA_Util::formatNumber($total_queries * 60 / $ServerStatusData->status['Uptime'], 0);
|
||||
$retval .= '<br />';
|
||||
if ($total_queries / $ServerStatusData->status['Uptime'] >= 1) {
|
||||
$retval .= 'ø ' . __('per second') . ': ';
|
||||
$retval .= PMA_Util::formatNumber($total_queries / $ServerStatusData->status['Uptime'], 0);
|
||||
}
|
||||
$retval .= '</span>';
|
||||
$retval .= '</h3>';
|
||||
|
||||
// reverse sort by value to show most used statements first
|
||||
arsort($used_queries);
|
||||
|
||||
$odd_row = true;
|
||||
$count_displayed_rows = 0;
|
||||
$perc_factor = 100 / $total_queries; //(- $ServerStatusData->status['Connections']);
|
||||
|
||||
$retval .= '<table id="serverstatusqueriesdetails" class="data sortable noclick">';
|
||||
$retval .= '<col class="namecol" />';
|
||||
$retval .= '<col class="valuecol" span="3" />';
|
||||
$retval .= '<thead>';
|
||||
$retval .= '<tr><th>' . __('Statements') . '</th>';
|
||||
$retval .= '<th>';
|
||||
/* l10n: # = Amount of queries */
|
||||
$retval .= __('#');
|
||||
$retval .= '</th>';
|
||||
$retval .= '<th>ø ' . __('per hour') . '</th>';
|
||||
$retval .= '<th>%</th>';
|
||||
$retval .= '</tr>';
|
||||
$retval .= '</thead>';
|
||||
$retval .= '<tbody>';
|
||||
|
||||
$chart_json = array();
|
||||
$query_sum = array_sum($used_queries);
|
||||
$other_sum = 0;
|
||||
foreach ($used_queries as $name => $value) {
|
||||
$odd_row = !$odd_row;
|
||||
// For the percentage column, use Questions - Connections, because
|
||||
// the number of connections is not an item of the Query types
|
||||
// but is included in Questions. Then the total of the percentages is 100.
|
||||
$name = str_replace(array('Com_', '_'), array('', ' '), $name);
|
||||
// Group together values that make out less than 2% into "Other", but only
|
||||
// if we have more than 6 fractions already
|
||||
if ($value < $query_sum * 0.02 && count($chart_json)>6) {
|
||||
$other_sum += $value;
|
||||
} else {
|
||||
$chart_json[$name] = $value;
|
||||
}
|
||||
$retval .= '<tr class="';
|
||||
$retval .= $odd_row ? 'odd' : 'even';
|
||||
$retval .= '">';
|
||||
$retval .= '<th class="name">' . htmlspecialchars($name) . '</th>';
|
||||
$retval .= '<td class="value">';
|
||||
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 5, 0, true));
|
||||
$retval .= '</td>';
|
||||
$retval .= '<td class="value">';
|
||||
$retval .= htmlspecialchars(
|
||||
PMA_Util::formatNumber($value * $hour_factor, 4, 1, true)
|
||||
);
|
||||
$retval .= '</td>';
|
||||
$retval .= '<td class="value">';
|
||||
$retval .= htmlspecialchars(
|
||||
PMA_Util::formatNumber($value * $perc_factor, 0, 2)
|
||||
);
|
||||
$retval .= '</td>';
|
||||
$retval .= '</tr>';
|
||||
}
|
||||
$retval .= '</tbody>';
|
||||
$retval .= '</table>';
|
||||
|
||||
$retval .= '<div id="serverstatusquerieschart"></div>';
|
||||
$retval .= '<div id="serverstatusquerieschart_data" style="display:none;">';
|
||||
if ($other_sum > 0) {
|
||||
$chart_json[__('Other')] = $other_sum;
|
||||
}
|
||||
$retval .= htmlspecialchars(json_encode($chart_json));
|
||||
$retval .= '</div>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
||||
763
server_status_variables.php
Normal file
763
server_status_variables.php
Normal file
@ -0,0 +1,763 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Displays a list of server status variables
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/server_common.inc.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';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('server_status_variables.js');
|
||||
$scripts->addFile('jquery/jquery.tablesorter.js');
|
||||
$scripts->addFile('server_status_sorter.js');
|
||||
|
||||
$response->addHTML('<div>');
|
||||
$response->addHTML($ServerStatusData->getMenuHtml());
|
||||
$response->addHTML(getFilterHtml($ServerStatusData));
|
||||
$response->addHTML(getLinkSuggestionsHtml($ServerStatusData));
|
||||
$response->addHTML(getVariablesTableHtml($ServerStatusData));
|
||||
$response->addHTML('</div>');
|
||||
|
||||
exit;
|
||||
|
||||
/**
|
||||
* Returns the html for the list filter
|
||||
*
|
||||
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFilterHtml($ServerStatusData)
|
||||
{
|
||||
$filterAlert = '';
|
||||
if (! empty($_REQUEST['filterAlert'])) {
|
||||
$filterAlert = ' checked="checked"';
|
||||
}
|
||||
$filterText = '';
|
||||
if (! empty($_REQUEST['filterText'])) {
|
||||
$filterText = htmlspecialchars($_REQUEST['filterText']);
|
||||
}
|
||||
$dontFormat = '';
|
||||
if (! empty($_REQUEST['dontFormat'])) {
|
||||
$dontFormat = ' checked="checked"';
|
||||
}
|
||||
|
||||
$retval = '';
|
||||
$retval .= '<fieldset id="tableFilter">';
|
||||
$retval .= '<legend>' . __('Filters') . '</legend>';
|
||||
$retval .= '<form action="server_status_variables.php?' . PMA_generate_common_url() . '">';
|
||||
$retval .= '<input type="submit" value="' . __('Refresh') . '" />';
|
||||
$retval .= '<div class="formelement">';
|
||||
$retval .= '<label for="filterText">' . __('Containing the word:') . '</label>';
|
||||
$retval .= '<input name="filterText" type="text" id="filterText" '
|
||||
. 'style="vertical-align: baseline;" value="' . $filterText . '" />';
|
||||
$retval .= '</div>';
|
||||
$retval .= '<div class="formelement">';
|
||||
$retval .= '<input' . $filterAlert . ' type="checkbox" name="filterAlert" id="filterAlert" />';
|
||||
$retval .= '<label for="filterAlert">';
|
||||
$retval .= __('Show only alert values');
|
||||
$retval .= '</label>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '<div class="formelement">';
|
||||
$retval .= '<select id="filterCategory" name="filterCategory">';
|
||||
$retval .= '<option value="">' . __('Filter by category...') . '</option>';
|
||||
|
||||
foreach ($ServerStatusData->sections as $section_id => $section_name) {
|
||||
if (isset($ServerStatusData->categoryUsed[$section_id])) {
|
||||
if (! empty($_REQUEST['filterCategory'])
|
||||
&& $_REQUEST['filterCategory'] == $section_id
|
||||
) {
|
||||
$selected = ' selected="selected"';
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$retval .= '<option' . $selected . ' value="' . $section_id. '">';
|
||||
$retval .= htmlspecialchars($section_name) . '</option>';
|
||||
}
|
||||
}
|
||||
$retval .= '</select>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '<div class="formelement">';
|
||||
$retval .= '<input' . $dontFormat . ' type="checkbox" name="dontFormat" id="dontFormat" />';
|
||||
$retval .= '<label for="dontFormat">';
|
||||
$retval .= __('Show unformatted values');
|
||||
$retval .= '</label>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '</form>';
|
||||
$retval .= '</fieldset>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the suggestion links
|
||||
*
|
||||
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getLinkSuggestionsHtml($ServerStatusData)
|
||||
{
|
||||
$retval = '<div id="linkSuggestions" class="defaultLinks" style="display:none">';
|
||||
$retval .= '<p class="notice">' . __('Related links:');
|
||||
foreach ($ServerStatusData->links as $section_name => $section_links) {
|
||||
$retval .= '<span class="status_' . $section_name . '"> ';
|
||||
$i=0;
|
||||
foreach ($section_links as $link_name => $link_url) {
|
||||
if ($i > 0) {
|
||||
$retval .= ', ';
|
||||
}
|
||||
if ('doc' == $link_name) {
|
||||
$retval .= PMA_Util::showMySQLDocu($link_url, $link_url);
|
||||
} else {
|
||||
$retval .= '<a href="' . $link_url . '">' . $link_name . '</a>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$retval .= '</span>';
|
||||
}
|
||||
unset($link_url, $link_name, $i);
|
||||
$retval .= '</p>';
|
||||
$retval .= '</div>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a table with variables information
|
||||
*
|
||||
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getVariablesTableHtml($ServerStatusData)
|
||||
{
|
||||
$retval = '';
|
||||
$strShowStatus = getStatusVariablesDescriptions();
|
||||
/**
|
||||
* define some alerts
|
||||
*/
|
||||
// name => max value before alert
|
||||
$alerts = array(
|
||||
// lower is better
|
||||
// variable => max value
|
||||
'Aborted_clients' => 0,
|
||||
'Aborted_connects' => 0,
|
||||
|
||||
'Binlog_cache_disk_use' => 0,
|
||||
|
||||
'Created_tmp_disk_tables' => 0,
|
||||
|
||||
'Handler_read_rnd' => 0,
|
||||
'Handler_read_rnd_next' => 0,
|
||||
|
||||
'Innodb_buffer_pool_pages_dirty' => 0,
|
||||
'Innodb_buffer_pool_reads' => 0,
|
||||
'Innodb_buffer_pool_wait_free' => 0,
|
||||
'Innodb_log_waits' => 0,
|
||||
'Innodb_row_lock_time_avg' => 10, // ms
|
||||
'Innodb_row_lock_time_max' => 50, // ms
|
||||
'Innodb_row_lock_waits' => 0,
|
||||
|
||||
'Slow_queries' => 0,
|
||||
'Delayed_errors' => 0,
|
||||
'Select_full_join' => 0,
|
||||
'Select_range_check' => 0,
|
||||
'Sort_merge_passes' => 0,
|
||||
'Opened_tables' => 0,
|
||||
'Table_locks_waited' => 0,
|
||||
'Qcache_lowmem_prunes' => 0,
|
||||
|
||||
'Qcache_free_blocks' => isset($ServerStatusData->server_status['Qcache_total_blocks'])
|
||||
? $ServerStatusData->server_status['Qcache_total_blocks'] / 5 : 0,
|
||||
'Slow_launch_threads' => 0,
|
||||
|
||||
// depends on Key_read_requests
|
||||
// normaly lower then 1:0.01
|
||||
'Key_reads' => isset($ServerStatusData->status['Key_read_requests'])
|
||||
? (0.01 * $ServerStatusData->status['Key_read_requests']) : 0,
|
||||
// depends on Key_write_requests
|
||||
// normaly nearly 1:1
|
||||
'Key_writes' => isset($ServerStatusData->status['Key_write_requests'])
|
||||
? (0.9 * $ServerStatusData->status['Key_write_requests']) : 0,
|
||||
|
||||
'Key_buffer_fraction' => 0.5,
|
||||
|
||||
// alert if more than 95% of thread cache is in use
|
||||
'Threads_cached' => isset($ServerStatusData->variables['thread_cache_size'])
|
||||
? 0.95 * $ServerStatusData->variables['thread_cache_size'] : 0
|
||||
|
||||
// higher is better
|
||||
// variable => min value
|
||||
//'Handler read key' => '> ',
|
||||
);
|
||||
|
||||
$retval .= '<table class="data sortable noclick" id="serverstatusvariables">';
|
||||
$retval .= '<col class="namecol" />';
|
||||
$retval .= '<col class="valuecol" />';
|
||||
$retval .= '<col class="descrcol" />';
|
||||
$retval .= '<thead>';
|
||||
$retval .= '<tr>';
|
||||
$retval .= '<th>' . __('Variable') . '</th>';
|
||||
$retval .= '<th>' . __('Value') . '</th>';
|
||||
$retval .= '<th>' . __('Description') . '</th>';
|
||||
$retval .= '</tr>';
|
||||
$retval .= '</thead>';
|
||||
$retval .= '<tbody>';
|
||||
|
||||
$odd_row = false;
|
||||
foreach ($ServerStatusData->status as $name => $value) {
|
||||
$odd_row = !$odd_row;
|
||||
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even')
|
||||
. (isset($ServerStatusData->allocationMap[$name])?' s_' . $ServerStatusData->allocationMap[$name] : '')
|
||||
. '">';
|
||||
|
||||
$retval .= '<th class="name">';
|
||||
$retval .= htmlspecialchars(str_replace('_', ' ', $name));
|
||||
/* Fields containing % are calculated, they can not be described in MySQL documentation */
|
||||
if (strpos($name, '%') === false) {
|
||||
$retval .= PMA_Util::showMySQLDocu(
|
||||
'server-status-variables',
|
||||
'server-status-variables',
|
||||
false,
|
||||
'statvar_' . $name
|
||||
);
|
||||
}
|
||||
$retval .= '</th>';
|
||||
|
||||
$retval .= '<td class="value"><span class="formatted">';
|
||||
if (isset($alerts[$name])) {
|
||||
if ($value > $alerts[$name]) {
|
||||
$retval .= '<span class="attention">';
|
||||
} else {
|
||||
$retval .= '<span class="allfine">';
|
||||
}
|
||||
}
|
||||
if ('%' === substr($name, -1, 1)) {
|
||||
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
|
||||
} elseif (strpos($name, 'Uptime') !== false) {
|
||||
$retval .= htmlspecialchars(
|
||||
PMA_Util::timespanFormat($value)
|
||||
);
|
||||
} elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
|
||||
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
|
||||
} elseif (is_numeric($value) && $value == (int) $value) {
|
||||
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 0));
|
||||
} elseif (is_numeric($value)) {
|
||||
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
|
||||
} else {
|
||||
$retval .= htmlspecialchars($value);
|
||||
}
|
||||
if (isset($alerts[$name])) {
|
||||
$retval .= '</span>';
|
||||
}
|
||||
$retval .= '</span>';
|
||||
$retval .= '<span style="display:none;" class="original">';
|
||||
$retval .= $value;
|
||||
$retval .= '</span>';
|
||||
$retval .= '</td>';
|
||||
$retval .= '<td class="descr">';
|
||||
|
||||
if (isset($strShowStatus[$name])) {
|
||||
$retval .= $strShowStatus[$name];
|
||||
}
|
||||
|
||||
if (isset($ServerStatusData->links[$name])) {
|
||||
foreach ($ServerStatusData->links[$name] as $link_name => $link_url) {
|
||||
if ('doc' == $link_name) {
|
||||
$retval .= PMA_Util::showMySQLDocu($link_url, $link_url);
|
||||
} else {
|
||||
$retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>';
|
||||
}
|
||||
}
|
||||
unset($link_url, $link_name);
|
||||
}
|
||||
$retval .= '</td>';
|
||||
$retval .= '</tr>';
|
||||
}
|
||||
$retval .= '</tbody>';
|
||||
$retval .= '</table>';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of variable descriptions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getStatusVariablesDescriptions()
|
||||
{
|
||||
/**
|
||||
* Messages are built using the message name
|
||||
*/
|
||||
return array(
|
||||
'Aborted_clients' => __(
|
||||
'The number of connections that were aborted because the client died'
|
||||
. ' without closing the connection properly.'
|
||||
),
|
||||
'Aborted_connects' => __(
|
||||
'The number of failed attempts to connect to the MySQL server.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Binlog_cache_use' => __(
|
||||
'The number of transactions that used the temporary binary log cache.'
|
||||
),
|
||||
'Connections' => __(
|
||||
'The number of connection attempts (successful or not)'
|
||||
. ' to the MySQL server.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Created_tmp_files' => __(
|
||||
'How many temporary files mysqld has created.'
|
||||
),
|
||||
'Created_tmp_tables' => __(
|
||||
'The number of in-memory temporary tables created automatically'
|
||||
. ' by the server while executing statements.'
|
||||
),
|
||||
'Delayed_errors' => __(
|
||||
'The number of rows written with INSERT DELAYED for which some'
|
||||
. ' error occurred (probably duplicate key).'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Delayed_writes' => __(
|
||||
'The number of INSERT DELAYED rows written.'
|
||||
),
|
||||
'Flush_commands' => __(
|
||||
'The number of executed FLUSH statements.'
|
||||
),
|
||||
'Handler_commit' => __(
|
||||
'The number of internal COMMIT statements.'
|
||||
),
|
||||
'Handler_delete' => __(
|
||||
'The number of times a row was deleted from a table.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Handler_rollback' => __(
|
||||
'The number of internal ROLLBACK statements.'
|
||||
),
|
||||
'Handler_update' => __(
|
||||
'The number of requests to update a row in a table.'
|
||||
),
|
||||
'Handler_write' => __(
|
||||
'The number of requests to insert a row in a table.'
|
||||
),
|
||||
'Innodb_buffer_pool_pages_data' => __(
|
||||
'The number of pages containing data (dirty or clean).'
|
||||
),
|
||||
'Innodb_buffer_pool_pages_dirty' => __(
|
||||
'The number of pages currently dirty.'
|
||||
),
|
||||
'Innodb_buffer_pool_pages_flushed' => __(
|
||||
'The number of buffer pool pages that have been requested'
|
||||
. ' to be flushed.'
|
||||
),
|
||||
'Innodb_buffer_pool_pages_free' => __(
|
||||
'The number of free pages.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Innodb_buffer_pool_pages_total' => __(
|
||||
'Total size of buffer pool, in pages.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Innodb_buffer_pool_read_ahead_seq' => __(
|
||||
'The number of sequential read-aheads InnoDB initiated. This'
|
||||
. ' happens when InnoDB does a sequential full table scan.'
|
||||
),
|
||||
'Innodb_buffer_pool_read_requests' => __(
|
||||
'The number of logical read requests InnoDB has done.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Innodb_buffer_pool_write_requests' => __(
|
||||
'The number writes done to the InnoDB buffer pool.'
|
||||
),
|
||||
'Innodb_data_fsyncs' => __(
|
||||
'The number of fsync() operations so far.'
|
||||
),
|
||||
'Innodb_data_pending_fsyncs' => __(
|
||||
'The current number of pending fsync() operations.'
|
||||
),
|
||||
'Innodb_data_pending_reads' => __(
|
||||
'The current number of pending reads.'
|
||||
),
|
||||
'Innodb_data_pending_writes' => __(
|
||||
'The current number of pending writes.'
|
||||
),
|
||||
'Innodb_data_read' => __(
|
||||
'The amount of data read so far, in bytes.'
|
||||
),
|
||||
'Innodb_data_reads' => __(
|
||||
'The total number of data reads.'
|
||||
),
|
||||
'Innodb_data_writes' => __(
|
||||
'The total number of data writes.'
|
||||
),
|
||||
'Innodb_data_written' => __(
|
||||
'The amount of data written so far, in bytes.'
|
||||
),
|
||||
'Innodb_dblwr_pages_written' => __(
|
||||
'The number of pages that have been written for'
|
||||
. ' doublewrite operations.'
|
||||
),
|
||||
'Innodb_dblwr_writes' => __(
|
||||
'The number of doublewrite operations that have been performed.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Innodb_log_write_requests' => __(
|
||||
'The number of log write requests.'
|
||||
),
|
||||
'Innodb_log_writes' => __(
|
||||
'The number of physical writes to the log file.'
|
||||
),
|
||||
'Innodb_os_log_fsyncs' => __(
|
||||
'The number of fsync() writes done to the log file.'
|
||||
),
|
||||
'Innodb_os_log_pending_fsyncs' => __(
|
||||
'The number of pending log file fsyncs.'
|
||||
),
|
||||
'Innodb_os_log_pending_writes' => __(
|
||||
'Pending log file writes.'
|
||||
),
|
||||
'Innodb_os_log_written' => __(
|
||||
'The number of bytes written to the log file.'
|
||||
),
|
||||
'Innodb_pages_created' => __(
|
||||
'The number of pages created.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Innodb_pages_read' => __(
|
||||
'The number of pages read.'
|
||||
),
|
||||
'Innodb_pages_written' => __(
|
||||
'The number of pages written.'
|
||||
),
|
||||
'Innodb_row_lock_current_waits' => __(
|
||||
'The number of row locks currently being waited for.'
|
||||
),
|
||||
'Innodb_row_lock_time_avg' => __(
|
||||
'The average time to acquire a row lock, in milliseconds.'
|
||||
),
|
||||
'Innodb_row_lock_time' => __(
|
||||
'The total time spent in acquiring row locks, in milliseconds.'
|
||||
),
|
||||
'Innodb_row_lock_time_max' => __(
|
||||
'The maximum time to acquire a row lock, in milliseconds.'
|
||||
),
|
||||
'Innodb_row_lock_waits' => __(
|
||||
'The number of times a row lock had to be waited for.'
|
||||
),
|
||||
'Innodb_rows_deleted' => __(
|
||||
'The number of rows deleted from InnoDB tables.'
|
||||
),
|
||||
'Innodb_rows_inserted' => __(
|
||||
'The number of rows inserted in InnoDB tables.'
|
||||
),
|
||||
'Innodb_rows_read' => __(
|
||||
'The number of rows read from InnoDB tables.'
|
||||
),
|
||||
'Innodb_rows_updated' => __(
|
||||
'The number of rows updated in InnoDB tables.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Key_buffer_fraction_%' => __(
|
||||
'Percentage of used key cache (calculated value)'
|
||||
),
|
||||
'Key_read_requests' => __(
|
||||
'The number of requests to read a key block from the cache.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Key_read_ratio_%' => __(
|
||||
'Key cache miss calculated as rate of physical reads compared'
|
||||
. ' to read requests (calculated value)'
|
||||
),
|
||||
'Key_write_requests' => __(
|
||||
'The number of requests to write a key block to the cache.'
|
||||
),
|
||||
'Key_writes' => __(
|
||||
'The number of physical writes of a key block to disk.'
|
||||
),
|
||||
'Key_write_ratio_%' => __(
|
||||
'Percentage of physical writes compared'
|
||||
. ' to write requests (calculated value)'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Max_used_connections' => __(
|
||||
'The maximum number of connections that have been in use'
|
||||
. ' simultaneously since the server started.'
|
||||
),
|
||||
'Not_flushed_delayed_rows' => __(
|
||||
'The number of rows waiting to be written in INSERT DELAYED queues.'
|
||||
),
|
||||
'Opened_tables' => __(
|
||||
'The number of tables that have been opened. If opened tables is'
|
||||
. ' big, your table cache value is probably too small.'
|
||||
),
|
||||
'Open_files' => __(
|
||||
'The number of files that are open.'
|
||||
),
|
||||
'Open_streams' => __(
|
||||
'The number of streams that are open (used mainly for logging).'
|
||||
),
|
||||
'Open_tables' => __(
|
||||
'The number of tables that are open.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Qcache_free_memory' => __(
|
||||
'The amount of free memory for query cache.'
|
||||
),
|
||||
'Qcache_hits' => __(
|
||||
'The number of cache hits.'
|
||||
),
|
||||
'Qcache_inserts' => __(
|
||||
'The number of queries added to the cache.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Qcache_not_cached' => __(
|
||||
'The number of non-cached queries (not cachable, or not cached'
|
||||
. ' due to the query_cache_type setting).'
|
||||
),
|
||||
'Qcache_queries_in_cache' => __(
|
||||
'The number of queries registered in the cache.'
|
||||
),
|
||||
'Qcache_total_blocks' => __(
|
||||
'The total number of blocks in the query cache.'
|
||||
),
|
||||
'Rpl_status' => __(
|
||||
'The status of failsafe replication (not yet implemented).'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Select_full_range_join' => __(
|
||||
'The number of joins that used a range search on a reference table.'
|
||||
),
|
||||
'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.)'
|
||||
),
|
||||
'Select_range' => __(
|
||||
'The number of joins that used ranges on the first table. (It\'s'
|
||||
. ' normally not critical even if this is big.)'
|
||||
),
|
||||
'Select_scan' => __(
|
||||
'The number of joins that did a full scan of the first table.'
|
||||
),
|
||||
'Slave_open_temp_tables' => __(
|
||||
'The number of temporary tables currently'
|
||||
. ' open by the slave SQL thread.'
|
||||
),
|
||||
'Slave_retried_transactions' => __(
|
||||
'Total (since startup) number of times the replication slave SQL'
|
||||
. ' thread has retried transactions.'
|
||||
),
|
||||
'Slave_running' => __(
|
||||
'This is ON if this server is a slave that is connected to a master.'
|
||||
),
|
||||
'Slow_launch_threads' => __(
|
||||
'The number of threads that have taken more than slow_launch_time'
|
||||
. ' seconds to create.'
|
||||
),
|
||||
'Slow_queries' => __(
|
||||
'The number of queries that have taken more than long_query_time'
|
||||
. ' seconds.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Sort_range' => __(
|
||||
'The number of sorts that were done with ranges.'
|
||||
),
|
||||
'Sort_rows' => __(
|
||||
'The number of sorted rows.'
|
||||
),
|
||||
'Sort_scan' => __(
|
||||
'The number of sorts that were done by scanning the table.'
|
||||
),
|
||||
'Table_locks_immediate' => __(
|
||||
'The number of times that a table lock was acquired immediately.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'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.'
|
||||
),
|
||||
'Threads_connected' => __(
|
||||
'The number of currently open connections.'
|
||||
),
|
||||
'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.)'
|
||||
),
|
||||
'Threads_cache_hitrate_%' => __(
|
||||
'Thread cache hit rate (calculated value)'
|
||||
),
|
||||
'Threads_running' => __(
|
||||
'The number of threads that are not sleeping.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user