Merge commit '5924811'
[phpmyadmin.git] / server_status_monitor.php
blob9af3f71e43a28ac08bd96f39ee8b783a8125238c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Server status monitor feature
6 * @package PhpMyAdmin
7 */
9 require_once 'libraries/common.inc.php';
10 require_once 'libraries/server_common.inc.php';
11 require_once 'libraries/ServerStatusData.class.php';
12 require_once 'libraries/server_status_monitor.lib.php';
14 if (PMA_DRIZZLE) {
15 $GLOBALS['replication_info'] = array();
16 $GLOBALS['replication_info']['master']['status'] = false;
17 $GLOBALS['replication_info']['slave']['status'] = false;
18 } else {
19 include_once 'libraries/replication.inc.php';
20 include_once 'libraries/replication_gui.lib.php';
23 /**
24 * Ajax request
26 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
27 // Send with correct charset
28 header('Content-Type: text/html; charset=UTF-8');
30 // real-time charting data
31 if (isset($_REQUEST['chart_data'])) {
32 switch($_REQUEST['type']) {
33 case 'chartgrid': // Data for the monitor
34 $ret = PMA_getJsonForChartingData();
35 PMA_Response::getInstance()->addJSON('message', $ret);
36 exit;
40 if (isset($_REQUEST['log_data'])) {
42 $start = intval($_REQUEST['time_start']);
43 $end = intval($_REQUEST['time_end']);
45 if ($_REQUEST['type'] == 'slow') {
46 $return = PMA_getJsonForLogDataTypeSlow($start, $end);
47 PMA_Response::getInstance()->addJSON('message', $return);
48 exit;
51 if ($_REQUEST['type'] == 'general') {
52 $return = PMA_getJsonForLogDataTypeGeneral($start, $end);
53 PMA_Response::getInstance()->addJSON('message', $return);
54 exit;
58 if (isset($_REQUEST['logging_vars'])) {
59 $loggingVars = PMA_getJsonForLoggingVars();
60 PMA_Response::getInstance()->addJSON('message', $loggingVars);
61 exit;
64 if (isset($_REQUEST['query_analyzer'])) {
65 $return = PMA_getJsonForQueryAnalyzer();
66 PMA_Response::getInstance()->addJSON('message', $return);
67 exit;
71 /**
72 * JS Includes
74 $header = $response->getHeader();
75 $scripts = $header->getScripts();
76 $scripts->addFile('jquery/jquery.tablesorter.js');
77 $scripts->addFile('jquery/jquery.sortableTable.js');
78 $scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
79 /* < IE 9 doesn't support canvas natively */
80 if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
81 $scripts->addFile('jqplot/excanvas.js');
83 $scripts->addFile('canvg/canvg.js');
84 // for charting
85 $scripts->addFile('jqplot/jquery.jqplot.js');
86 $scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js');
87 $scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js');
88 $scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
89 $scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js');
90 $scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
91 $scripts->addFile('jqplot/plugins/jqplot.cursor.js');
92 $scripts->addFile('jqplot/plugins/jqplot.byteFormatter.js');
94 $scripts->addFile('server_status_monitor.js');
95 $scripts->addFile('server_status_sorter.js');
98 /**
99 * start output
101 $ServerStatusData = new PMA_ServerStatusData();
104 * Output
106 $response->addHTML('<div>');
107 $response->addHTML($ServerStatusData->getMenuHtml());
108 $response->addHTML(PMA_getHtmlForMonitor($ServerStatusData));
109 $response->addHTML(PMA_getHtmlForClientSideDataAndLinks($ServerStatusData));
110 $response->addHTML('</div>');
111 exit;