There is a module released for monitoring Drupal sites with Nagios. Monitoring includes the check if your site is up and running, check for new updates on Drupal core, security, and modules, database updates, write permission on “files” directory, check if cron is running on the specified period, and other sections of your Drupal site. It is intended and helpful to those maintain large number of Drupal sites.
At this time of writing, this module is still on a development version and there’s no guarantee that the installation guide will work out-of-the-box with your system. And this post will mainly cover my own installation process on our Nagios monitoring server running on Debian and Nagios version 3.0, and Drupal version 6.x sites on web servers running CentOS 5.x.
Installation: My installation is based on the included README file and with some adjustments to my liking.
Install the Drupal Module:
Download the Nagios module from Drupal project page.
Install the module to your Drupal site just like the other modules. Download tarball, extract to modules directory ex: sites/all/modules/, go to admin->build->modules and enable the module.
Configure your Nagios module and set the site’s UniqueID and Cron duration.
UniqueID is your site identifier to be used by the Nagios (check_drupal) to authorize the service check and for security purposes. The author also suggests the use of MD5 or SHA1 string. Refer to README for more info on this parameter.
Cron Duration - you need to supply the interval of your cron job that checks for Drupal updates. This value should match with your cron settings, ex: daily or every 3 hours..etc.
Configure Nagios checks:
- Copy the plugin file (check_drupal) found on the nagios-plugin directory of the module, to your Nagios plugins directory where the other Nagios check commands are located - in my case it’s on /usr/local/nagios/libexec/ (CentOS).
If your Nagios installation is on a different machine than your Drupal server, you need to copy the check_drupal file in there. You can also put it on the same server with Drupal sites and use NRPE instead.
On my CentOS machine i received an error on check_drupal regarding the location of basename file - it’s on /bin/basename. You can edit the check_drupal file directly to adjust the path to basename.
./check_drupal: line 14: /usr/bin/basename: No such file or directory.
- Add command, host, hostgroup, and service definition:
Command (commands.cfg): I made small modification on the given commands from the README file to match my setup.
1 2 3 4
HostGroup: I created a new Host group because we have other service checks on our server such as SSH, HTTP, LOAD, etc and I want to separate my checks for Drupal sites.
1 2 3 4 5
Host: I defined new host for Drupal sites so i can configure and group my them on the same host where they belong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Service: Below is my service checks definition for checking Drupal sites, i only need to copy this and change supply parameters for domain, unique key and the timeout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
If your installation and configuration is correct you will get the Nagios service status similar below. It indicates number of modules, themes, users, nodes, etc.
On my initial tests i received Nagios status (below) different than the above info and it was caused by my Apache configuration because i have a default Nagios installation before on my server that hosts my Drupal sites.
So you need to check first the url of your Nagios module installation ex: http://mysamplesite.com/nagios/, this will give you: