Translated using Weblate (Chinese (Simplified))
[phpmyadmin.git] / server_status_monitor.php
blobed547d5d5bffb510fb2079d719bcc4afe45cfde6
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Server status monitor feature
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Server\Status\Monitor;
10 use PhpMyAdmin\Server\Status\Data;
11 use PhpMyAdmin\Response;
13 require_once 'libraries/common.inc.php';
14 require_once 'libraries/server_common.inc.php';
15 require_once 'libraries/replication.inc.php';
17 $response = Response::getInstance();
19 /**
20 * Ajax request
22 if ($response->isAjax()) {
23 // Send with correct charset
24 header('Content-Type: text/html; charset=UTF-8');
26 // real-time charting data
27 if (isset($_POST['chart_data'])) {
28 switch($_POST['type']) {
29 case 'chartgrid': // Data for the monitor
30 $ret = Monitor::getJsonForChartingData();
31 $response->addJSON('message', $ret);
32 exit;
36 if (isset($_POST['log_data'])) {
38 $start = intval($_POST['time_start']);
39 $end = intval($_POST['time_end']);
41 if ($_POST['type'] == 'slow') {
42 $return = Monitor::getJsonForLogDataTypeSlow($start, $end);
43 $response->addJSON('message', $return);
44 exit;
47 if ($_POST['type'] == 'general') {
48 $return = Monitor::getJsonForLogDataTypeGeneral($start, $end);
49 $response->addJSON('message', $return);
50 exit;
54 if (isset($_POST['logging_vars'])) {
55 $loggingVars = Monitor::getJsonForLoggingVars();
56 $response->addJSON('message', $loggingVars);
57 exit;
60 if (isset($_POST['query_analyzer'])) {
61 $return = Monitor::getJsonForQueryAnalyzer();
62 $response->addJSON('message', $return);
63 exit;
67 /**
68 * JS Includes
70 $header = $response->getHeader();
71 $scripts = $header->getScripts();
72 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
73 $scripts->addFile('vendor/jquery/jquery.sortableTable.js');
74 // for charting
75 $scripts->addFile('vendor/jqplot/jquery.jqplot.js');
76 $scripts->addFile('vendor/jqplot/plugins/jqplot.pieRenderer.js');
77 $scripts->addFile('vendor/jqplot/plugins/jqplot.enhancedPieLegendRenderer.js');
78 $scripts->addFile('vendor/jqplot/plugins/jqplot.canvasTextRenderer.js');
79 $scripts->addFile('vendor/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
80 $scripts->addFile('vendor/jqplot/plugins/jqplot.dateAxisRenderer.js');
81 $scripts->addFile('vendor/jqplot/plugins/jqplot.highlighter.js');
82 $scripts->addFile('vendor/jqplot/plugins/jqplot.cursor.js');
83 $scripts->addFile('jqplot/plugins/jqplot.byteFormatter.js');
85 $scripts->addFile('server_status_monitor.js');
86 $scripts->addFile('server_status_sorter.js');
89 /**
90 * start output
92 $serverStatusData = new Data();
94 /**
95 * Output
97 $response->addHTML('<div>');
98 $response->addHTML($serverStatusData->getMenuHtml());
99 $response->addHTML(Monitor::getHtmlForMonitor($serverStatusData));
100 $response->addHTML(Monitor::getHtmlForClientSideDataAndLinks($serverStatusData));
101 $response->addHTML('</div>');
102 exit;