Health Status

Component ID

2000412

Component name

Health Status

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

488

Component created

Component changed

Component body

Health Status is a great solution to monitor custom functionality built into your site.
The Health Status module makes it easy to hook into, and add custom "monitors" that display status messages on an admin dashboard. Health Status can automatically send e-mails when a monitor returns an error.

Adding a new monitor is simple, just create a hook: hook_health_monitors().
Return some info:

<?php
  $monitors['check_nodes'] = array(
    'name' => t('Check number of nodes'),
    'group' => t('Example Group'),
    'description' => t('Checks to make sure at least 1 node exists.'),
    'args' => array('threshold' => 1),
  );
?>

This monitor will now call hook_health_monitor_MONITOR().
Your hook should return a status:

<?php
function health_health_monitor_check_nodes($args) {
  $count = get_node_count();
  if ($count >= $args['threshold']) {
    return health_monitor_status(HEALTH_OKAY, t('There are !count nodes in the database.', array("!count" => $count)));
  }
  else {
    return health_monitor_status(HEALTH_ERROR, t('There are only !count nodes in the database!', array("!count" => $count)));
  }
}
?>

.... And you're done. Wasn't that easy?

This module was originally sponsored by Digital Bungalow