Moodle Plugins directory: Heartbeat check (eg Nagios / Icinga) | Moodle.org

Heartbeat check (eg Nagios / Icinga)
A heartbeat test page for Moodle
Very simple, just performs a quick check of all critical service dependancies (filesystem, DB, caches, and sessions) and return OK
Use from a load balancer to tell whether a node is OK
Just install the plugin normally and then point your load balance to a url like this:
http://moodle.example.com/admin/tool/heartbeat/
It will return a page with either a 200 or 503 response code and if it fails a string for why.
By default it only performs a light check, in particular it does not check the moodle database. To do a full check add this query param:
http://moodle.example.com/admin/tool/heartbeat/?fullcheck
This check can also be run as a CLI:
php index.php fullcheck
A nagios cron health checker
A script croncheck is a nagios compliant checker to see if cron or any individual tasks are failing, with configurable thresholds
This script can be either run from the web:
http://moodle.example.com/admin/tool/heartbeat/croncheck.php
Or can be run as a CLI in which case it will return in the format expected by Nagios:
sudo -u www-data php /var/www/moodle/admin/tool/heartbeat/croncheck.php
The various thresholds can be configured with query params or cli args see this for details:
php croncheck.php -h
This looks a brilliant tool - I have been wanting to have some sort of error tracking on the cron for a while!
Can you tell me how to integrate it into Nagios?
Thanks
John Rickard
I just discovered this simple tool to check the status of any Moodle platform. I was interested enough because in our organization, we manage several platforms Moodle and our Nagios is difficult to check whether the site is ok or not, if the database connected or not connected.
I tested it in a test environment and the truth is quite functional and very useful. What interest me is how to include the two checks (the fullcheck and croncheck) in the Nagios service we have assembled in our company.
Anyway thank you very much.
https://github.com/brendanheywood/moodle-tool_heartbeat#a-heartbeat-test-page-for-moodle
Context : Moodle 3.2/LAMP
This plugin seems to use the 'memcache' PHP module, not the 'memcached' one, to check Memcached session server (if apply). Correct?
Thanks for you great job!
Best regards.
and the 'tool_heartbeat | testing' setting is only applied for the 'croncheck' script, right?
Best regards,
Benoit.
Yes the testing mode is only for the croncheck, and yes the session check is hard coded and quite hacky (we don't actually use that particular feature very much, it's monitored in other ways). It would be much better if it detected which session handler was being used and each session handler declared it's own concept of healthy which is the intention of this tracker which ideally will make this plugin redundant:
https://tracker.moodle.org/browse/MDL-47271
How about caching checks? Redis support needed.
We have been using the 2018 version for some time which works well. When we upgrade our sites to the 2024 version the health check returns an HTTP 303. Any clues as to why this might be? We are a bit stumped at the moment.