Admin tools: Heartbeat check (eg Nagios / Icinga)

tool_heartbeat
Maintained by Picture of Catalyst ITCatalyst IT, Picture of Brendan HeywoodBrendan Heywood, Picture of Daniel Thee RopertoDaniel Thee Roperto
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.
206 sites
31 downloads
7 fans
Moodle 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4

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

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

Comments RSS

Show comments
  • Picture of David Mudrák
    Tue, Mar 3, 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!
  • Picture of Brendan Heywood
    Tue, Mar 3, 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
  • Picture of John Rickard
    Wed, Apr 1, 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
  • Picture of Eduardo Hm
    Mon, May 9, 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.
  • Picture of Brendan Heywood
    Tue, May 10, 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
  • Picture of Benoît Lathière
    Wed, Nov 15, 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.
  • Picture of Benoît Lathière
    Wed, Nov 15, 2017, 10:58 PM
    ...
    and the 'tool_heartbeat | testing' setting is only applied for the 'croncheck' script, right?

    Best regards,
    Benoit.
  • Picture of Brendan Heywood
    Thu, Nov 16, 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
  • Picture of Rajan Zalavadiya
    Wed, Mar 20, 2019, 7:17 PM
    Dangerous things to you body when you eating grain! about grain side effects to bodyKnow About Grain,How Dangerous For Health
  • Picture of Klaus Kuusela
    Mon, Sep 2, 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