Production monitor & Production check screenshot
Drush colour coded output
Performance monitoring in prod_mon

#2059569: Move 7.x features into 8.x+ and clean up is in progress and 8.x-1.0-alpha7 has been released. Please test thoroughly and submit any issues you encounter.

Performance monitoring note: kbahey was kind enough to grant me permissions to bring life back into the Performance project after it was removed from Devel this summer 2011.
This module now integrates with Production check and Production monitor to provide the Drupal community with a full monitoring suite! Nagios integration is already present and will be expanded / optimised where needed.

Introduction

When bringing a site live, you should double check a lot of settings, like the error logging, site e-mail, disabling the Devel module and so on.
Next to that, you should ensure that all SEO modules are installed and properly configured (like Google Analytics, Page Title, XML Sitemap etc.). The Production check module will do all of this checking for you and present the results in a convenient status page accessible through /admin/reports/prod-check. Through this status page, you can easily navigate to all the settings pages or the project pages of the missing modules to rectify all you need to.

It would of course also be nice that these settings remain as you set them up. In some cases, when multiple developers make updates to a live site or with the odd client having somehow gotten superadmin access, stuff can get changed, usually unintended. That's where the Production monitor comes in the picture. You can open up the Production check's XMLRPC interface through its settings page and have the Production monitor module connect to it from a 'local' monitoring site in your development environment. This will allow you to monitor all your sites from a central server and keep an eye on them. When adding a site using Production monitor, you can indicate what exactly needs to be monitored for this site. Updates can be requested manually and are fetched automatically each cron run.

But I like Nagios to monitor my sites!

If you prefer Nagios monitoring, you can open up Production check's Nagios integration from its settings page. You can specify what exactly you want to monitor there. You will obviousely need to install the Nagios module to make this functionality work.

Remote module update status monitoring

Since Production check recommends to turn of the Update module, we have integrated its functionality in both Production check and Production monitor.

Production check can be configured to allow to transfer its module list with versioning information once a week at a given time.

Production monitor can be configured to download this data along with all the rest. It will then, upon your request (still need to add this on cron, but it's a heavy operation, thinking about the best way to do this: the boost crawler code makes a good candidate), check for module updates locally for the remote site. Production check and Production monitor have the necessary code embedded so you will never need to activate the Update module, not even on the monitor site!

Performance monitoring

If you install the performance module on a production site, you can use Production monitor to remotely monitor the collected performance data. A new subtab will be available displaying the module data in some nice Google charts. Be sure to activate the fetching of performance data in the site's config!

You can ofcourse use hook_prod_check_alter() to pass your own performance data to Production monitor. Here is an example from the performance module:

<?php
/**
 * Implementation of hook_prod_check_alter().
 */
function performance_prod_check_alter(&$checks) {
  $checks['perf_data']['functions']['performance_prod_check_return_data'] = 'Performance logging';
}

/**
 * Return performance data to Production Monitor.
 */
function performance_prod_check_return_data() {
  $data = performance_gather_summary_data();

  if (!$data) {
    return array(
      // 'performance' should be replaced by the name of your module!
      'performance' => array (
        'title' => 'Performance logging',
        'data' => 'No performance data found.',
       ),
    );
  }

  return array(
    // 'performance' should be replaced by the name of your module!
    'performance' => array (
      'title' => 'Performance logging',
      'data' => array(
        'Total number of page accesses' => array($data['total_accesses']),
        'Average duration per page' => array($data['ms_avg'], 'ms'),
        'Average memory per page' => array($data['mb_avg'], 'MB'),
        'Average querycount' => array($data['query_count']),
        'Average duration per query' => array($data['ms_query'], 'ms'),
      ),
    ),
  );
}
?>

Independent modules

Production check and Production monitor are independent of one another. You can easily run different versions of Production check across various sites while keeping Production monitor up to date.

The reason for this is that Production monitor will get the possible checks / settings from Production check and only allows you to configure those.

You can also use Production monitor on a D6 site to monitor D7 sites and vice versa.

Drush

Drush support has been added. For Production check use:

$ drush prod-check

or the alias

$ drush pchk

to see the colour coded status page. The information displayed is a tad more limited than the Drupal version.

You can easily make your site 'production ready' by using the following command:

 $ drush prod-check-prodmode

or its alias:

$ drush pchk-pmode

This will fix most of the problems reported in the status page. You can have
some extra control on the process by adding the --config option:

$ drush pchk-pmode --config

This will ask for some input before setting up the site.

For Production monitor, these commands are available:

$ drush prod-monitor [id]
$ drush prod-monitor-fetch [id]
$ drush prod-monitor-flush [id]
$ drush prod-monitor-delete [id]
$ drush prod-monitor-updates [id] (--check, --security-only)

The id parameter is optional for the prod-monitor command. Correct usage is to first do:

$ drush prod-monitor

in order to lookup the id of a site, then use the other commands to act on that specific site by passing it the id. You can pass multiple ID's by separating them with spaces.
Aliases are there as well:

$ drush pmon [id]
$ drush pmon-fe [id]
$ drush pmon-fl [id]
$ drush pmon-rm [id]
$ drush pmon-up [id] (--check, --security-only)

Development: hook_prod_check_alter()

You can implement hook_prod_check_alter() in your own module to add additional checks or modify the core checks.
The hook receives the default functions divided into 7 categories:

  • settings
  • server
  • performance
  • security
  • modules
  • seo
  • prod_mon
  • perf_data

'prod_mon' is a special category that will only be used by the accompanying Production monitor module.

Your function that implements the actual check must accept 1 string parameter and return an array using the prod_check_execute_check() function.

An example implementation (note the pass by reference in the hook!):

<?php
/**
 * Implements hook_prod_check_alter()
 * @param array reference to an associative array of all available checks
 */
function my_module_prod_check_alter(&$checks) {
  // Add custom check to the server category:
  //  function_name => title
  // Do not use t() for the title!
  $checks['server']['functions']['my_module_additional_check'] = 'Additional check title';

  // Add custom check for Production Monitor only
  $checks['prod_mon']['functions']['my_module_prod_mon_check'] = 'My Production Monitor only check';

  // Add entirely new category.
  $checks['my_category'] = array(
    'title' => 'Custom category',
    'description' => 'Collection of checks I find important.',
    'functions' => array(
      'my_module_check_stuff' => 'Check stuff',
      'my_module_check_more_stuff' => 'Check more stuff',
    ),
  );
}

/**
 * Custom function to check some things.
 * @param string the caller of the function, defaults to 'internal' but can also
 *        be 'xmlrpc' or 'nagios'
 * @return array you _must_ return prod_check_execute_check($check, $caller) as
 *         per the example below to insure a proper status array is returned.
 */
function my_module_additional_check($caller = 'internal') {
  $check = array();

  $title = 'My modules settings';
  $setting1 = t('Enable debug info');
  $setting2 = t('Disable debug info');
  $path = 'admin/settings/my-module-settings-page';
  if ($caller != 'internal') {
    $path = PRODCHECK_BASEURL . $path;
  }

  $check['my_module_additional_check'] = array(
    '#title' => t($title),
    '#state' => variable_get('my_module_debug', 1) != 1,
    '#severity' => ($caller == 'nagios') ? NAGIOS_STATUS_CRITICAL : REQUIREMENT_ERROR,
    '#value_ok'  => $setting2,
    '#value_nok'  => $setting1,
    '#description_ok'  => prod_check_ok_title($title, $path),
    '#description_nok' => t('Your !link settings are set to %setting1, they should be set to %setting2 on a producion environment!',
      array(
        '!link' => '<em>'.l(t($title), $path, array('attributes' => array('title' => t($title)))).'</em>',
        '%setting1' => $setting1,
        '%setting2' => $setting2,
      )
    ),
    '#nagios_key' => 'MYCHCK',
    '#nagios_type' => 'state',
  );

  return prod_check_execute_check($check, $caller);
}

function my_module_check_stuff($caller = 'internal') {
  [...]

  return prod_check_execute_check($check, $caller);
}

function my_module_check_more_stuff($caller = 'internal') {
  [...]

  return prod_check_execute_check($check, $caller);
}

/**
 * Custom callback for a prod_mon only check. Note the additional parameter in
 * the prod_check_execute_check() call!
 */
function my_module_prod_mon_check($caller = 'internal') {
  [...]

  return prod_check_execute_check($check, $caller, 'prod_mon');
}
?>

Module sponsored by Nascom

Project information

Releases