server_status_monitor.php 2.9 KB

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