Skip to content

Commit

Permalink
MDL-35716 report_performance: Performance report for moodle site
Browse files Browse the repository at this point in the history
This will report config setting which can affect moodle performance.
Few of them are added in this patch:
1. Theme designer mode
2. Cache Javascript
3. Debug message set to developer
4. Backup - Active
5. Stats enabled.
  • Loading branch information
Rajesh Taneja committed Mar 11, 2013
1 parent 8673a98 commit 87f9a3b
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 3 deletions.
36 changes: 36 additions & 0 deletions report/performance/db/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Capabilities
*
* @package report_performance
* @copyright 2013 Rajesh Taneja
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$capabilities = array(
'report/performance:view' => array(
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW
),
)
);
89 changes: 89 additions & 0 deletions report/performance/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Performance overview report
*
* @package report_performance
* @copyright 2013 Rajesh Taneja
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('NO_OUTPUT_BUFFERING', true);

require('../../config.php');
require_once($CFG->dirroot.'/report/performance/locallib.php');
require_once($CFG->libdir.'/adminlib.php');

require_login();

// Show detailed info about one issue only.
$issue = optional_param('issue', '', PARAM_ALPHANUMEXT);

$reportperformance = new report_performance();
$issues = $reportperformance->get_issue_list();

// Test if issue valid string.
if (array_search($issue, $issues, true) === false) {
$issue = '';
}

// Print the header.
admin_externalpage_setup('reportperformance', '', null, '', array('pagelayout'=>'report'));
echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('pluginname', 'report_performance'));

$strissue = get_string('issue', 'report_performance');
$strvalue = get_string('value', 'report_performance');
$strcomments = get_string('comments', 'report_performance');
$stredit = get_string('edit');

$table = new html_table();
$table->head = array($strissue, $strvalue, $strcomments, $stredit);
$table->colclasses = array('mdl-left issue', 'mdl-left value', 'mdl-left comments', 'mdl-left config');
$table->attributes = array('class' => 'admintable performancereport generaltable');
$table->id = 'performanceissuereporttable';
$table->data = array();

// Print details of one issue only.
if ($issue and ($issueresult = $reportperformance::$issue())) {
$reportperformance->add_issue_to_table($table, $issueresult, true);

$PAGE->set_docs_path('report/security/' . $issue);

echo html_writer::table($table);

echo $OUTPUT->box($issueresult->details, 'generalbox boxwidthnormal boxaligncenter');

echo $OUTPUT->continue_button(new moodle_url('/report/performance/index.php'));
} else {
// Add Performance report description on main list page.
$morehelplink = $OUTPUT->doc_link('report/performance', get_string('morehelp', 'report_performance'));
echo $OUTPUT->box(get_string('performancereportdesc', 'report_performance', $morehelplink), 'generalbox mdl-align');

foreach ($issues as $issue) {
$issueresult = $reportperformance::$issue();
if (!$issueresult) {
// Ignore this test.
continue;
}
$reportperformance->add_issue_to_table($table, $issueresult, false);
}
echo html_writer::table($table);
}

echo $OUTPUT->footer();
50 changes: 50 additions & 0 deletions report/performance/lang/en/report_performance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Lang strings
*
* @package report_performance
* @copyright 2013 Rajesh Taneja
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['check_backup'] = 'Automated backup';
$string['check_backup_comment_disable'] = 'Performance may be affected during the backup process. If enabled, backups should be scheduled for off-peak times.';
$string['check_backup_comment_enable'] = 'Performance may be affected during the backup process. Backups should be scheduled for off-peak times.';
$string['check_backup_details'] = 'Enabling automated backup will automatically create archives of all the courses on the server at the time you specified.<p>During this process, it will consume more server resources and may affect performance.</p>';
$string['check_cachejs_comment_disable'] = 'If enabled, page loading performance is improved.';
$string['check_cachejs_comment_enable'] = 'If disabled, page might load slow.';
$string['check_cachejs_details'] = 'Javascript caching and compression greatly improves page loading performance. It is strongly recommended for production sites.';
$string['check_debugmsg_comment_nodeveloper'] = 'If set to DEVELOPER, performance may be affected slightly.';
$string['check_debugmsg_comment_developer'] = 'If set other then DEVELOPER, performance may be improved slightly.';
$string['check_debugmsg_details'] = 'There is rarely any advantage in going to Developer level, unless you are a developer, in which case it is strongly recommended.<p>Once you have got the error message, and copied and pasted it somewhere. HIGHLY RECOMMENDED to turn Debug back to NONE. Debug messages can give clues to a hacker as to the setup of your site and may affect performance.</p>';
$string['check_enablestats_comment_disable'] = 'Performance may be affected by statistics processing. If enabled, statistics settings should be set with caution.';
$string['check_enablestats_comment_enable'] = 'Performance may be affected by statistics processing. Statistics settings should be set with caution.';
$string['check_enablestats_details'] = 'Enabling this will process the logs in cronjob and gather some statistics. Depending on the amount of traffic on your site, this can take awhile.<p>During this process, it will consume more server resources and may affect performance.</p>';
$string['check_themedesignermode_comment_enable'] = 'If disabled, images and style sheets are cached, resulting in significant performance improvements.';
$string['check_themedesignermode_comment_disable'] = 'If enabled, images and style sheets will not be cached, resulting in significant performance degradation.';
$string['check_themedesignermode_details'] = 'This is often the cause of slow Moodle sites. <p>On average it might take at least twice the amount of CPU to run a Moodle site with theme designer mode enabled.</p>';
$string['comments'] = 'Comments';
$string['edit'] = 'Edit';
$string['enabled'] = 'Enabled';
$string['disabled'] = 'Disabled';
$string['issue'] = 'Issue';
$string['morehelp'] = 'more help';
$string['performance:view'] = 'View performance report';
$string['performancereportdesc'] = 'This report lists issues which may affect performance of the site {$a}';
$string['pluginname'] = 'Performance overview';
$string['value'] = 'Value';
Loading

0 comments on commit 87f9a3b

Please sign in to comment.