It's Nagios Drupal Monitoring time for us dogs, now that Acquia is mumbling in its beer.

Aquia Drupal - free as in beer and speachI still have my brown Acquia T-shirt that was distributed at the March, 2009 Washington DC DurpalCon. On the back it says "Free as in beer". Well, the free bit still applies to Acquia Drupal, and the various stacks which are useful for various operating systems and environments to a lot of people. But now Acquia is mumbling in their beer: no more freebie community style accounts, you gotta start paying for site monitoring via the Acquia Network once the initial 30 day trial period ends. OK, it does include goodies like Acquia search, and other stuff. But to get a solution that is truly free as in beer, and a richer solution at that, it's clearly Nagios time for us dogs.

This is a detailed howto article, but you can skip the parts that you don't need easily, and it will get you up and running with an enviable Nagios Drupal Monitoring station. Just jump in wherever:

What is Nagios?

"So what are the sorts of things Nagios can do? Nagios can do much more than this, but nevertheless here’s a list of common things that Nagios is used for.

  • Check to see if a server is up and running

  • Notify you if a server is down (by email/pager/SMS)

  • Check to see if a service is running (mail, http, pop, ssh)

  • Check to see if a process (or Windows service) is running

  • Gather performance statistics on a server

  • Allow specific alerts to only go to particular groups/individuals

  • Get reports of downtime on your servers"

from "What is Nagios", The Nagios Book

As independent Drupal developers our own server and sites infrastructure, even together with all the hosted production sites belonging to our clients, is no match for a large corporation's IT infrastructure. But we still need to monitor them, and so a system like Nagios, which is open source software and published under the GPL license (http://www.nagios.org/about/features), and, erm, free as in beer, is looking pretty good right now. See http://www.nagios.org/about

Setting up the Nagios monitoring application.

OK, first of all, we are talking about server environments and shared hosting is not convered in this article. The Drupal sites BEING monitored can be on shared hosts, no problem there, of course. I simply don't cover setting up the Nagios monitoring application itself on shared hosts. So we are assuming a VPS or Dedicated server environment, where you have root access. But, hey, if you can install Drupal from a tarball you can install Nagios Cool. 'nuff said.

Check out the Nagios Quickstart Installation Guides for your own particular environment flavor. Also, here are a couple of Ubuntu examples from my own recent experience:

Example: Installing Nagios as an Ubuntu package

About a year ago I was beginning work on a development server, and installed Nagios on an Ubuntu 8.10 Server edition. You can find detailed instructions on installation and configuration here:  http://awebfactory.com.ar/node/345#installnagios

Example: Installing the latest version from source on Ubuntu Hardy

[Skip to the next section on setting up the Drupal Nagios monitoring module]

I basically followed the instructions found at http://nagios.sourceforge.net/docs/3_0/quickstart-ubuntu.html and reflected in http://www.ubuntugeek.com/nagios-network-monitoring-system-setup-in-ubuntu.html. Please leave a comment here if you encounter any difficulty.

As advertised, I ended up with:

  • Nagios and the plugins will be installed underneath /usr/local/nagios
  • Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage, etc.)
  • The Nagios web interface will be accessible at http://localhost/nagios/

Useful command-line Nagios commands:

To check the configuration files for warnings and errors, I did the following:

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Starting, stopping, restarting nagios from the command-line (after changing configuration, for example):

# /etc/init.d/nagios start 
# /etc/init.d/nagios stop
# /etc/init.d/nagios restart

Setting up the Nagios monitoring module (Thanks kbahey -- Khalid Baheyeldin of 2bits.com).

Almost as soon as I installed Nagios for the first time about a year ago and was wondering to myself, "OK, I got myself a heartbeat, now what?", Khalid (kbahey) blogged about his recently developed Drupal Nagios monitoring module, and I was so happy I promised him I would try it. Well, better late than never, so here goes!

Download the module http://drupal.org/project/nagios to each of the client Drupal sites, as well as the Nagios server site also (for the included Nagios plugin, details on this in a moment).

Read the author's disclaimers found in the README.txt file, especially on security... (the unique identifier security enhancer works well, I recommend that) and follow the instructions found there.

I created my unique identifer on a linux command line specifying a string composed of, for example, items like MAC numbers, a random number and a datestamp, and did something like:

$ echo "xxxxx string goes here *****" | md5sum
 xxxxxxxxxxxxxxxxxxxxxxxxxx

and copied the result.

After installing and enabling the module as usual, I headed over to Administer > Settings > Nagios monitoring, and entered the ID created in previous step.

In general, I followed the instructions in README.txt

I then mosied over to the Nagios server site. I copied the check_drupal script found in the nagios-plugin sub-directory to the Nagios plugins directory. Where this is depends on your nagios install. The module author speaks of /usr/lib/nagios/plugins but in my case (compiled from source together with plugins following the Nagios quick start guide) it was /usr/local/nagios/libexec.

I double-checked to make sure it had execute permissions and did a:

# chown nagios:nagios check_drupal

in line with other plugins I knew were already working (like check_ping).

Since I am working with Nagios 3.x on my server (latest stable 3.2.0 at my time of writing), I next edited the commands.cfg file in the /usr/local/nagios/etc/objects directory, adding the following (make sure the command_line path is accurate):

################################################################################
# Command for Drupal Nagios monitoring module http://drupal.org/project/nagios
################################################################################

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

Then, following the examples in the nagios sample configuration files I went ahead and added the Drupal site host(s), hostgroup and services info into a single drupal.cfg file in the objects directory (/usr/local/nagios/etc/objects) instead of separately following steps 3 and 4 from the Drupal module README file.

I ended up with the following

/usr/local/nagios/etc/objects/drupal.cfg 

file (info changed to protect the guilty):

# cat drupal.cfg 
###############################################################################
# drupal.cfg - Configuration file for monitoring drupal site hosts
#
###############################################################################

###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

define host{
use linux-server ; Name of host template to use
host_name awebfactory.com.ar
alias awebfactory.com.ar
}

###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################

# Define an optional hostgroup for Linux machines

define hostgroup{
hostgroup_name drupal-servers ; The name of the hostgroup
alias Drupal Servers ; Long name of the group
members awebfactory.com.ar ; Comma separated list of hosts that belong to this group
}


###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

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

Be sure to replace "unique identifier" with your... unique identifier (discussed above). The exclamation marks are simply Nagios speak to separate the paramaters used to invoke the plugin.

After having created the configuration file in this way, I then enabled it in:

/usr/local/nagios/etc/nagios.cfg 

by adding the following two lines just under the localhost.cfg specification, ending up as follows:

# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring Drupal servers
cfg_file=/usr/local/nagios/etc/objects/drupal.cfg

Now to check the sanity of all the new configuration setup and finally to restart the nagios service itself.

To carry out this check for warnings and errors, I did the following:

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

A bunch of highly useful info scrolled by, and then I saw:

Total Warnings: 0
Total Errors:   0

Which is what I wanted to see, of course!

But does it work? First restart the nagios service:

# /etc/init.d/nagios restart

and then point your browser at http://example.com/nagios .

 

If you have difficulties with the Drupal plugin, you can execute drupal_check from the command_line:

/usr/local/nagios/libexec # ./check_drupal -U xxxxxxxxx

Comments? Did people get this working?

Enjoy your free Drupal sites Nagios monitoring dashboard!

Pointing your browser at the Nagios monitoring application (in my install it was something like http://example.com/nagios), and clicking on Services should yield a screen similar to the following (in this case the Drupal service is grumbling about Date Popup JQuery UI requirements Laughing:

Nagios Drupal service wants JQuery UI for Date Popup calendar

 

So I installed the JQuery UI module and library, and everything was blessed:

Nagios Drupal service flagging everything A-OK

Enjoy receving Drupal site Nagios alerts in your mail for free!

Meanwhile, I had taken care to install mailx in my system and correct the Nagios configuration files accordingly, in order to get those annoying but life-saving emails for alerts and recoveries!

I did the following from the command line on the Nagios server:

# apt-get install mailx
# which mailx
/usr/bin/mailx

Armed with the knowledge of how to invoke mailx, I went to the appropriate directory and edited commands.cfg so that the right mail sending utility would be invoked (I replaced /usr/bin/mail with /usr/bin/mailx wherever it occurred):

cd /usr/local/nagios/etc/objects/
vi commands.cfg

I restarted Nagios for the changes to take effect:

/etc/init.d/nagios restart

And lo and behold, for annoying alerts started rolling into my email account (since I am the nagioadmin contact: see contacts.cfg in the objects directory):

Annoying but life-saving Nagios Drupal alerts

The text of the mail reads as follows:

Text of Nagios Drupal alert emails

OK! We're good to go. Now I can add additional host definitions in /usr/local/nagios/etc/objects/drupal.cfg

What's next? Roll your own...

New release

Hi Victor,

I'm the new maintainer of Nagios (Khalid is still a maintainer, but he's too busy right now, so I'm the caretaker) - I just rolled a D6 point release and a D7 beta. Just thought I'd let you know, in case you want to review this again. It's even better now and supports NRPE (via drush) so you don't even have to use the http check any more, for better security and reliability. We run a two-vector set-up, with a Nagios server at Rackspace Cloud and another at Linode, both watching all our Drupal sites and it's just great. Soooo much more info than a certain other service you mentioned (plus we run Munin alongside it for longer term resource monitoring, which is also excellent). Anyway, I'm rambling. Would be happy to show you around our set-up if you want to see how we're doing it. =)

Great news Greg!

I will review as soon as possible!

As soon as I have time I will be contacting you to take you up on that tour!

Cheers!

Victor

The Drupal companion to Nagios, Droptor

Great write-up on Nagios. I've used it a big in the past.

I know this flies a bit in the face of Acquia not being free as in beer, but we make a tool called Droptor that does what Nagios does at the server layer to your Drupal layer: http://drupal.org/project/droptor

It focuses more on profiling than uptime monitoring, but it delves deeper into Drupal than Nagios can.

how do you monitor nagios, then ?

thanks for the post, it looks inspiring. just one stupid question ... how do you make sure the nagios server is running ? is there some "heartbeat" to another server ? thanks.

Two vectors

We run two Nagios servers, one from Rackspace and one from Linode, that watch each other *and* everything else. =)

Something to think about...

Well, I think that the free version of Acquia wouldn´t last long. I mean, Acquia was created as an enterprise not an NGO. I think that the free version was very good to attract potential customers though.
I didn´t noticed the change of politics, was it at the same time that they´ve changed their homepage?

Thanks for the information about Nagios, I think that now it is a quite good alternative.

Does it looks like Acquia Drupal isn´t freely distributed also?
Could we think that the best free modules at drupal repository won´t be updated because the latest updates will be at Acquia after we pay a fee?

Just rambling questions that comes to my mind after reading your post...

Rosamunda

Acquia Drupal is still free

It's simply disconcerting that a service that was free (Acquia Network) no longer has a free option. The Basic is now USD $349 / year. So while Acquia Drupal itself is still free, it's not the most secure feeling in the world to, say, base yourself on that distribution.

Apart from which, it includes the Acquia Drupal monitoring, although I guess you can turn it off...

There's nothing wrong with a company charging for services. And there's certainly nothing wrong with a company orienting itself towards Enterprise customers (the new hosting _starts_ at USD $500 / month); but there begins to be an abandonment of small shops and independent developers. You can see that when you see that the Developer subscription costs USD $5000 a year. And it is this community that has made Drupal quality what it is.

A dependency upon large corporate needs will definitely color things.

In terms of having to pay a fee for third party modules, I think there is no danger of that per se, but there is a tendency for Enterprise customer "needs" to be a driving force in Drupal development, which, although inevitable in every successful Open Source project, will have its effect on what happens. Because we don't really get to see the engineering under the hood that makes everything really happen. Take whitehouse.gov for example: what has been shared on that score?

So that model is Closed Shop, not Open Source.

So it is good we have "rambling thoughts"... let's see what happens...

Some clarifications

To clarify (And it says this on the t-shirt if you read it).

Acquia Drupal
Free as in Freedom (all FOSS software)
Free as in Beer (Costs nothing).

This is a Drupal distribution Acquia maintains, and spends quite a bit of money doing. It contains best practices and a starter kit to get new people into Drupal or old hands to have some sense of confidence that contributed modules are being at least looked at when updates come out (updates don't cost money btw as you suggested earlier).

Acquia Network
Costs many hundreds of thousands or millions to develop and maintain (as does Acquia Drupal). Never was free as in Beer, although much of it is Free as in Freedom.

There was a BETA free account, there was never a free account. There is a free trial and a cheap community account which includes Acquia Search (Awesome faceted search w/ no setup), site monitoring, spam filtering, and some support among other things.

I don't understand the comment that Acquia is "Mumbling into its beer." Acquia has not deviated from its initial or continuing commitment to open source (Acquia Engineers figure heavily into Drupal contributions in core and contrib on company money). Included is the Apache Solr module which which you reference. A "roll your own" would not be available without the work of Peter Wolanin, Robert Douglas and myself being given back 100% to the community.

It is true that much of Acquia's offerings are targeted at Enterprise customers, but we have quite a few SMEs as customers as well and independent developers who need support helping deliver top notch value for their clients.

In addition, an open source company needs to make money. This means providing commercial support, the profitable part of that is to enterprises. If you don't like it, stop using any of your banks, they all run Redhat, and stop using MySQL for your database, and discontinue the use of Java, Eclipse, Ubuntu, Wordpress. All of these projects have companies with very expensive enterprise rates and give back the lions share of their developed source code for everyone to use. I don't see Acquia being any different here.

While your article has useful information, the headline is simply not accurate and seems motivated more by a desire to stir up controversy for publicity than to push forward the efforts of FOSS software. I suggest you take it up with Dries, he'd be happy to explain the Acquia position, as would anyone on the Acquia team.

Best,
Jacob

Acquia should have a free community track for Acquia Network

Acquia should have a free community track for Acquia Network.

The Open Source model of using the community to check out the bugs with a free Beta version has been discontinued despite the work of the community, and a free community track would still be of value.

That's my point.

Victor