Merge remote-tracking branch 'tyron/master'
This commit is contained in:
commit
7741ad7286
@ -90,6 +90,13 @@ $js_messages['strChartIssuedQueriesTitle'] = __('Questions (executed statements
|
||||
$js_messages['strChartQueryPie'] = __('Query statistics');
|
||||
|
||||
/* server status monitor */
|
||||
$js_messages['strIncompatibleMonitorConfig'] = __('Local monitor configuration icompatible');
|
||||
$js_messages['strIncompatibleMonitorConfigDescription'] = __('The chart arrangement configuration in your browsers local storage is not compatible anymore to the newer version of the monitor dialog. It is very likely that your current configuration will not work anymore. Please reset your configuration to default in the <i>Settings</i> menu.');
|
||||
|
||||
$js_messages['strQueryCacheEfficiency'] = __('Query cache efficiency');
|
||||
$js_messages['strQueryCacheUsage'] = __('Query cache usage');
|
||||
$js_messages['strQueryCacheUsed'] = __('Query cache used');
|
||||
|
||||
$js_messages['strSystemCPUUsage'] = __('System CPU Usage');
|
||||
$js_messages['strSystemMemory'] = __('System memory');
|
||||
$js_messages['strSystemSwap'] = __('System swap');
|
||||
|
||||
@ -662,17 +662,19 @@ $(function() {
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function serverResponseError() {
|
||||
var btns = {};
|
||||
btns[PMA_messages['strReloadPage']] = function() {
|
||||
window.location.reload();
|
||||
};
|
||||
$('#emptyDialog').attr('title', PMA_messages['strRefreshFailed']);
|
||||
$('#emptyDialog').html(
|
||||
'<img class="icon ic_s_attention" src="themes/dot.gif" alt=""> ' +
|
||||
PMA_messages['strInvalidResponseExplanation']
|
||||
);
|
||||
$('#emptyDialog').dialog({ buttons: btns });
|
||||
}
|
||||
});
|
||||
|
||||
// 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').attr('title', PMA_messages['strRefreshFailed']);
|
||||
$('#emptyDialog').html(
|
||||
'<img class="icon ic_s_attention" src="themes/dot.gif" alt=""> ' +
|
||||
PMA_messages['strInvalidResponseExplanation']
|
||||
);
|
||||
$('#emptyDialog').dialog({ buttons: btns });
|
||||
}
|
||||
|
||||
@ -16,6 +16,11 @@ $(function() {
|
||||
// Holds about to 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
|
||||
var monitorProtocolVersion = '1.0';
|
||||
|
||||
// Runtime parameter of the monitor, is being fully set in initGrid()
|
||||
var runtime = {
|
||||
@ -51,103 +56,158 @@ $(function() {
|
||||
|
||||
// Allows drag and drop rearrange and print/edit icons on charts
|
||||
var editMode = false;
|
||||
|
||||
|
||||
/* List of preconfigured charts that the user may select */
|
||||
var presetCharts = {
|
||||
'cpu-WINNT': {
|
||||
title: PMA_messages['strSystemCPUUsage'],
|
||||
nodes: [{ dataType: 'cpu', name: PMA_messages['strAverageLoad'], dataPoint: 'loadavg', unit: '%'}]
|
||||
// Query cache efficiency
|
||||
'qce': {
|
||||
title: PMA_messages['strQueryCacheEfficiency'],
|
||||
nodes: [ {
|
||||
name: PMA_messages['strQueryCacheEfficiency'],
|
||||
dataPoints: [{type: 'statusvar', name: 'Qcache_hits'}, {type: 'statusvar', name: 'Com_select'}],
|
||||
unit: '%',
|
||||
transformFn: 'qce'
|
||||
} ]
|
||||
},
|
||||
'memory-WINNT': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
nodes: [
|
||||
{ dataType: 'memory', name: PMA_messages['strTotalMemory'], dataPoint: 'MemTotal', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strUsedMemory'], dataPoint: 'MemUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
|
||||
]
|
||||
},
|
||||
'swap-WINNT': {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
nodes: [
|
||||
{ dataType: 'memory', name: PMA_messages['strTotalSwap'], dataPoint: 'SwapTotal', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strUsedSwap'], dataPoint: 'SwapUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
|
||||
]
|
||||
},
|
||||
'cpu-Linux': {
|
||||
title: PMA_messages['strSystemCPUUsage'],
|
||||
nodes: [
|
||||
{ dataType: 'cpu',
|
||||
name: PMA_messages['strAverageLoad'],
|
||||
unit: '%',
|
||||
transformFn: 'cpu-linux'
|
||||
}
|
||||
]
|
||||
},
|
||||
'memory-Linux': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
nodes: [
|
||||
{ dataType: 'memory', name: PMA_messages['strUsedMemory'], dataPoint: 'MemUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strCachedMemory'], dataPoint: 'Cached', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strBufferedMemory'], dataPoint: 'Buffers', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strFreeMemory'], dataPoint: 'MemFree', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
|
||||
],
|
||||
settings: {
|
||||
chart: {
|
||||
type: 'area',
|
||||
animation: false
|
||||
},
|
||||
plotOptions: {
|
||||
area: {
|
||||
stacking: 'percent'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'swap-Linux': {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
nodes: [
|
||||
{ dataType: 'memory', name: PMA_messages['strTotalSwap'], dataPoint: 'SwapUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strCachedSwap'], dataPoint: 'SwapCached', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ dataType: 'memory', name: PMA_messages['strFreeSwap'], dataPoint: 'SwapFree', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
|
||||
],
|
||||
settings: {
|
||||
chart: {
|
||||
type: 'area',
|
||||
animation: false
|
||||
},
|
||||
plotOptions: {
|
||||
area: {
|
||||
stacking: 'percent'
|
||||
}
|
||||
}
|
||||
}
|
||||
// Query cache usage
|
||||
'qcu': {
|
||||
title: PMA_messages['strQueryCacheUsage'],
|
||||
nodes: [ {
|
||||
name: PMA_messages['strQueryCacheUsed'],
|
||||
dataPoints: [{type: 'statusvar', name: 'Qcache_free_memory'}, {type: 'servervar', name: 'query_cache_size'}],
|
||||
unit: '%',
|
||||
transformFn: 'qcu'
|
||||
} ]
|
||||
}
|
||||
};
|
||||
|
||||
/* Add OS specific system info charts to the preset chart list */
|
||||
switch(server_os) {
|
||||
case 'WINNT':
|
||||
$.extend(presetCharts, {
|
||||
'cpu': {
|
||||
title: PMA_messages['strSystemCPUUsage'],
|
||||
nodes: [ {
|
||||
name: PMA_messages['strAverageLoad'],
|
||||
dataPoints: [{ type: 'cpu', name: 'loadavg'}],
|
||||
unit: '%'
|
||||
} ]
|
||||
},
|
||||
|
||||
'memory': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
nodes: [ {
|
||||
name: PMA_messages['strTotalMemory'],
|
||||
dataPoints: [{ type: 'memory', name: 'MemTotal' }],
|
||||
valueDivisor: 1024,
|
||||
unit: PMA_messages['strMiB']
|
||||
}, {
|
||||
dataType: 'memory',
|
||||
name: PMA_messages['strUsedMemory'],
|
||||
dataPoints: [{ type: 'memory', name: 'MemUsed' }],
|
||||
valueDivisor: 1024,
|
||||
unit: PMA_messages['strMiB']
|
||||
} ]
|
||||
},
|
||||
|
||||
'swap': {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
nodes: [ {
|
||||
name: PMA_messages['strTotalSwap'],
|
||||
dataPoints: [{ type: 'memory', name: 'SwapTotal' }],
|
||||
valueDivisor: 1024,
|
||||
unit: PMA_messages['strMiB']
|
||||
}, {
|
||||
name: PMA_messages['strUsedSwap'],
|
||||
dataPoints: [{ type: 'memory', name: 'SwapUsed' }],
|
||||
valueDivisor: 1024,
|
||||
unit: PMA_messages['strMiB']
|
||||
} ]
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Linux':
|
||||
$.extend(presetCharts, {
|
||||
'cpu': {
|
||||
title: PMA_messages['strSystemCPUUsage'],
|
||||
nodes: [ {
|
||||
name: PMA_messages['strAverageLoad'],
|
||||
dataPoints: [{ type: 'cpu', name: 'irrelevant' }],
|
||||
unit: '%',
|
||||
transformFn: 'cpu-linux'
|
||||
} ]
|
||||
},
|
||||
'memory': {
|
||||
title: PMA_messages['strSystemMemory'],
|
||||
nodes: [
|
||||
{ name: PMA_messages['strUsedMemory'], dataPoints: [{ type: 'memory', name: 'MemUsed' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ name: PMA_messages['strCachedMemory'], dataPoints: [{ type: 'memory', name: 'Cached' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ name: PMA_messages['strBufferedMemory'], dataPoints: [{ type: 'memory', name: 'Buffers' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ name: PMA_messages['strFreeMemory'], dataPoints: [{ type: 'memory', name: 'MemFree' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] }
|
||||
],
|
||||
settings: {
|
||||
chart: {
|
||||
type: 'area',
|
||||
animation: false
|
||||
},
|
||||
plotOptions: {
|
||||
area: {
|
||||
stacking: 'percent'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'swap': {
|
||||
title: PMA_messages['strSystemSwap'],
|
||||
nodes: [
|
||||
{ name: PMA_messages['strUsedSwap'], dataPoints: [{ type: 'memory', name: 'SwapUsed' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ name: PMA_messages['strCachedSwap'], dataPoints: [{ type: 'memory', name: 'SwapCached' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] },
|
||||
{ name: PMA_messages['strFreeSwap'], dataPoints: [{ type: 'memory', name: 'SwapFree' }], valueDivisor: 1024, unit: PMA_messages['strMiB'] }
|
||||
],
|
||||
settings: {
|
||||
chart: {
|
||||
type: 'area',
|
||||
animation: false
|
||||
},
|
||||
plotOptions: {
|
||||
area: {
|
||||
stacking: 'percent'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
// Default setting
|
||||
// Default setting for the chart grid
|
||||
defaultChartGrid = {
|
||||
'c0': { title: PMA_messages['strQuestions'],
|
||||
nodes: [{ dataType: 'statusvar', name: PMA_messages['strQuestions'], dataPoint: 'Questions', display: 'differential' }]
|
||||
nodes: [{name: PMA_messages['strQuestions'], dataPoints: [{ type: 'statusvar', name: 'Questions' }], display: 'differential' }]
|
||||
},
|
||||
'c1': {
|
||||
title: PMA_messages['strChartConnectionsTitle'],
|
||||
nodes: [ { dataType: 'statusvar', name: PMA_messages['strConnections'], dataPoint: 'Connections', display: 'differential' },
|
||||
{ dataType: 'proc', name: PMA_messages['strProcesses'], dataPoint: 'processes'} ]
|
||||
nodes: [ { name: PMA_messages['strConnections'], dataPoints: [{ type: 'statusvar', name: 'Connections' }], display: 'differential' },
|
||||
{ name: PMA_messages['strProcesses'], dataPoints: [{ type: 'proc', name: 'processes' }] } ]
|
||||
},
|
||||
'c2': {
|
||||
title: PMA_messages['strTraffic'],
|
||||
nodes: [
|
||||
{ dataType: 'statusvar', name: PMA_messages['strBytesSent'], dataPoint: 'Bytes_sent', display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] },
|
||||
{ dataType: 'statusvar', name: PMA_messages['strBytesReceived'], dataPoint: 'Bytes_received', display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] }
|
||||
{ name: PMA_messages['strBytesSent'], dataPoints: [{ type: 'statusvar', name: 'Bytes_sent' }], display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] },
|
||||
{ name: PMA_messages['strBytesReceived'], dataPoints: [{ type: 'statusvar', name: 'Bytes_received' }], display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] }
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// Server is localhost => We can add cpu/memory/swap
|
||||
// Server is localhost => We can add cpu/memory/swap to the default chart
|
||||
if (server_db_isLocal) {
|
||||
defaultChartGrid['c3'] = presetCharts['cpu-' + server_os];
|
||||
defaultChartGrid['c4'] = presetCharts['memory-' + server_os];
|
||||
defaultChartGrid['c5'] = presetCharts['swap-' + server_os];
|
||||
defaultChartGrid['c3'] = presetCharts['cpu'];
|
||||
defaultChartGrid['c4'] = presetCharts['memory'];
|
||||
defaultChartGrid['c5'] = presetCharts['swap'];
|
||||
}
|
||||
|
||||
/* Buttons that are on the top right corner of each chart */
|
||||
var gridbuttons = {
|
||||
cogButton: {
|
||||
//enabled: true,
|
||||
@ -368,9 +428,11 @@ $(function() {
|
||||
dlgButtons[PMA_messages['strAddChart']] = function() {
|
||||
var type = $('input[name="chartType"]:checked').val();
|
||||
|
||||
if (type == 'cpu' || type == 'memory' || type == 'swap') {
|
||||
newChart = presetCharts[type + '-' + server_os];
|
||||
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
|
||||
// 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']);
|
||||
return;
|
||||
@ -395,6 +457,17 @@ $(function() {
|
||||
$(this).dialog("close");
|
||||
};
|
||||
|
||||
var $presetList = $('div#addChartDialog select[name="presetCharts"]');
|
||||
if ($presetList.html().length == 0) {
|
||||
$.each(presetCharts, function(key, value) {
|
||||
$presetList.append('<option value="' + key + '">' + value.title + '</option>');
|
||||
});
|
||||
$presetList.change(function() {
|
||||
$('input#chartPreset').trigger('click');
|
||||
$('input[name="chartTitle"]').attr('value', presetCharts[$(this).prop('value')].title);
|
||||
});
|
||||
}
|
||||
|
||||
$('div#addChartDialog').dialog({
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
@ -500,6 +573,7 @@ $(function() {
|
||||
$('a[href="#clearMonitorConfig"]').click(function() {
|
||||
window.localStorage.removeItem('monitorCharts');
|
||||
window.localStorage.removeItem('monitorSettings');
|
||||
window.localStorage.removeItem('monitorVersion');
|
||||
$(this).hide();
|
||||
rebuildGrid();
|
||||
});
|
||||
@ -712,8 +786,7 @@ $(function() {
|
||||
}
|
||||
|
||||
var serie = {
|
||||
dataType: 'statusvar',
|
||||
dataPoint: $('input#variableInput').attr('value'),
|
||||
dataPoints: [{ type: 'statusvar', name: $('input#variableInput').attr('value') }],
|
||||
name: $('input#variableInput').attr('value'),
|
||||
display: $('input[name="differentialValue"]').attr('checked') ? 'differential' : ''
|
||||
};
|
||||
@ -733,7 +806,7 @@ $(function() {
|
||||
var str = serie.display == 'differential' ? ', ' + PMA_messages['strDifferential'] : '';
|
||||
str += serie.valueDivisor ? (', ' + $.sprintf(PMA_messages['strDividedBy'], serie.valueDivisor)) : '';
|
||||
|
||||
$('#seriesPreview').append('- ' + serie.dataPoint + str + '<br>');
|
||||
$('#seriesPreview').append('- ' + serie.name + str + '<br>');
|
||||
|
||||
newChart.nodes.push(serie);
|
||||
|
||||
@ -769,6 +842,19 @@ $(function() {
|
||||
}
|
||||
|
||||
$('a[href="#clearMonitorConfig"]').toggle(runtime.charts != null);
|
||||
|
||||
if (runtime.charts != null && monitorProtocolVersion != window.localStorage['monitorVersion']) {
|
||||
$('div#emptyDialog').attr('title',PMA_messages['strIncompatibleMonitorConfig']);
|
||||
$('div#emptyDialog').html(PMA_messages['strIncompatibleMonitorConfigDescription']);
|
||||
|
||||
var dlgBtns = {};
|
||||
dlgBtns[PMA_messages['strClose']] = function() { $(this).dialog('close'); };
|
||||
|
||||
$('div#emptyDialog').dialog({
|
||||
width: 400,
|
||||
buttons: dlgBtns
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (runtime.charts == null) {
|
||||
@ -1033,7 +1119,7 @@ $(function() {
|
||||
var htmlStr = '<p><b>Chart title: </b> <br/> <input type="text" size="35" name="chartTitle" value="' + chart.title + '" />';
|
||||
htmlStr += '</p><p><b>Series:</b> </p><ol>';
|
||||
for (var i = 0; i<chart.nodes.length; i++) {
|
||||
htmlStr += '<li><i>' + chart.nodes[i].dataPoint + ': </i><br/><input type="text" name="chartSerie-' + i + '" value=" ' + chart.nodes[i].name + '" /></li>';
|
||||
htmlStr += '<li><i>' + chart.nodes[i].dataPoints[0].name + ': </i><br/><input type="text" name="chartSerie-' + i + '" value="' + chart.nodes[i].name + '" /></li>';
|
||||
}
|
||||
|
||||
dlgBtns = {};
|
||||
@ -1114,10 +1200,8 @@ $(function() {
|
||||
if (! chartData[key]) {
|
||||
return;
|
||||
}
|
||||
// Draw all points
|
||||
// Draw all series
|
||||
for (var j = 0; j < elem.nodes.length; j++) {
|
||||
value = chartData[key][j].y;
|
||||
|
||||
// Update x-axis
|
||||
if (i == 0 && j == 0) {
|
||||
if (oldChartData == null) {
|
||||
@ -1132,24 +1216,32 @@ $(function() {
|
||||
|
||||
elem.chart.xAxis[0].setExtremes(runtime.xmin, runtime.xmax, false);
|
||||
|
||||
// Calculate y value
|
||||
if (elem.nodes[j].display == 'differential') {
|
||||
if (oldChartData == null || oldChartData[key] == null) {
|
||||
continue;
|
||||
}
|
||||
value -= oldChartData[key][j].y;
|
||||
}
|
||||
|
||||
if (elem.nodes[j].valueDivisor) {
|
||||
value = value / elem.nodes[j].valueDivisor;
|
||||
}
|
||||
|
||||
/* Calculate y value */
|
||||
|
||||
// If transform function given, use it
|
||||
if (elem.nodes[j].transformFn) {
|
||||
value = chartValueTransform(
|
||||
elem.nodes[j].transformFn,
|
||||
chartData[key][j],
|
||||
(oldChartData == null ? null : oldChartData[key][j])
|
||||
// Check if first iteration (oldChartData==null), or if newly added chart oldChartData[key]==null
|
||||
(oldChartData == null || oldChartData[key] == null ? null : oldChartData[key][j])
|
||||
);
|
||||
|
||||
// Otherwise use original value and apply differential and divisor if given,
|
||||
// in this case we have only one data point per series - located at chartData[key][j][0]
|
||||
} else {
|
||||
value = parseFloat(chartData[key][j][0].value);
|
||||
|
||||
if (elem.nodes[j].display == 'differential') {
|
||||
if (oldChartData == null || oldChartData[key] == null) {
|
||||
continue;
|
||||
}
|
||||
value -= oldChartData[key][j][0].value;
|
||||
}
|
||||
|
||||
if (elem.nodes[j].valueDivisor) {
|
||||
value = value / elem.nodes[j].valueDivisor;
|
||||
}
|
||||
}
|
||||
|
||||
// Set y value, if defined
|
||||
@ -1177,28 +1269,54 @@ $(function() {
|
||||
}
|
||||
|
||||
/* Function that supplies special value transform functions for chart values */
|
||||
function chartValueTransform(name, cur, prev) {
|
||||
function chartValueTransform(name, cur, prev) {
|
||||
switch(name) {
|
||||
case 'cpu-linux':
|
||||
if (prev == null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var diff_total = cur.busy + cur.idle - (prev.busy + prev.idle);
|
||||
var diff_idle = cur.idle - prev.idle;
|
||||
return 100*(diff_total - diff_idle) / diff_total;
|
||||
case 'cpu-linux':
|
||||
if (prev == null) {
|
||||
return undefined;
|
||||
}
|
||||
// cur and prev are datapoint arrays, but containing only 1 element for cpu-linux
|
||||
cur = cur[0], prev = prev[0];
|
||||
|
||||
var diff_total = cur.busy + cur.idle - (prev.busy + prev.idle);
|
||||
var diff_idle = cur.idle - prev.idle;
|
||||
return 100 * (diff_total - diff_idle) / diff_total;
|
||||
|
||||
// Query cache efficiency (%)
|
||||
case 'qce':
|
||||
if (prev == null) {
|
||||
return undefined;
|
||||
}
|
||||
// cur[0].value is Qcache_hits, cur[1].value is Com_select
|
||||
var diffQHits = cur[0].value - prev[0].value;
|
||||
// No NaN please :-)
|
||||
if (cur[1].value - prev[1].value == 0) return 0;
|
||||
|
||||
return diffQHits / (cur[1].value - prev[1].value + diffQHits) * 100;
|
||||
|
||||
// Query cache usage (%)
|
||||
case 'qcu':
|
||||
if (cur[1].value == 0) return 0;
|
||||
// cur[0].value is Qcache_free_memory, cur[1].value is query_cache_size
|
||||
return 100 - cur[0].value / cur[1].value * 100;
|
||||
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* Build list of nodes that need to be retrieved from server */
|
||||
/* Build list of nodes that need to be retrieved from server.
|
||||
* It creates something like a stripped down version of the runtime.charts object.
|
||||
*/
|
||||
function buildRequiredDataList() {
|
||||
runtime.dataList = {};
|
||||
// Store an own id, because the property name is subject of reordering,
|
||||
// thus destroying our mapping with runtime.charts <=> runtime.dataList
|
||||
var chartID = 0;
|
||||
$.each(runtime.charts, function(key, chart) {
|
||||
runtime.dataList[chartID] = chart.nodes;
|
||||
runtime.dataList[chartID] = [];
|
||||
for(var i=0; i < chart.nodes.length; i++) {
|
||||
runtime.dataList[chartID][i] = chart.nodes[i].dataPoints;
|
||||
}
|
||||
runtime.charts[key].chartID = chartID;
|
||||
chartID++;
|
||||
});
|
||||
@ -1746,6 +1864,7 @@ $(function() {
|
||||
if (window.localStorage) {
|
||||
window.localStorage['monitorCharts'] = $.toJSON(gridCopy);
|
||||
window.localStorage['monitorSettings'] = $.toJSON(monitorSettings);
|
||||
window.localStorage['monitorVersion'] = monitorProtocolVersion;
|
||||
}
|
||||
|
||||
$('a[href="#clearMonitorConfig"]').show();
|
||||
|
||||
@ -218,14 +218,14 @@ rule 'rate of reading fixed position'
|
||||
Handler_read_rnd / Uptime
|
||||
value * 60 * 60 > 1
|
||||
The rate of reading data from a fixed position is high.
|
||||
This indicates many queries need to sort results and/or do a full table scan, including join queries that do not use indexes. Add indexes where applicable.
|
||||
This indicates that many queries need to sort results and/or do a full table scan, including join queries that do not use indexes. Add indexes where applicable.
|
||||
Rate of reading fixed position average: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
|
||||
|
||||
rule 'rate of reading next table row'
|
||||
Handler_read_rnd_next / Uptime
|
||||
value * 60 * 60 > 1
|
||||
The rate of reading the next table row is high.
|
||||
This indicates many queries are doing full table scans. Add indexes where applicable.
|
||||
This indicates that many queries are doing full table scans. Add indexes where applicable.
|
||||
Rate of reading next table row: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
|
||||
|
||||
# temp tables
|
||||
|
||||
@ -31,6 +31,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
// real-time charting data
|
||||
if (isset($_REQUEST['chart_data'])) {
|
||||
switch($_REQUEST['type']) {
|
||||
// Process and Connections realtime chart
|
||||
case 'proc':
|
||||
$c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
|
||||
$result = PMA_DBI_query('SHOW PROCESSLIST');
|
||||
@ -44,6 +45,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
exit(json_encode($ret));
|
||||
|
||||
// Query realtime chart
|
||||
case 'queries':
|
||||
$queries = PMA_DBI_fetch_result(
|
||||
"SHOW GLOBAL STATUS
|
||||
@ -64,6 +66,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
exit(json_encode($ret));
|
||||
|
||||
// Traffic realtime chart
|
||||
case 'traffic':
|
||||
$traffic = PMA_DBI_fetch_result(
|
||||
"SHOW GLOBAL STATUS
|
||||
@ -78,63 +81,105 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
exit(json_encode($ret));
|
||||
|
||||
// Data for the monitor
|
||||
case 'chartgrid':
|
||||
$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) {
|
||||
foreach ($chartNodes as $node_id => $node) {
|
||||
switch ($node['dataType']) {
|
||||
case 'statusvar':
|
||||
// Some white list filtering
|
||||
if (!preg_match('/[^a-zA-Z_]+/', $node['dataPoint']))
|
||||
$statusVars[] = $node['dataPoint'];
|
||||
break;
|
||||
// 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 'proc':
|
||||
$result = PMA_DBI_query('SHOW PROCESSLIST');
|
||||
$ret[$chart_id][$node_id]['y'] = PMA_DBI_num_rows($result);
|
||||
break;
|
||||
case 'statusvar':
|
||||
if (!preg_match('/[^a-zA-Z_]+/', $pName))
|
||||
$statusVars[] = $pName;
|
||||
break;
|
||||
|
||||
case 'cpu':
|
||||
if (!$sysinfo) {
|
||||
require_once('libraries/sysinfo.lib.php');
|
||||
$sysinfo = getSysInfo();
|
||||
}
|
||||
if (!$cpuload)
|
||||
$cpuload = $sysinfo->loadavg();
|
||||
case 'proc':
|
||||
$result = PMA_DBI_query('SHOW PROCESSLIST');
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = PMA_DBI_num_rows($result);
|
||||
break;
|
||||
|
||||
if (PHP_OS == 'Linux') {
|
||||
$ret[$chart_id][$node_id]['idle'] = $cpuload['idle'];
|
||||
$ret[$chart_id][$node_id]['busy'] = $cpuload['busy'];
|
||||
} else
|
||||
$ret[$chart_id][$node_id]['y'] = $cpuload['loadavg'];
|
||||
case 'cpu':
|
||||
if (!$sysinfo) {
|
||||
require_once('libraries/sysinfo.lib.php');
|
||||
$sysinfo = getSysInfo();
|
||||
}
|
||||
if (!$cpuload)
|
||||
$cpuload = $sysinfo->loadavg();
|
||||
|
||||
break;
|
||||
if (PHP_OS == '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'];
|
||||
|
||||
case 'memory':
|
||||
if (!$sysinfo) {
|
||||
require_once('libraries/sysinfo.lib.php');
|
||||
$sysinfo = getSysInfo();
|
||||
}
|
||||
if (!$memory)
|
||||
$memory = $sysinfo->memory();
|
||||
break;
|
||||
|
||||
$ret[$chart_id][$node_id]['y'] = $memory[$node['dataPoint']];
|
||||
break;
|
||||
case 'memory':
|
||||
if (!$sysinfo) {
|
||||
require_once('libraries/sysinfo.lib.php');
|
||||
$sysinfo = getSysInfo();
|
||||
}
|
||||
if (!$memory)
|
||||
$memory = $sysinfo->memory();
|
||||
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = $memory[$pName];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$vars = PMA_DBI_fetch_result(
|
||||
"SHOW GLOBAL STATUS
|
||||
WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1);
|
||||
// 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 => $node) {
|
||||
if ($node['dataType'] == 'statusvar')
|
||||
$ret[$chart_id][$node_id]['y'] = $vars[$node['dataPoint']];
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,12 +639,9 @@ if (isset($_REQUEST['show']) && isset($_REQUEST['ajax_request'])) {
|
||||
}
|
||||
}
|
||||
|
||||
$server = 1;
|
||||
if (isset($_REQUEST['server']) && intval($_REQUEST['server'])) $server = intval($_REQUEST['server']);
|
||||
|
||||
$server_db_isLocal = strtolower($cfg['Servers'][$server]['host']) == 'localhost'
|
||||
|| $cfg['Servers'][$server]['host'] == '127.0.0.1'
|
||||
|| $cfg['Servers'][$server]['host'] == '::1';
|
||||
$server_db_isLocal = strtolower($cfg['Server']['host']) == 'localhost'
|
||||
|| $cfg['Server']['host'] == '127.0.0.1'
|
||||
|| $cfg['Server']['host'] == '::1';
|
||||
|
||||
PMA_AddJSCode('pma_token = \'' . $_SESSION[' PMA_token '] . "';\n" .
|
||||
'url_query = \'' . str_replace('&', '&', PMA_generate_common_url($db)) . "';\n" .
|
||||
@ -1466,16 +1508,11 @@ function printMonitor()
|
||||
<div id="addChartDialog" title="Add chart" style="display:none;">
|
||||
<div id="tabGridVariables">
|
||||
<p><input type="text" name="chartTitle" value="<?php echo __('Chart Title'); ?>" /></p>
|
||||
<?php if ($server_db_isLocal) { ?>
|
||||
<input type="radio" name="chartType" value="cpu" id="chartCPU">
|
||||
<label for="chartCPU"><?php echo __('CPU Usage'); ?></label><br/>
|
||||
|
||||
<input type="radio" name="chartType" value="preset" id="chartPreset">
|
||||
<label for="chartPreset"><?php echo __('Preset chart'); ?></label>
|
||||
<select name="presetCharts"></select><br/>
|
||||
|
||||
<input type="radio" name="chartType" value="memory" id="chartMemory">
|
||||
<label for="chartMemory"><?php echo __('Memory Usage'); ?></label><br/>
|
||||
|
||||
<input type="radio" name="chartType" value="swap" id="chartSwap">
|
||||
<label for="chartSwap"><?php echo __('Swap Usage'); ?></label><br/>
|
||||
<?php } ?>
|
||||
<input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked">
|
||||
<label for="chartStatusVar"><?php echo __('Status variable(s)'); ?></label><br/>
|
||||
<div id="chartVariableSettings">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user