Welcome to mirror list, hosted at ThFree Co, Russian Federation.

server_status.js « js - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6677d7b0dca813ffa709b1a32a84ed5e2f702163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * @fileoverview    functions used in server status pages
 * @name            Server Status
 *
 * @requires    jQuery
 * @requires    jQueryUI
 * @requires    jQueryCookie
 * @requires    jQueryTablesorter
 * @requires    Highcharts
 * @requires    canvg
 * @requires    js/functions.js
 *
 */

// Add a tablesorter parser to properly handle thousands seperated numbers and SI prefixes
$(function() {
    // 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');
            }
        });
    });
});

$(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();

    /*** Table sort tooltip ***/
    PMA_createqTip($('table.sortable thead th'), PMA_messages['strSortHint']);

    // Tell highcarts not to use UTC dates (global setting)
    Highcharts.setOptions({
        global: {
            useUTC: false
        }
    });

    $.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
            menuResize();

            // Initialize selected tab
            if (!$(ui.tab.hash).data('init-done')) {
                initTab($(ui.tab.hash), null);
            }

            // 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 = [
                        'js/jquery/timepicker.js',
                        'js/jquery/jquery.json-2.2.js',
                        'js/jquery/jquery.sortableTable.js'];
                    scripts.push('js/server_status_monitor.js');
                    loadJavascript(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
    $('div.buttonlinks select').change(function() {
        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 **/

    // 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') {
            var settings = {
                series: [
                    { name: PMA_messages['strChartKBSent'], data: [] },
                    { name: PMA_messages['strChartKBReceived'], data: [] }
                ],
                title: { text: PMA_messages['strChartServerTraffic'] },
                realtime: { url: 'server_status.php?' + url_query,
                           type: 'traffic',
                           callback: function(chartObj, curVal, lastVal, numLoadedPoints) {
                               if (lastVal == null) {
                                   return;
                                }
                                chartObj.series[0].addPoint(
                                    { x: curVal.x, y: (curVal.y_sent - lastVal.y_sent) / 1024 },
                                    false,
                                    numLoadedPoints >= chartObj.options.realtime.numMaxPoints
                                );
                                chartObj.series[1].addPoint(
                                    { x: curVal.x, y: (curVal.y_received - lastVal.y_received) / 1024 },
                                    true,
                                    numLoadedPoints >= chartObj.options.realtime.numMaxPoints
                                );
                            },
                            error: function() { serverResponseError(); }
                         }
            };

            setupLiveChart($tab, this, settings);
            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') {
            var settings = {
                series: [
                    { name: PMA_messages['strChartConnections'], data: [] },
                    { name: PMA_messages['strChartProcesses'], data: [] }
                ],
                title: { text: PMA_messages['strChartConnectionsTitle'] },
                realtime: { url: 'server_status.php?' + url_query,
                           type: 'proc',
                           callback: function(chartObj, curVal, lastVal, numLoadedPoints) {
                                if (lastVal == null) {
                                    return;
                                }
                                chartObj.series[0].addPoint(
                                    { x: curVal.x, y: curVal.y_conn - lastVal.y_conn },
                                    false,
                                    numLoadedPoints >= chartObj.options.realtime.numMaxPoints
                                );
                                chartObj.series[1].addPoint(
                                    { x: curVal.x, y: curVal.y_proc },
                                    true,
                                    numLoadedPoints >= chartObj.options.realtime.numMaxPoints
                                );
                            },
                            error: function() { serverResponseError(); }
                         }
            };

            setupLiveChart($tab, this, settings);
            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');
        var settings = null;

        if (tabStatus[$tab.attr('id')] == 'static') {
            settings = {
                series: [ { name: PMA_messages['strChartIssuedQueries'], data: [] } ],
                title: { text: PMA_messages['strChartIssuedQueriesTitle'] },
                tooltip: { formatter: function() { return this.point.name; } },
                realtime: { url: 'server_status.php?' + url_query,
                          type: 'queries',
                          callback: function(chartObj, curVal, lastVal, numLoadedPoints) {
                                if (lastVal == null) { return; }
                                chartObj.series[0].addPoint({
                                        x: curVal.x,
                                        y: curVal.y - lastVal.y,
                                        name: sortedQueriesPointInfo(curVal, lastVal)
                                    },
                                    true,
                                    numLoadedPoints >= chartObj.options.realtime.numMaxPoints
                                );
                            },
                            error: function() { serverResponseError(); }
                         }
            };
        } else {
            $(this).html(PMA_messages['strLiveQueryChart']);
        }

        setupLiveChart($tab, this, settings);
        tabStatus[$tab.attr('id')] = 'livequeries';
        return false;
    });

    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;
                tabChart[$tab.attr('id')].destroy();
                // 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";

            $tab.find('.tabInnerContent')
                .hide()
                .after('<div class="liveChart" id="' + $tab.attr('id') + '_chart_cnt"></div>');
            tabChart[$tab.attr('id')] = PMA_createChart(settings);
            $(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';
            tabChart[$tab.attr('id')].destroy();
            $tab.find('.buttonlinks a.tabRefresh').show();
            $tab.find('.buttonlinks select').get(0).selectedIndex = 2;
            $tab.find('.buttonlinks .refreshList').hide();
        }
    }

    /* 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);
                }
                PMA_convertFootnotesToTooltips();
                break;
            case 'statustabs_queries':
                if (data != null) {
                    queryPieChart.destroy();
                    tab.find('.tabInnerContent').html(data);
                }

                // Build query statistics chart
                var cdata = new Array();
                $.each(jQuery.parseJSON($('#serverstatusquerieschart span').html()), function(key, value) {
                    cdata.push([key, parseInt(value)]);
                });

                queryPieChart = PMA_createChart({
                    chart: {
                        renderTo: 'serverstatusquerieschart'
                    },
                    title: {
                        text: '',
                        margin: 0
                    },
                    series: [{
                        type: 'pie',
                        name: PMA_messages['strChartQueryPie'],
                        data: cdata
                    }],
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                formatter: function() {
                                    return '<b>' + this.point.name +'</b><br/> ' +
                                            Highcharts.numberFormat(this.percentage, 2) + ' %';
                               }
                            }
                        }
                    },
                    tooltip: {
                        formatter: function() {
                            return '<b>' + this.point.name + '</b><br/>' +
                                    Highcharts.numberFormat(this.y, 2) + '<br/>(' +
                                    Highcharts.numberFormat(this.percentage, 2) + ' %)';
                        }
                    }
                });
                initTableSorter(tab.attr('id'));
                break;

            case 'statustabs_allvars':
                if (data != null) {
                    tab.find('.tabInnerContent').html(data);
                    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);

            $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 });
}