Monitoring Drupal with Icinga


Monitoring one or two Drupal sites can be done by logging into the status report every few days and reviewing settings, looking at your watchdog log, and reading the emails the sites send you. However, as you run more and more sites that process becomes overwhelming and can take up a large amount of time. A few services exist to help monitor all of your sites in one place, Droptor, Drupal Monitor, and Acquia all provide really slick solutions. However, if you want to roll your own due to cost, corporate security, etc… the Drupal community has developed several tools leveraging Nagios.

I wanted to set this up to monitor the sites I manage and chose to use Icinga, a fork of Nagios and openSUSE 12.2 as that is consistent with our environment. Currently I am doing this as a proof of concept project and it is running inside of VirtualBox on an older Mac. The Drupal projects that I am using are the following:

These two modules first let us talk with our Nagios server but also provide most of the stats you can find in the paid services. On initial install the results are not all that pretty to look at but I believe there are ways to fix that and I would rather have comprehensive than pretty any day.

Installation was inspired by the post at awebfactory. There is currently no write-ups on how to do the install if you are using Icinga but since it is a fork of Nagios all of the steps are quite similar. I still know very little about Nagios so if you see a goofy config file please improve upon it. The readme file that accompanies the Nagios Monitoring module is fairly comprehensive and if using Icinga use the Nagios 3 style configuration options. Here are four tips that I wish I had known while setting this up.

4 Tips

  1. You must define a host in your .cfg file you create for monitoring the Drupal sites. The README assumes you have done this already but if you are creating a monitoring server from scratch this is news. Add the following at the top of the hostgroups.cfg file the instructions ask you to create.
    define host{
            use                     linux-server
            alias                   DevVM ; You will see what you put here in Icinga
  2. The unique string you generate for use in the module and within Icinga goes where the instructions have the words unique identifier.
  3. Initially my Drupal check was not returning any results. I got an error “Service Check Timed Out.” My dev server is a little pokey so I needed to edit the service_check_timeout line in icinga.cfg from 60 to 600. I chose 600 because this article uses it, very scientific, I know.
  4. The SUSE Icinga package places Icinga in /etc/icinga, /etc/init.d/icinga check_verbose checks your settings in the .cfg files you have edited/created and /etc/init.d/icinga restart restarts the service.

Installing Icinga

Thankfully there is a package for Icinga in the openSUSE repositories. I installed this using the GUI tools but if I move out of a proof of concept phase I would do this with an openSUSE box run level 3 so I will try to show the command line install options rather than how to use Yast. This generally just involves following the documentation at

Install the dependencies:

$ zypper install gd gd-devel libjpeg libjpeg-devel libpng libpng-devel
$ zypper install net-snmp net-snmp-devel perl-Net-SNMP

Create a user named icinga, please follow the instructions at the link above.

$ zypper install thttpd
$ sudo vi /etc/icinga/etc/objects/contacts.cfg

Change the email address associated with icingaadmin to one that you can receive email at. ESC : wq ENTER to exit.
Set the password for icingaadmin
$ htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
$ sudo /etc/init.d/apache2 reload

Make sure Icinga starts when you boot.

$ chkconfig --add icinga
$ chkconfig icinga on
Verify everything is good with your initial configuration.
$ sudo /etc/init.d/icinga check_verbose

Start Icinga

$ sudo /etc/init.d/icinga start

Navigate to http://localhost/icinga/ and login with icingaadmin and the password you set earlier.

Install the Nagios Drupal Check service

The steps in the README file are correct for openSUSE. Just use the Nagios 3.x version of the commands and follow tip number 1 from above.

Final Result

Drupal Nagios Alert
A nagios alert showing issues with a site I have in dev.

I started monitoring a site I have on my devVM and it shows me a boatload of issues. Core is out of date, stuff is turned on that shouldn’t be for a production site, modules need to be updated, etc… The beauty of this is that I simply need to turn the module on for each site I want to monitor, update my hostgroup definition in hostgroups.cfg and I have instant monitoring. I hope to provide further details such as NRPE on the remote host, selective alerts, and a prettier interface.

Thank you to everyone I have linked to in this article and to the developers of the fantastic Icinga, Nagios, and Drupal modules. On a happy note, Acquia itself uses Nagios to monitor their sites in the Acquia cloud.

Leave a Reply

Your email address will not be published. Required fields are marked *