Admin tools: Cron lock statistics

tool_lockstats
Maintained by Picture of Catalyst ITCatalyst IT, Picture of Brendan HeywoodBrendan Heywood, Picture of Nicholas HoobinNicholas Hoobin
A lock statistics admin tool, specifically tailored to report on cron task timings. This tool exposes which tasks are currently running and where, and also shows a detailed history of how long each task has taken in the past.

Cron lock statistics 2017071200

Release notes

Travis integration: Build Status

tool_lockstats

A lock statistics admin tool, specifically tailored to report on cron task timings.

This tool exposes which tasks are currently running and where, and also shows a detailed history of how long each task has taken in the past.

How it works

It implements a proxy lock factory which adds instrumentation around the real lock factory. It will log details about each cron task when a lock is obtained and released. This is the data that is obtained:

  • Task name
  • Duration
  • Hostname
  • Time gained
  • Time released
  • PID

Most of the time, most cron tasks are quick and finish in seconds. These typically are not the tasks you are interesting in the history off. So this plugin compresses the history quick tasks so you still get overall stats for all tasks, and detailed stats for slower bigger tasks, and without bloating out the database with too much data. Old stats can be removed after a set time period too.

Installation

Install the plugin the same as any standard moodle plugin either via the Moodle plugin directory, or you can use git to clone it into your source:

git clone git@github.com:catalyst/moodle-tool_lockstats.git admin/tool/lockstats

Configuration

This is an example of using the Postgres lock factory, add this to your config.php:

$CFG->lock_factory = "\\tool_lockstats\\proxy_lock_factory";
$CFG->proxied_lock_factory = "\\core\\lock\\postgres_lock_factory";

// To allow unit tests to pass.
$CFG->phpunit_lock_factory = "\\tool_lockstats\\proxy_lock_factory";
$CFG->phpunit_proxied_lock_factory = "\\core\\lock\\postgres_lock_factory";

Using the UI you can configure additional settings at,

Site administration > Plugins > Admin tools > Lock statistics

The values you can configure are,

  • Blacklist (Default: core_cron)

This allows you to prevent logging the history for specific tasks.

  • History threshold (Default: 60)

If the task exceeds this value in seconds then a new history entry will be logged.

  • Cleanup history (Default: 30)

A task exists that will clean up history entries that exceed this value in days.

  • Debug (Default: No)

Provides additional debugging messages in the cron.log for when the locks are obtained and released.

Usage

You can view the current locked tasks, lock history and details via the UI at,

Site administration > Server > Lock statistics

Moodle 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3

Version information

Version build number
2017071200
Version release name
2017071200
Maturity
Stable version
MD5 Sum
d4c2bab23284532099ab234e1d9b4834
Supported software
Moodle 2.7, Moodle 2.8, Moodle 2.9, Moodle 3.0, Moodle 3.1, Moodle 3.2, Moodle 3.3
  • This is the latest release for Moodle 2.7
  • This is the latest release for Moodle 2.8
  • This is the latest release for Moodle 2.9
  • This is the latest release for Moodle 3.0
  • This is the latest release for Moodle 3.1
  • This is the latest release for Moodle 3.2
  • This is the latest release for Moodle 3.3

Version control information

Version control system (VCS)
GIT
VCS repository URL
VCS tag
2017071200

Default installation instructions for plugins of the type Admin tools

  1. Make sure you have all the required versions.
  2. Download and unpack the module.
  3. Place the folder (eg "mytool") in the "admin/tool" subdirectory.
  4. Visit http://yoursite.com/admin to finish the installation