munin_api.install 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * Munin API for Drupal: installation and runtime checks.
  6. *
  7. * @author Frederic G. MARAND
  8. *
  9. * @copyright (c) 2011 Ouest Systèmes Informatiques
  10. *
  11. * Licensed under the General Public License version 2 or later.
  12. */
  13. /**
  14. * Implements hook_requirements().
  15. */
  16. function munin_api_requirements($phase) {
  17. $ret = array();
  18. if ($phase == 'runtime') {
  19. $count = count(module_implements('munin_api_info'));
  20. if ($count == 0) {
  21. $req = array(
  22. 'title' => t('Munin plugin modules'),
  23. 'value' => t('No Munin plugin module enabled'),
  24. 'description' => t('Munin API is enabled, but no plugin module is enabled to report to it. In this situation, Munin API consumes resources but does not actually report anything. You should either enable some plugin modules or disable and uninstall Munin API.'),
  25. 'severity' => REQUIREMENT_WARNING,
  26. );
  27. }
  28. else {
  29. $req = array(
  30. 'title' => t('Munin plugin modules'),
  31. 'value' => format_plural($count, '1 Munin plugin enabled.',
  32. '@count Munin plugins enabled.'),
  33. 'severity' => REQUIREMENT_OK,
  34. );
  35. }
  36. $ret[] = $req;
  37. }
  38. elseif ($phase != 'install') {
  39. // This should never happen and points to a severe error somewhere
  40. watchdog('munin_api', 'Invalid phase %phase passed to %function', array(
  41. '%phase' => $phase,
  42. '%function' => __FUNCTION__,
  43. ), WATCHDOG_ERROR);
  44. }
  45. // else $phase == 'install', nothing to do.
  46. return $ret;
  47. }