? .cvsignore
? 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	10 May 2010 05:05:55 -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.api.php
===================================================================
RCS file: nagios.api.php
diff -N nagios.api.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ nagios.api.php	10 May 2010 05:05:55 -0000
@@ -0,0 +1,94 @@
+<?php
+// $Id;
+
+/**
+ * Provide a way to enabled/disable a certain module from being included in Nagios reports and alerts.
+ */
+function hook_nagios_info() {
+  return array(
+    'name'   => 'Your module name',
+    'id'     => 'IDENTIFIER',
+  );
+}
+
+/**
+ * Does the actual work of checking something.
+ *
+ * @param $id
+ *   Optional, an identifier which is the 2nd argument passed via the URL.
+ *   this is useful when you just want nagios to check a single function.
+ *   example: http://mysite.com/nagios/mymodule/myId.
+ *
+ *   "myId" would be send to mymodule_nagios.
+ *
+ *   http://mysite.com/nagios/mymodule would not send any id, but would not
+ *   run hook_nagios for any other modules.
+ *
+ * @return array
+ * 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:
+*
+* @return <type>
+*/
+function yourmodule_nagios($id) {
+  $data = array();
+
+  // Check something ...
+  $count = 10;
+  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,
+  );
+}
+
+/**
+ * Form API elements to be included at admin/settings/nagios
+ */
+function hook_nagios_settings() {
+  $form = array();
+
+  $form['size_of_file'] = array(
+    '#type' => 'textfield',
+    '#title' => 'Max file size',
+    '#desciption' => 'If file is over this size, tell nagios it is an error',
+  );
+
+  return $form;
+}
+
+
+
+?>
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	10 May 2010 05:05:56 -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
