Monitor Log analyzer: This change should hopefully reduce insert length and group together inserts into same table
This commit is contained in:
parent
87736c6b6d
commit
ab4bf6d737
@ -951,9 +951,9 @@ $(function() {
|
||||
$('#logAnalyseDialog').html(
|
||||
'<p>Selected time range: ' +
|
||||
Highcharts.dateFormat('%H:%M:%S',new Date(min)) + ' - ' + Highcharts.dateFormat('%H:%M:%S',new Date(max)) + '</p>' +
|
||||
'<p>Results are currently group by query text</p>'+
|
||||
'<p>Choose from which log you want the statistics to be generated from.</p>' /*+
|
||||
'<input type="checkbox" id="groupData" value="1" checked="checked" /> <label for="groupData">Group together identical queries</label>'*/
|
||||
'<input type="checkbox" id="groupInserts" value="1" checked="checked" /> <label for="groupData">Group together INSERTs into same table</label>' +
|
||||
'<p>Choose from which log you want the statistics to be generated from.</p>' +
|
||||
'Results are grouped by query text.'
|
||||
);
|
||||
|
||||
$('#logAnalyseDialog').dialog({
|
||||
@ -961,12 +961,12 @@ $(function() {
|
||||
height: 'auto',
|
||||
buttons: {
|
||||
'From slow log': function() {
|
||||
loadLogStatistics({src: 'slow', start: min, end: max});
|
||||
loadLogStatistics({src: 'slow', start: min, end: max, groupInserts: $('input#groupInserts').attr('checked') });
|
||||
|
||||
$( this ).dialog( "close" );
|
||||
},
|
||||
'From general log': function() {
|
||||
loadLogStatistics({src: 'general', start: min, end: max});
|
||||
loadLogStatistics({src: 'general', start: min, end: max, groupInserts: $('input#groupInserts').attr('checked') });
|
||||
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
@ -1151,37 +1151,34 @@ $(function() {
|
||||
var rows = data.rows;
|
||||
var cols = new Array();
|
||||
|
||||
tableStr = '<table border="0">';
|
||||
|
||||
for(var i=0; i < rows.length; i++) {
|
||||
if(i == 0) {
|
||||
tableStr += '<thead>';
|
||||
$.each(rows[0],function(key, value) {
|
||||
cols.push(key);
|
||||
});
|
||||
tableStr += '<tr><th>' + cols.join('</th><th>') + '</th></tr>';
|
||||
tableStr += '</thead><tbody>';
|
||||
if(rows.length != 0) {
|
||||
tableStr = '<table border="0">';
|
||||
|
||||
for(var i=0; i < rows.length; i++) {
|
||||
if(i == 0) {
|
||||
tableStr += '<thead>';
|
||||
$.each(rows[0],function(key, value) {
|
||||
cols.push(key);
|
||||
});
|
||||
tableStr += '<tr><th>' + cols.join('</th><th>') + '</th></tr>';
|
||||
tableStr += '</thead><tbody>';
|
||||
}
|
||||
|
||||
tableStr += '<tr>';
|
||||
for(var j=0; j < cols.length; j++)
|
||||
tableStr += '<td>' + formatValue(cols[j], rows[i][cols[j]]) + '</td>';
|
||||
tableStr += '</tr>';
|
||||
}
|
||||
|
||||
tableStr += '<tr>';
|
||||
for(var j=0; j < cols.length; j++)
|
||||
tableStr += '<td>' + formatValue(cols[j], rows[i][cols[j]]) + '</td>';
|
||||
tableStr += '</tr>';
|
||||
}
|
||||
|
||||
tableStr+='</tbody></table>';
|
||||
|
||||
if(rows.length == 0)
|
||||
tableStr = '<i>No results found</i>';
|
||||
|
||||
$('#logTable').html(tableStr);
|
||||
|
||||
$('div#logTable table').tablesorter({
|
||||
sortList: [[0,1]],
|
||||
widgets: ['zebra']
|
||||
});
|
||||
|
||||
if(rows.length != 0) {
|
||||
tableStr+='</tbody></table>';
|
||||
|
||||
$('#logTable').html(tableStr);
|
||||
|
||||
$('div#logTable table').tablesorter({
|
||||
sortList: [[0,1]],
|
||||
widgets: ['zebra']
|
||||
});
|
||||
|
||||
$('#loadingLogsDialog').html('<p>Log data loaded. Queries executed in this time span:</p>');
|
||||
$.each(data.sum, function(key, value) {
|
||||
key = key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
|
||||
@ -1195,10 +1192,12 @@ $(function() {
|
||||
} } );
|
||||
|
||||
} else {
|
||||
|
||||
$('#loadingLogsDialog').html('<p>Log analysed, but not data found in this time span.</p>');
|
||||
$('#loadingLogsDialog').dialog( "option", "buttons", { "Close": function() {
|
||||
$(this).dialog("close");
|
||||
} } );
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@ -202,13 +202,30 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
$return = array( 'rows' => array(), 'sum' => array());
|
||||
$type = '';
|
||||
$insertTables = array();
|
||||
$insertTablesFirst = array();
|
||||
$i = 0;
|
||||
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
$type = substr($row['argument'],0,strpos($row['argument'],' '));
|
||||
preg_match('/^(\w+)\s/',$row['argument'],$match);
|
||||
$type = $match[1];
|
||||
$return['sum'][$type]++;
|
||||
if($type=='INSERT' && strlen($row['argument'] > 300))
|
||||
$row['argument'] = substr($row['argument'],0,301) . '...';
|
||||
if($type=='INSERT') {
|
||||
if(isset($_REQUEST['groupInserts']) && $_REQUEST['groupInserts'] && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i',$row['argument'],$matches)) {
|
||||
$insertTables[$matches[2]]++;
|
||||
if ($insertTables[$matches[2]] > 1)
|
||||
$returns['rows'][$insertTablesFirst]['count'] = $insertTables[$matches[2]];
|
||||
else {
|
||||
$insertTablesFirst = $i;
|
||||
$insertTables[$matches[2]] += $returns['rows'][$insertTablesFirst]['count'] - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(strlen($row['argument']) > 300)
|
||||
$row['argument'] = substr($row['argument'],0,301) . '...';
|
||||
}
|
||||
$return['rows'][] = $row;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$return['sum']['TOTAL'] = array_sum($return['sum']);
|
||||
@ -1240,7 +1257,7 @@ function printMonitor() {
|
||||
<div class="popupMenu">
|
||||
<a href="#pauseCharts"><img src="<?php echo $GLOBALS['pmaThemeImage'];?>play.png" alt="Start"/> Start Monitor</a>
|
||||
<a href="#popupLink" style="display:none;"><img src="<?php echo $GLOBALS['pmaThemeImage'];?>s_cog.png" alt="Settings"/> Settings</a>
|
||||
<a href="#monitorInstructionsDialog"><img src="<?php echo $GLOBALS['pmaThemeImage'];?>b_help.png" alt="Instructions"/> Instructions</a>
|
||||
<a href="#monitorInstructionsDialog"><img src="<?php echo $GLOBALS['pmaThemeImage'];?>b_help.png" alt="Instructions"/> Instructions/Setup</a>
|
||||
<ul class="popupContent">
|
||||
<li><a href="#addNewChart"><img src="<?php echo $GLOBALS['pmaThemeImage'];?>b_chart.png" alt="Add chart"/> Add chart</a><br></li>
|
||||
<li>
|
||||
@ -1320,7 +1337,7 @@ function printMonitor() {
|
||||
</div>
|
||||
|
||||
<div id="loadingLogsDialog" title="Loading logs" style="display:none;">
|
||||
</diV>
|
||||
</div>
|
||||
|
||||
<div title="Log statistics" id="logAnalyseDialog">
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user