diff --git a/js/server_status.js b/js/server_status.js index c32b5096aa..16b10c5193 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -951,9 +951,9 @@ $(function() { $('#logAnalyseDialog').html( '
Selected time range: ' + Highcharts.dateFormat('%H:%M:%S',new Date(min)) + ' - ' + Highcharts.dateFormat('%H:%M:%S',new Date(max)) + '
' + - 'Results are currently group by query text
'+ - 'Choose from which log you want the statistics to be generated from.
' /*+ - ' '*/ + ' ' + + 'Choose from which log you want the statistics to be generated from.
' + + '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 = '| ' + cols.join(' | ') + ' |
|---|
| ' + cols.join(' | ') + ' |
|---|---|
| ' + formatValue(cols[j], rows[i][cols[j]]) + ' | '; + tableStr += '|
| ' + formatValue(cols[j], rows[i][cols[j]]) + ' | '; - tableStr += '
Log data loaded. Queries executed in this time span:
'); $.each(data.sum, function(key, value) { key = key.charAt(0).toUpperCase() + key.slice(1).toLowerCase(); @@ -1195,10 +1192,12 @@ $(function() { } } ); } else { + $('#loadingLogsDialog').html('Log analysed, but not data found in this time span.
'); $('#loadingLogsDialog').dialog( "option", "buttons", { "Close": function() { $(this).dialog("close"); } } ); + } } ); diff --git a/server_status.php b/server_status.php index 1e6e45968b..7801fedad2 100644 --- a/server_status.php +++ b/server_status.php @@ -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() {
Start Monitor
-
Instructions
+
Instructions/Setup
Add chart