Merge remote-tracking branch 'origin/master'
[phpmyadmin.git] / server_status_monitor.php
blob5c58c94bb885c2be90c4362b4ebeab7c906a98b1
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';
13 if (PMA_DRIZZLE) {
14 $server_master_status = false;
15 $server_slave_status = false;
16 } else {
17 include_once 'libraries/replication.inc.php';
18 include_once 'libraries/replication_gui.lib.php';
21 /**
22 * Ajax request
24 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
25 // Send with correct charset
26 header('Content-Type: text/html; charset=UTF-8');
28 // real-time charting data
29 if (isset($_REQUEST['chart_data'])) {
30 switch($_REQUEST['type']) {
31 case 'chartgrid': // Data for the monitor
32 $ret = PMA_getJsonForChartingData();
33 PMA_Response::getInstance()->addJSON('message', $ret);
34 exit;
38 if (isset($_REQUEST['log_data'])) {
39 if (PMA_MYSQL_INT_VERSION < 50106) {
40 // Table logging is only available since 5.1.6
41 exit('""');
44 $start = intval($_REQUEST['time_start']);
45 $end = intval($_REQUEST['time_end']);
47 if ($_REQUEST['type'] == 'slow') {
48 $return = PMA_getJsonForLogDataTypeSlow($start, $end);
49 PMA_Response::getInstance()->addJSON('message', $return);
50 exit;
53 if ($_REQUEST['type'] == 'general') {
54 $return = PMA_getJsonForLogDataTypeGeneral($start, $end);
55 PMA_Response::getInstance()->addJSON('message', $return);
56 exit;
60 if (isset($_REQUEST['logging_vars'])) {
61 $loggingVars = PMA_getJsonForLoggingVars();
62 PMA_Response::getInstance()->addJSON('message', $loggingVars);
63 exit;
66 if (isset($_REQUEST['query_analyzer'])) {
67 $return = PMA_getJsonForQueryAnalyzer();
68 PMA_Response::getInstance()->addJSON('message', $return);
69 exit;
73 /**
74 * JS Includes
76 $header = $response->getHeader();
77 $scripts = $header->getScripts();
78 $scripts->addFile('jquery/jquery.tablesorter.js');
79 $scripts->addFile('jquery/jquery.json-2.4.js');
80 $scripts->addFile('jquery/jquery.sortableTable.js');
81 $scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
82 /* < IE 9 doesn't support canvas natively */
83 if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
84 $scripts->addFile('jqplot/excanvas.js');
86 $scripts->addFile('canvg/canvg.js');
87 // for charting
88 $scripts->addFile('jqplot/jquery.jqplot.js');
89 $scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js');
90 $scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js');
91 $scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
92 $scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js');
93 $scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
94 $scripts->addFile('jqplot/plugins/jqplot.cursor.js');
95 $scripts->addFile('jqplot/plugins/jqplot.byteFormatter.js');
97 $scripts->addFile('server_status_monitor.js');
98 $scripts->addFile('server_status_sorter.js');
102 * start output
104 $ServerStatusData = new PMA_ServerStatusData();
107 * Output
109 $response->addHTML('<div>');
110 $response->addHTML($ServerStatusData->getMenuHtml());
111 $response->addHTML(PMA_getHtmlForMonitor($ServerStatusData));
112 $response->addHTML(PMA_getHtmlForClientSideDataAndLinks($ServerStatusData));
113 $response->addHTML('</div>');
114 exit;