[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-14614-g7741ad7

Michal Čihař nijel at users.sourceforge.net
Fri Aug 12 12:16:12 CEST 2011


The branch, master has been updated
       via  7741ad728678aec6e97638df5a5252816f3cc845 (commit)
       via  278c55eb8b218689ca7c522f6f8831ca9c424643 (commit)
       via  cac3e6aee5aa3a1c4d57551ccf0c0b1195c1be8b (commit)
       via  772962d1b631bb66bd6ccff5330645cc05f46a4f (commit)
       via  a8f2d96baad8d6c99fbe8f74841bf57d10d6092b (commit)
       via  d94d681e7da478bdd12874010a2e7aec05238931 (commit)
       via  6bfa452f8d04694021d211e0abd2dd5f080669e5 (commit)
       via  1120bb597a1207074736a217a232de312af852df (commit)
       via  ca94b919ac6cae10e0a8b30a5b30508c9b3fa55a (commit)
       via  df0eca21e3da5389816ddd3150c58be9e7515f92 (commit)
       via  bfef230b91d6ab716c6d236b7c86e44c299b2098 (commit)
      from  ab4c24c30eb49f0a5ef1a8f96169091f834824d1 (commit)


- Log -----------------------------------------------------------------
commit 7741ad728678aec6e97638df5a5252816f3cc845
Merge: ab4c24c 278c55e
Author: Michal Čihař <michal at cihar.com>
Date:   Fri Aug 12 12:15:50 2011 +0200

    Merge remote-tracking branch 'tyron/master'

commit 278c55eb8b218689ca7c522f6f8831ca9c424643
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 19:38:25 2011 +0300

    Fix: 2 typos

commit cac3e6aee5aa3a1c4d57551ccf0c0b1195c1be8b
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 19:37:04 2011 +0300

    Fix: Error message not displayed

commit 772962d1b631bb66bd6ccff5330645cc05f46a4f
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:58:22 2011 +0300

    Fix: NaN values in query cache efficiency chart

commit a8f2d96baad8d6c99fbe8f74841bf57d10d6092b
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:50:28 2011 +0300

    removed debug logs

commit d94d681e7da478bdd12874010a2e7aec05238931
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:49:39 2011 +0300

    Typo in Swap chart

commit 6bfa452f8d04694021d211e0abd2dd5f080669e5
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:36:55 2011 +0300

    Fix: No "undefined" in add series and edit chart

commit 1120bb597a1207074736a217a232de312af852df
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:25:13 2011 +0300

    Fix: Don't show 'reset to default' if there is no config in localstorage

commit ca94b919ac6cae10e0a8b30a5b30508c9b3fa55a
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:20:40 2011 +0300

    Fix: don't show incompatible message if theres no localstorage config

commit df0eca21e3da5389816ddd3150c58be9e7515f92
Merge: bfef230 d585bba
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:11:39 2011 +0300

    Merge remote-tracking branch 'origin/master'

commit bfef230b91d6ab716c6d236b7c86e44c299b2098
Author: Tyron Madlener <tyronx at gmail.com>
Date:   Thu Aug 11 17:10:12 2011 +0300

    - New feature: Charting over calculated values through presets. Currently available: query cache efficiency and query cache usage
    - Fix sysinfo charts

-----------------------------------------------------------------------

Summary of changes:
 js/messages.php              |    7 +
 js/server_status.js          |   28 ++--
 js/server_status_monitor.js  |  331 ++++++++++++++++++++++++++++--------------
 libraries/advisory_rules.txt |    4 +-
 server_status.php            |  157 ++++++++++++--------
 5 files changed, 346 insertions(+), 181 deletions(-)

diff --git a/js/messages.php b/js/messages.php
index 62950be..e032af7 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -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');
diff --git a/js/server_status.js b/js/server_status.js
index c798bd3..870f9b1 100644
--- a/js/server_status.js
+++ b/js/server_status.js
@@ -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 });
-    }
-});
\ No newline at end of file
+
+// 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 });
+}
diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js
index cb01ca7..f8a179d 100644
--- a/js/server_status_monitor.js
+++ b/js/server_status_monitor.js
@@ -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: '%'}]
-        },
-        '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'] }
-            ]
+        // 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'
+            } ]
         },
-        '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'
+        // 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-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'
+            },
+            '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();
diff --git a/libraries/advisory_rules.txt b/libraries/advisory_rules.txt
index edbdb7b..90c0254 100644
--- a/libraries/advisory_rules.txt
+++ b/libraries/advisory_rules.txt
@@ -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
diff --git a/server_status.php b/server_status.php
index 7517362..cdbe9bb 100644
--- a/server_status.php
+++ b/server_status.php
@@ -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;
-
-                            case 'proc':
-                                $result = PMA_DBI_query('SHOW PROCESSLIST');
-                                $ret[$chart_id][$node_id]['y'] = PMA_DBI_num_rows($result);
-                                break;
-
-                            case 'cpu':
-                                if (!$sysinfo) {
-                                    require_once('libraries/sysinfo.lib.php');
-                                    $sysinfo = getSysInfo();
-                                }
-                                if (!$cpuload)
-                                    $cpuload = $sysinfo->loadavg();
-
-                                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'];
-
-                                break;
-
-                            case 'memory':
-                                if (!$sysinfo) {
-                                    require_once('libraries/sysinfo.lib.php');
-                                    $sysinfo = getSysInfo();
-                                }
-                                if (!$memory)
-                                    $memory  = $sysinfo->memory();
-
-                                $ret[$chart_id][$node_id]['y'] = $memory[$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 '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) {
+                                        require_once('libraries/sysinfo.lib.php');
+                                        $sysinfo = getSysInfo();
+                                    }
+                                    if (!$cpuload)
+                                        $cpuload = $sysinfo->loadavg();
+
+                                    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'];
+
+                                    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="memory" id="chartMemory">
-            <label for="chartMemory"><?php echo __('Memory 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="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">


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list