{"id":19592079,"url":"https://github.com/catalyst/moodle-tool_lockstats","last_synced_at":"2025-06-20T23:08:05.988Z","repository":{"id":19094263,"uuid":"85017782","full_name":"catalyst/moodle-tool_lockstats","owner":"catalyst","description":"Moodle cron / task API lock statistics admin tool","archived":false,"fork":false,"pushed_at":"2025-04-16T01:23:14.000Z","size":192,"stargazers_count":6,"open_issues_count":22,"forks_count":13,"subscribers_count":26,"default_branch":"MOODLE_310_STABLE","last_synced_at":"2025-06-20T23:07:21.079Z","etag":null,"topics":["locks","moodle","moodle-plugin","report"],"latest_commit_sha":null,"homepage":"https://moodle.org/plugins/tool_lockstats","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catalyst.png","metadata":{"files":{"readme":"README.md","changelog":"historyreset.php","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-03-15T02:07:09.000Z","updated_at":"2025-04-16T01:23:17.000Z","dependencies_parsed_at":"2025-04-27T14:43:50.969Z","dependency_job_id":null,"html_url":"https://github.com/catalyst/moodle-tool_lockstats","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/catalyst/moodle-tool_lockstats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-tool_lockstats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-tool_lockstats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-tool_lockstats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-tool_lockstats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catalyst","download_url":"https://codeload.github.com/catalyst/moodle-tool_lockstats/tar.gz/refs/heads/MOODLE_310_STABLE","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-tool_lockstats/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261032097,"owners_count":23100050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["locks","moodle","moodle-plugin","report"],"created_at":"2024-11-11T08:33:01.933Z","updated_at":"2025-06-20T23:08:00.976Z","avatar_url":"https://github.com/catalyst.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Travis integration: [![Build Status](https://travis-ci.org/catalyst/moodle-tool_lockstats.svg?branch=master)](https://travis-ci.org/catalyst/moodle-tool_lockstats)\n\n# tool_lockstats\n\nA lock statistics admin tool, specifically tailored to report on cron task timings.\n\nThis tool exposes which tasks are currently running and where, and also shows a detailed\nhistory of how long each task has taken in the past.\n\n# Warning\n\nSince Moodle 3.10 there is now an internal record of which tasks are running and their host\nand pid and very similar metadata to what this plugin records. The reporting in core is not\nquite the same but for simple visbiity of what tasks are currently running this plugin is\nmostly redudant. See also:\n\nhttps://tracker.moodle.org/browse/MDL-67211\n\nAs the reports in core are improved more this plugin will be fully redundant, so it is best\nto consider this plugin deprecated but with no clear timeline on when support will end.\n\n# Branches\n\n| Moodle verion      | Branch            |\n| ------------------ | ----------------- |\n| Moodle 2.7 to 3.8  | master            |\n| Moodle 3.9         | MOODLE_39_STABLE  |\n| Moodle 3.10 - 3.11 | MOODLE_310_STABLE |\n| Totara 9 - 12      | master            |\n| Totara 13          | MOODLE_310_STABLE |\n\n# How it works\n\nIt implements a proxy lock factory which adds instrumentation around the real lock factory.\nIt will log details about each cron task when a lock is obtained and released.\nThis is the data that is obtained:\n\n- Task name\n- Duration\n- Hostname\n- Time gained\n- Time released\n- PID\n\nMost of the time, most cron tasks are quick and finish in seconds. These typically are not the\ntasks you are interesting in the history off. So this plugin compresses the history quick tasks\nso you still get overall stats for all tasks, and detailed stats for slower bigger tasks, and\nwithout bloating out the database with too much data. Old stats can be removed after a set\ntime period too.\n\n# Installation\n\nInstall the plugin the same as any standard moodle plugin either via the Moodle plugin directory:\n\nhttps://moodle.org/plugins/tool_lockstats\n\nhttps://docs.moodle.org/en/Installing_plugins\n\nOR you can use git to clone it into your source:\n\n```bash\ngit clone git@github.com:catalyst/moodle-tool_lockstats.git admin/tool/lockstats\n```\n\n# Configuration\n\nThis is an example of using the Postgres lock factory, add this to your config.php:\n\n```php\n$CFG-\u003elock_factory = \"\\\\tool_lockstats\\\\proxy_lock_factory\";\n$CFG-\u003eproxied_lock_factory = \"auto\";\n\n# If you want to be explicit you can do this:\n$CFG-\u003eproxied_lock_factory = \"\\\\core\\\\lock\\\\postgres_lock_factory\";\n\n// To allow unit tests to pass.\n$CFG-\u003ephpunit_lock_factory = \"\\\\tool_lockstats\\\\proxy_lock_factory\";\n$CFG-\u003ephpunit_proxied_lock_factory = \"\\\\core\\\\lock\\\\postgres_lock_factory\";\n```\n\nUsing the UI you can configure additional settings at,\n\n`Site administration \u003e Plugins \u003e Admin tools \u003e Lock statistics`\n\nThe values you can configure are,\n\n- Blacklist (Default: core_cron)\n\nThis allows you to prevent logging the history for specific tasks.\n\n- History threshold (Default: 60)\n\nIf the task exceeds this value in seconds then a new history entry will be logged.\n\n- Cleanup history (Default: 30)\n\nA task exists that will clean up history entries that exceed this value in days.\n\n- Debug (Default: No)\n\nProvides additional debugging messages in the cron.log for when the locks are obtained and released.\n\n# Usage\n\nYou can view the current locked tasks, lock history and details via the UI at,\n\n`Site administration \u003e Server \u003e Lock statistics`\n\nThe list of current locks is also exposed via a cli script:\n\n```sh\n$ php admin/tool/lockstats/cli/list_locks.php \n    PID HOST       TYPE    TIME     KEY                  NAME                                    \n  10806 zebrafish  adhoc   00:00:06 adhoc_65943          \\tool_testtasks\\task\\timed_adhoc_task   \n  10810 zebrafish  adhoc   00:00:05 adhoc_65945          \\tool_testtasks\\task\\timed_adhoc_task   \n  10808 zebrafish  adhoc   00:00:05 adhoc_65944          \\tool_testtasks\\task\\timed_adhoc_task   \n\nFound 3 lock(s)\n```\n\nAnd you can watch this for a dynamic list of processes:\n\n```sh\nwatch -n 1 php admin/tool/lockstats/cli/list_locks.php\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalyst%2Fmoodle-tool_lockstats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatalyst%2Fmoodle-tool_lockstats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalyst%2Fmoodle-tool_lockstats/lists"}