Heartbeat check (eg Nagios / Icinga)

Administration tool ::: tool_heartbeat
Maintained by Catalyst IT, Brendan Heywood
A load balancer heartbeat / health checker url, and also a configurable nagios compliant cron health checker. This should work out of the box with most load balancers, eg Amazon ELB, F5, HA proxy etc as most of these simply check the http status for 200 or non-200 response codes.
Latest release:
764 sites
244 downloads
14 fans
Current versions available: 2

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

Screenshots

Screenshot #0

Contributors

Catalyst IT (Lead maintainer)
Daniel Thee Roperto: Developer
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • David Mudrák
    Tue, 3 Mar 2015, 3:58 AM
    Thanks Brendan for sharing this plugin. It is apparently focused on sites with quite specific setup. I found it working as expected. The only suggestion I have was reported to your issues tracker. With the hope that will be fixed soon (I can imagine info in the README and in the plugin description here), I am going to approve this now. You are cleared to land, welcome to the Plugins directory!
  • Brendan Heywood
    Tue, 3 Mar 2015, 8:51 AM
    hi David, re #1 that is now automated in code with no config needed, I'll add a new version here. Thanks smile
  • John Rickard
    Wed, 1 Apr 2015, 4:55 PM
    Hi There

    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
  • Eduardo Hm
    Mon, 9 May 2016, 8:07 PM
    Good morning Brendan

    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.
  • Brendan Heywood
    Tue, 10 May 2016, 8:16 AM
    If you are not familiar with configuring nagios using the cli plugins, it might be easier to configure nagios to test whether any arbitrary url is working and then point it at the heartbeat url which returns a 200 or a 503

    https://github.com/brendanheywood/moodle-tool_heartbeat#a-heartbeat-test-page-for-moodle
  • Benoît Lathière
    Wed, 15 Nov 2017, 10:44 PM
    Hello,
    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.
  • Benoît Lathière
    Wed, 15 Nov 2017, 10:58 PM
    ...
    and the 'tool_heartbeat | testing' setting is only applied for the 'croncheck' script, right?

    Best regards,
    Benoit.
  • Brendan Heywood
    Thu, 16 Nov 2017, 10:47 AM
    hi Benoît,

    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
  • Klaus Kuusela
    Mon, 2 Sep 2019, 7:14 PM
    It would be nice to have official support for MDL 3.5 (and up) smile
    How about caching checks? Redis support needed.
Please login to post comments