? .cvsignore
? nagios.api.php
? specific_check_and_documentation_update.patch
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nagios/README.txt,v
retrieving revision 1.1.2.16
diff -u -r1.1.2.16 README.txt
--- README.txt	21 Oct 2009 18:47:10 -0000	1.1.2.16
+++ README.txt	9 May 2010 17:44:14 -0000
@@ -158,79 +158,11 @@
 ---
 
 This module provides an API for other modules to report status back to Nagios.
-Your module should implement the following hooks:
-
-hook_nagios_info()
-------------------
-This hook is used to provide a way to enabled/disable a certain module from being included in Nagios
-reports and alerts.
-
-function yourmodule_nagios_info() {
-  return array(
-    'name'   => 'Your module name',
-    'id'     => 'IDENTIFIER',
-  );
-}
-
-hook_nagios()
--------------
-Your module should have a yourmodule_nagios() function that does the actual work of checking something
-and reporting back a status and some info.
-
-The data returned is an associative array as follows:
-
-array(
-  'key'  => 'IDENTIFIER',
-  'data' => array(
-    'status' => STATUS_CODE,
-    'type    => 'state', // Can be a 'state' for OK, Warning, Critical, Unknown) or can be 'perf', which does
-                         // Cause an alert, but can be processed later by custom programs
-    'text'   => 'Text description for the problem',
-  ),
-);
-
-STATUS_CODE must be one of the following, defined in nagios.module:
-
-  NAGIOS_STATUS_OK
-  NAGIOS_STATUS_UNKNOWN
-  NAGIOS_STATUS_WARNING
-  NAGIOS_STATUS_CRITICAL
-
-Here is an example:
-
-function yourmodule_nagios() {
-  $data = array();
-
-  // Check something ...
-  $count = ...
-  if (!$count) {
-    $data = array(
-      'status' => NAGIOS_STATUS_WARNING,
-      'type'   => 'state',
-      'text'   => t('A very brief description of the warning'),
-    );
-  }
-  else {
-    $data = array(
-      'status' => NAGIOS_STATUS_OK,
-      'type'   => 'state',
-      'text'   => '',
-    );
-  }
-
-  return array(
-    'key' => 'IDENTIFIER', // This identifier will appear on Nagios' monitoring pages and alerts.
-    'data' => $data,
-  );
-}
+See nagios.api.php for examples of the hooks and documentation.
 
 For a real life example on how to use this API, check the performance.module in the devel project
 at http://drupal.org/project/devel
 
-hook_nagios_settings()
-----------------------
-This hook provides standard form API elements to be included at admin/settings/nagios. You can
-set any thresholds you want in this hook.
 
 Bugs/Features/Patches:
 ----------------------
Index: nagios.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nagios/nagios.module,v
retrieving revision 1.1.2.25
diff -u -r1.1.2.25 nagios.module
--- nagios.module	18 Mar 2010 22:29:27 -0000	1.1.2.25
+++ nagios.module	9 May 2010 17:44:14 -0000
@@ -113,8 +113,12 @@
  * Callback for the nagios status page
  */
 function nagios_status_page() {
-  $skip_invoke = FALSE;
-
+  $args = func_get_args();
+  // Module to run checks for.
+  $module = array_shift($args);
+  // ID to run checks for.
+  $id = array_shift($args);
+  
   header("Pragma: no-cache");
   header("Expires: 0");
 
@@ -123,8 +127,7 @@
   // Check the unique ID string first
   $ua = variable_get('nagios_ua', 'Nagios');
   if ($_SERVER['HTTP_USER_AGENT'] != $ua) {
-    // This is not an authorized unique id, so do not send information out
-    $skip_invoke = TRUE;
+    // This is not an authorized unique id, so just return this default status.
     $nagios_data = array(
       'nagios' =>  array(
         'DRUPAL' => array(
@@ -135,10 +138,16 @@
       ),
     );
   }
-  
-  if (!$skip_invoke) {
-    // Not authorized, so skipping calling other modules
-    $nagios_data = nagios_invoke_all('nagios');
+  else {
+    // Authorized so calling other modules
+    if ($module) {
+      // A specific module has been requested.
+      $nagios_data = array();
+      $nagios_data[$module] = module_invoke($module, 'nagios', $id);
+    }
+    else {
+      $nagios_data = nagios_invoke_all('nagios');
+    }
   }
 
   // Find the highest level to be the overall status
