2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Server status monitor feature
8 declare(strict_types
=1);
10 use PhpMyAdmin\Controllers\Server\Status\MonitorController
;
11 use PhpMyAdmin\DatabaseInterface
;
12 use PhpMyAdmin\Response
;
14 if (! defined('ROOT_PATH')) {
15 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
18 require_once ROOT_PATH
. 'libraries/common.inc.php';
19 require_once ROOT_PATH
. 'libraries/server_common.inc.php';
20 require_once ROOT_PATH
. 'libraries/replication.inc.php';
22 /** @var Response $response */
23 $response = $containerBuilder->get(Response
::class);
25 /** @var DatabaseInterface $dbi */
26 $dbi = $containerBuilder->get(DatabaseInterface
::class);
28 /** @var MonitorController $controller */
29 $controller = $containerBuilder->get(MonitorController
::class);
34 if ($response->isAjax()) {
35 // Send with correct charset
36 header('Content-Type: text/html; charset=UTF-8');
39 // real-time charting data
40 if ($response->isAjax() && isset($_POST['chart_data']) && $_POST['type'] === 'chartgrid') {
41 $response->addJSON($controller->chartingData([
42 'requiredData' => $_POST['requiredData'] ??
null,
44 } elseif ($response->isAjax() && isset($_POST['log_data']) && $_POST['type'] === 'slow') {
45 $response->addJSON($controller->logDataTypeSlow([
46 'time_start' => $_POST['time_start'] ??
null,
47 'time_end' => $_POST['time_end'] ??
null,
49 } elseif ($response->isAjax() && isset($_POST['log_data']) && $_POST['type'] === 'general') {
50 $response->addJSON($controller->logDataTypeGeneral([
51 'time_start' => $_POST['time_start'] ??
null,
52 'time_end' => $_POST['time_end'] ??
null,
53 'limitTypes' => $_POST['limitTypes'] ??
null,
54 'removeVariables' => $_POST['removeVariables'] ??
null,
56 } elseif ($response->isAjax() && isset($_POST['logging_vars'])) {
57 $response->addJSON($controller->loggingVars([
58 'varName' => $_POST['varName'] ??
null,
59 'varValue' => $_POST['varValue'] ??
null,
61 } elseif ($response->isAjax() && isset($_POST['query_analyzer'])) {
62 $response->addJSON($controller->queryAnalyzer([
63 'database' => $_POST['database'] ??
null,
64 'query' => $_POST['query'] ??
null,
67 $header = $response->getHeader();
68 $scripts = $header->getScripts();
69 $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
70 $scripts->addFile('vendor/jquery/jquery.sortableTable.js');
72 $scripts->addFile('vendor/jqplot/jquery.jqplot.js');
73 $scripts->addFile('vendor/jqplot/plugins/jqplot.pieRenderer.js');
74 $scripts->addFile('vendor/jqplot/plugins/jqplot.enhancedPieLegendRenderer.js');
75 $scripts->addFile('vendor/jqplot/plugins/jqplot.canvasTextRenderer.js');
76 $scripts->addFile('vendor/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
77 $scripts->addFile('vendor/jqplot/plugins/jqplot.dateAxisRenderer.js');
78 $scripts->addFile('vendor/jqplot/plugins/jqplot.highlighter.js');
79 $scripts->addFile('vendor/jqplot/plugins/jqplot.cursor.js');
80 $scripts->addFile('jqplot/plugins/jqplot.byteFormatter.js');
82 $scripts->addFile('server/status/monitor.js');
83 $scripts->addFile('server/status/sorter.js');
85 $response->addHTML($controller->index());