Given the newness of the Drupal 8 CMS, a D8 site owner may wonder about the performance of their site and if everything is running smoothly.
To address these questions to some extent, Drupal hosting vendors have built-in status checking. This handles the most common issues we see with different versions of Drupal and, specifically, with Drupal 8.
But what if we want our own custom, detailed report that has specific information not contained within the hosting reports? To accomplish this task, we can use an excellent contributed module for Drupal 8, Site Audit (https://www.drupal.org/project/site_audit).
To get this module using Drush, just type:
% drush dl site_audit
Which should respond with:
Project site_audit (8.x-n.m) downloaded to /some_path/.drush/site_audit. [success]
And now we are ready to start running tests. Let's see what tests are available:
% drush | grep audit
Tools for auditing a Drupal site: (site_audit) audit-all (aa) Executes every Site Audit Report audit-best-practices Audit best practices used. audit-cache (ac) Audit Drupal caching settings. audit-codebase (acb) Audit the codebase. audit-content (can) Audit content. audit-cron (acr) Audit cron. audit-database (ad) Report information about a site's database. audit-extensions Audit extensions (modules and themes). audit-front-end Analyze a site's front end performance. audit-security Audit a site for known security vulnerabilities. audit-status (as) Audit Drupal's built-in status report. audit-users (au) Audit Users. audit-views (av) Audit Views. audit-watchdog (aw) Audit the database logs. site-audit-version Show the Site Audit version.
That certainly is a comprehensive-looking list of options. Where to begin? It looks like 'drush audit-all', or 'aa' for short, will check everything. Let's try that with the --detail option to show everything.
In Linux we type:
% drush aa --detail
And we then see a text dump of the information following the command in Linux.
https://drupal.org/project/site_audit report Generated on Mon, 16 May 2016 12:08:12 -0400 % drush aa --detail | head -n 100 https://drupal.org/project/site_audit report Generated on Mon, 16 May 2016 12:18:05 -0400 Best practices: 88% Fast 404 pages: Check if enabled. Fast 404 pages are enabled. sites/sites.php: Check if multisite configuration file is a symbolic link. sites.php does not exist. Multi-site: Detect multi-site configurations. No multi-sites detected. sites/default/settings.php: Check if the configuration file exists. settings.php exists and is not a symbolic link. sites/default/services.yml: Check if the services file exists. services.yml does not exist! Copy the default.service.yml to services.yml and see https://www.drupal.org/documentation/install/settings-file for details. Create services.yml file inside sites/default directory by copying default.services.yml file. See https://www.drupal.org/documentation/install/settings-file for details. sites/default: Check if it exists and isn't symbolic sites/default is a directory and not a symbolic link. Superfluous files in /sites: Detect unnecessary files. No unnecessary files detected. Folder Structure: Checks if modules/contrib and modules/custom directory is present modules/contrib and modules/custom directories exist. Drupal's caching settings: 0% Available Caching backends: Detail all available caching backends. Backend: Class ---------- cache.backend.chainedfast: Drupal\Core\Cache\ChainedFastBackendFactory cache.backend.database: Drupal\Core\Cache\DatabaseBackendFactory cache.backend.apcu: Drupal\Core\Cache\ApcuBackendFactory …
Whoa there! The text report showed all this and much more. In fact, what is produced looks like far too much detail to deal with from the command line. Still, this is certainly looking like useful information. What if we want to see it in a nicely formatted way and also view the full detail of all reports?
For that, we just add a few parameters to site_audit, as shown below.
% drush aa --html --bootstrap --detail > ~/Desktop/report.html
The command above will do a full audit with detail and produce a downloadable report in the more-readable HTML format. We use the popular and clean Bootstrap framework for greater readability.
Let's take a look at what our full report looks like formatted as HTML.
This is more like it! The output is readable and segmented into sections. From this screen-shot of one of many pages, it looks like this site is in development, as caching is turned off (which is OK for a non-production site). However, it also looks like there is some work to do to make the site better, which is exactly what we wanted.
This report is very detailed, and it would be useful to have a skilled Drupal professional look over the report to determine what your site needs. Still, let's look at some of the areas of this report.
From the taxonomy report it looks like we have some useful information:
There is an unused taxonomy, perhaps not the biggest issue, but if we can verify that it is really not being used, we could remove it to make the site cleaner.
Below is another sub-report:
Well, that is looking like good news. Everything looks clean as far as Drupal 8 extensions (modules) are concerned. Great, let's continue!
In yet a different sub-report, shown below, we see there is some database fragmentation, which can affect performance.
The fragmentation information above is a good issue for system administrators to use to optimize the database, if needed.
Let's show another report; this time for Drupal 8 Views:
It looks like we should turn on caching in Views for more performance. (This is especially helpful to look at prior to launching the site.)
In addition, it is also quite useful using the Site Audit to generate simple reports from time to time. For instance:
% drush audit-best-practices --html --bootstrap > ~/Desktop/report2.htm
This command produces the report below:
This is looking pretty good, as we have only one main best-practices issue to address.
And of course, it may be useful to run the following command periodically:
% drush audit-security --html --bootstrap > ~/Desktop/report2.html
That produces the following report in its entirety:
Of course, even with these reports, it's always a good idea to find a Drupal expert or two to look over everything with a fine toothed comb. You want to carefully check every point, as well as look for things that the automated reports do not show. With many years of experience working with the Drupal CMS, professionals become familiar with site issues that even the reports don't catch.
It's great to see tools like the Site Audit module running so well on Drupal 8! Certainly we can expect this is only the tip of the iceberg, and we can expect to see far more great stuff coming out for Drupal 8 in the future!
What Drupal 8 modules have you found work well for you?