You are here

README.txt in Nagios Monitoring 7

Same filename and directory in other branches
  1. 5 README.txt
  2. 6 README.txt
Copyright 2009 Khalid Baheyeldin http://2bits.com
Drush commands originally authored by Josh Waihi http://joshwaihi.com
Maintained by Code Enigma https://www.codeenigma.com


Description
-----------
The Nagios Monitoring module intergrates your Drupal site with with the Nagios.

Nagios is a network and host monitoring application. For more information about
Nagios, see http://www.nagios.org

The module reports to Nagios that the site is up and running normally, including:
- PHP is parsing scripts and modules correctly
- The database is accessible from Drupal
- Whether there are configuration issues with the site, such as:
  * pending Drupal version update
  * pending Drupal module updates
  * unwritable 'files' directory
  * Pending updates to the database schema
  * Cron not running for a specified period

If you already use Nagios in your organization to monitor your infrastructure, then
this module will be useful for you. If you only run one or two Drupal sites, Nagios
may be overkill for this task.

There are also drush commands to allow you to execute Nagios plugins on remote
Linux/Unix machines using NRPE.


Security Note
-------------
This module exposes the following information from your web site:
- The number of published nodes.
- The number of active users.
- Whether an action requiring the administrator's attention (e.g pending module updates,
  unreadable 'files' directory, ...etc.)

To mitigate the security risks involve, make sure you use a unique ID. However, this is
not a fool proof solution. If you are concerned about this information being publicly
accessible, then don't use this module.

For additional security, you may also put the Nagios module status page behind http
authentication, which is recommended. If you do this, we recommend it is done via a
HTTPS connection. While plain HTTP will work, plaintext credentials are never advisable.

If you can run NRPE then it is recommended you disable Nagios checks via Drupal and only
use NRPE checks via drush instead as a security enhancement. This is the best method.


Installation
------------
To install this module, do the following:

1. Extract the tarball that you downloaded from Drupal.org

2. Upload the nagios directory that you extracted to your sites/all/modules
   directory.

3. Optional, to enable Nagios NRPE download and read the documentation at
   http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf


Configuration for Drupal
------------------------
To enable this module do the following:

1. Go to Admin -> Build -> Modules
   Enable the module.

2. Go to Admin -> Settings -> Nagios Monitoring.
   Enter a unique ID. This must match what you configure Nagios for.
   See below for more details.

   Don't forget to configure Nagios accordingly. See below.


Configuration for Nagios
------------------------
The exact way to configure Nagios depends on several factors, e.g. how many Drupal
sites you want to monitor, the way Nagios is setup, ...etc.

The following way is just one of many ways to configure Nagios for Drupal. There are
certainly other ways to do it, but it all centers on using the check_drupal command
being run for each site.

1. Copy the check_drupal script in the nagios-plugin directory to your Nagios plugins
   directory (e.g. /usr/lib/nagios/plugins).

   Depending on your Linux distribution, you may need to alter the PROGPATH variable
   in check_drupal to the correct location for Nagios utils.sh script.

2. Change the commands.cfg file for Nagios to include the following:

   Nagios 2.x:

   define command{
     command_name  check_drupal
     command_line  /usr/lib/nagios/plugins/check_drupal -H $HOSTADDRESS$ -U $ARG1$ -t $ARG2$
   }

   Nagios 3.x:

   define command{
     command_name  check_drupal
     command_line  /usr/lib/nagios/plugins/check_drupal -H $HOSTADDRESS$ -U $ARG1$ -t $ARG2$
   }

   You can add the -S option for hosts that use https.

   If you are monitoring multiple Drupal instances set up as virtual hosts, you
   may have to use $HOSTNAME$ instead of $HOSTADDRESS$ in the command_line
   parameter.

3. Create a hostgroup for the hosts that run Drupal and need to be monitored.
   This is normally in a hostgroups.cfg file.

   define hostgroup {
     hostgroup_name  drupal-servers
     alias           Drupal servers
     members         yoursite.example.com, mysite.example.com
   }

4. Defined a service that will run for this host group

   Nagios 2.x:

   define service{
     hostgroup_name         drupal-servers
     service_description    DRUPAL
     check_command          check_drupal!-U "unique_id" -t 2
     use                    generic-service
     notification_interval  0 ; set > 0 if you want to be renotified
   }

   Nagios 3.x:

   define service{
     hostgroup_name         drupal-servers
     service_description    DRUPAL
     check_command          check_drupal!unique_id!2
     use                    generic-service
     notification_interval  0 ; set > 0 if you want to be renotified
   }

Here is an explanation of some of the options:

-U "unique_id"
  This parameter is required.
  It is a unique identifier that is send as the user agent from the Nagios check_drupal script,
  and has to match what the Drupal Nagios module has configured.  Both sides have to match,
  otherwise, you will get "unauthorized" errors. The best way is to generate an MD5 or SHA1
  string from a combination of data, such as date, city, company name, ...etc. For example:

  $ echo "2003-Jan-17 Waterloo, Canada Honda" | md5sum

  The result will be something like this:

  645666c39f06514528987278c4071d85  -

  The resulting hash is hard enough to deduce, and gives a first level protection against snooping.

-t 2
  This parameter is optional.
  This means that if the Drupal site does not respond in 2 seconds, an error will be reported
  by Nagios. Increase this value if you site is really slow.
  The default is 2 seconds.

-P nagios
  This parameter is optional.
  For a normal site where Drupal is installed in the web server's DocumentRoot, leave this unchanged.
  If you installed Drupal in a subdirectory, then change nagios to sub_directory/nagios
  The default is the path nagios.


Configuration for NRPE
----------------------
See http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf for details on how to set up NRPE checks.

Here is a basic example of checking cron is running.

1. Edit the NRPE cfg file on the web server (normally /etc/nagios/nrpe.cfg) and add:

     command[drupal_check_cron]=/path/to/drush -r /path/to/drupal nagios cron

2. Add an NRPE check to the Nagios server to check for "drupal_check_cron".


NRPE requirements checks
------------------------
It is important to note you will get critical requirements errors from this
module if your NRPE user does not have write permissions to the Drupal
files directory. To resolve this, we recommend the following steps:

1. chgrp your files directory to www-data (where www-data is the group
   of your web server user)

2. chmod your files directory to 775

3. Add your NRPE user to the www-data group

As a more secure alternative, it should be possible for the nrpe/nagios
user to sudo su  to become the www-data user to run the check, but we had a
lot of issues making this work.


API
---
This module provides an API for other modules to report status back to Nagios.
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


Bugs/Features/Patches:
----------------------
If you want to report bugs, feature requests, or submit a patch, please do so
at the project page on the Drupal web site.

Author
------
Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)

If you use this module, find it useful, and want to send the author
a thank you note, then use the Feedback/Contact page at the URL above.

The author can also be contacted for paid customizations of this
and other modules.

File

README.txt
View source
  1. Copyright 2009 Khalid Baheyeldin http://2bits.com
  2. Drush commands originally authored by Josh Waihi http://joshwaihi.com
  3. Maintained by Code Enigma https://www.codeenigma.com
  4. Description
  5. -----------
  6. The Nagios Monitoring module intergrates your Drupal site with with the Nagios.
  7. Nagios is a network and host monitoring application. For more information about
  8. Nagios, see http://www.nagios.org
  9. The module reports to Nagios that the site is up and running normally, including:
  10. - PHP is parsing scripts and modules correctly
  11. - The database is accessible from Drupal
  12. - Whether there are configuration issues with the site, such as:
  13. * pending Drupal version update
  14. * pending Drupal module updates
  15. * unwritable 'files' directory
  16. * Pending updates to the database schema
  17. * Cron not running for a specified period
  18. If you already use Nagios in your organization to monitor your infrastructure, then
  19. this module will be useful for you. If you only run one or two Drupal sites, Nagios
  20. may be overkill for this task.
  21. There are also drush commands to allow you to execute Nagios plugins on remote
  22. Linux/Unix machines using NRPE.
  23. Security Note
  24. -------------
  25. This module exposes the following information from your web site:
  26. - The number of published nodes.
  27. - The number of active users.
  28. - Whether an action requiring the administrator's attention (e.g pending module updates,
  29. unreadable 'files' directory, ...etc.)
  30. To mitigate the security risks involve, make sure you use a unique ID. However, this is
  31. not a fool proof solution. If you are concerned about this information being publicly
  32. accessible, then don't use this module.
  33. For additional security, you may also put the Nagios module status page behind http
  34. authentication, which is recommended. If you do this, we recommend it is done via a
  35. HTTPS connection. While plain HTTP will work, plaintext credentials are never advisable.
  36. If you can run NRPE then it is recommended you disable Nagios checks via Drupal and only
  37. use NRPE checks via drush instead as a security enhancement. This is the best method.
  38. Installation
  39. ------------
  40. To install this module, do the following:
  41. 1. Extract the tarball that you downloaded from Drupal.org
  42. 2. Upload the nagios directory that you extracted to your sites/all/modules
  43. directory.
  44. 3. Optional, to enable Nagios NRPE download and read the documentation at
  45. http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf
  46. Configuration for Drupal
  47. ------------------------
  48. To enable this module do the following:
  49. 1. Go to Admin -> Build -> Modules
  50. Enable the module.
  51. 2. Go to Admin -> Settings -> Nagios Monitoring.
  52. Enter a unique ID. This must match what you configure Nagios for.
  53. See below for more details.
  54. Don't forget to configure Nagios accordingly. See below.
  55. Configuration for Nagios
  56. ------------------------
  57. The exact way to configure Nagios depends on several factors, e.g. how many Drupal
  58. sites you want to monitor, the way Nagios is setup, ...etc.
  59. The following way is just one of many ways to configure Nagios for Drupal. There are
  60. certainly other ways to do it, but it all centers on using the check_drupal command
  61. being run for each site.
  62. 1. Copy the check_drupal script in the nagios-plugin directory to your Nagios plugins
  63. directory (e.g. /usr/lib/nagios/plugins).
  64. Depending on your Linux distribution, you may need to alter the PROGPATH variable
  65. in check_drupal to the correct location for Nagios utils.sh script.
  66. 2. Change the commands.cfg file for Nagios to include the following:
  67. Nagios 2.x:
  68. define command{
  69. command_name check_drupal
  70. command_line /usr/lib/nagios/plugins/check_drupal -H $HOSTADDRESS$ -U $ARG1$ -t $ARG2$
  71. }
  72. Nagios 3.x:
  73. define command{
  74. command_name check_drupal
  75. command_line /usr/lib/nagios/plugins/check_drupal -H $HOSTADDRESS$ -U $ARG1$ -t $ARG2$
  76. }
  77. You can add the -S option for hosts that use https.
  78. If you are monitoring multiple Drupal instances set up as virtual hosts, you
  79. may have to use $HOSTNAME$ instead of $HOSTADDRESS$ in the command_line
  80. parameter.
  81. 3. Create a hostgroup for the hosts that run Drupal and need to be monitored.
  82. This is normally in a hostgroups.cfg file.
  83. define hostgroup {
  84. hostgroup_name drupal-servers
  85. alias Drupal servers
  86. members yoursite.example.com, mysite.example.com
  87. }
  88. 4. Defined a service that will run for this host group
  89. Nagios 2.x:
  90. define service{
  91. hostgroup_name drupal-servers
  92. service_description DRUPAL
  93. check_command check_drupal!-U "unique_id" -t 2
  94. use generic-service
  95. notification_interval 0 ; set > 0 if you want to be renotified
  96. }
  97. Nagios 3.x:
  98. define service{
  99. hostgroup_name drupal-servers
  100. service_description DRUPAL
  101. check_command check_drupal!unique_id!2
  102. use generic-service
  103. notification_interval 0 ; set > 0 if you want to be renotified
  104. }
  105. Here is an explanation of some of the options:
  106. -U "unique_id"
  107. This parameter is required.
  108. It is a unique identifier that is send as the user agent from the Nagios check_drupal script,
  109. and has to match what the Drupal Nagios module has configured. Both sides have to match,
  110. otherwise, you will get "unauthorized" errors. The best way is to generate an MD5 or SHA1
  111. string from a combination of data, such as date, city, company name, ...etc. For example:
  112. $ echo "2003-Jan-17 Waterloo, Canada Honda" | md5sum
  113. The result will be something like this:
  114. 645666c39f06514528987278c4071d85 -
  115. The resulting hash is hard enough to deduce, and gives a first level protection against snooping.
  116. -t 2
  117. This parameter is optional.
  118. This means that if the Drupal site does not respond in 2 seconds, an error will be reported
  119. by Nagios. Increase this value if you site is really slow.
  120. The default is 2 seconds.
  121. -P nagios
  122. This parameter is optional.
  123. For a normal site where Drupal is installed in the web server's DocumentRoot, leave this unchanged.
  124. If you installed Drupal in a subdirectory, then change nagios to sub_directory/nagios
  125. The default is the path nagios.
  126. Configuration for NRPE
  127. ----------------------
  128. See http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf for details on how to set up NRPE checks.
  129. Here is a basic example of checking cron is running.
  130. 1. Edit the NRPE cfg file on the web server (normally /etc/nagios/nrpe.cfg) and add:
  131. command[drupal_check_cron]=/path/to/drush -r /path/to/drupal nagios cron
  132. 2. Add an NRPE check to the Nagios server to check for "drupal_check_cron".
  133. NRPE requirements checks
  134. ------------------------
  135. It is important to note you will get critical requirements errors from this
  136. module if your NRPE user does not have write permissions to the Drupal
  137. files directory. To resolve this, we recommend the following steps:
  138. 1. chgrp your files directory to www-data (where www-data is the group
  139. of your web server user)
  140. 2. chmod your files directory to 775
  141. 3. Add your NRPE user to the www-data group
  142. As a more secure alternative, it should be possible for the nrpe/nagios
  143. user to sudo su to become the www-data user to run the check, but we had a
  144. lot of issues making this work.
  145. API
  146. ---
  147. This module provides an API for other modules to report status back to Nagios.
  148. See nagios.api.php for examples of the hooks and documentation.
  149. For a real life example on how to use this API, check the performance.module in the devel project
  150. at http://drupal.org/project/devel
  151. Bugs/Features/Patches:
  152. ----------------------
  153. If you want to report bugs, feature requests, or submit a patch, please do so
  154. at the project page on the Drupal web site.
  155. Author
  156. ------
  157. Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)
  158. If you use this module, find it useful, and want to send the author
  159. a thank you note, then use the Feedback/Contact page at the URL above.
  160. The author can also be contacted for paid customizations of this
  161. and other modules.