Nagios on Ubuntu 9.04 server

Posted by Quinny Wed, 12 Aug 2009 10:17:15 GMT
This little article will describe the steps you'll need to follow to install Nagios with digest authentication and temperature monitoring on an Asus EEE Box.

Nagios
So, I finally got my server up and running. I'd like to keep it that way or, at least, keep my blog available...

I know a server monitoring itself is not ideal, hardware failure and kernel panics will probably take it down without me getting any kind of warning.
Still, I will get warnings when processes die, when the SSD starts filling up or when the CPU temperature becomes uncomfortably hot. (The EEE Box is located in my old room at my parents house; in the attic. It gets really hot in there...)

First, download Nagios and the Nagios-plugins and upload them to your server.

I followed this guide to do the basic Nagios installation. Skip over the parts for Ubuntu 6.10, as they're not needed for Ubuntu 9.04.

I wanted to use digest authentication, because I don't want usernames and passwords to be sent over the internet in clear text.
To setup digest authentication I followed this guide. I didn't bother with forced TLS and IP subnet lockdown. To enable digest authentication in Apache on Ubuntu 9.04 you need to run:

Code:
$ sudo ln -s /etc/apache2/mods-available/auth_digest.load /etc/apache2/mods-enabled $ sudo /etc/init.d/apache2 reload


To make things just a little bit more complex, I wanted Nagios to run in a virtual host. To accomplish this, I moved the Nagios configuration from /etc/apache2/conf.d/nagios to /etc/apache2/sites-available/nagios and embedded it in a VirtualHost directive:

Code:
<VirtualHost *:80> ServerAdmin quintin@quintinsmits.com DocumentRoot /var/www/nagios.quintinsmits.com/ ServerName nagios.quintinsmits.com ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <Directory "/usr/local/nagios/sbin"> Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Digest AuthUserFile /usr/local/nagios/etc/.digest_pw Require valid-user </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/usr/local/nagios/share"> Options None AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Digest AuthUserFile /usr/local/nagios/etc/.digest_pw Require valid-user </Directory> </VirtualHost>

After this, you'd need to make a link from sites-available to sites-enabled:

Code:
$ sudo ln -s /etc/apache2/sites-available/nagios /etc/apache2/sites-enabled/000-nagios

Remember, that after every change to your Apache configuration you need to run:

Code:
$ sudo /etc/init.d/apache2 reload

You'd need a DNS entry for this as well, of course...

To redirect from nagios.quintinsmits.com to nagios.quintinsmits.com/nagios/ I used a simple PHP redirect:

Code:
<?php header( 'Location: http://nagios.quintinsmits.com/nagios/' ) ; ?>

For temperature monitoring I used LM_Sensors. Yesterday, I wrote a little howto on MSN for a friend, who made a nice post about it on his blog. Use that to install LM_Sensors if you're using an EEE Box. If you're using something else, you're on your own...

After installing LM_Sensors and getting a readout of your sensors, you'll want to download check_lm_sensors from MonitoringExchange and upload it to your server. The check_sensors plugin that comes with the Nagios-plugins package only displays a summary of all the sensor values.
Unpack and install check_lm_sensors:

Code:
$ tar -xvf check_lm_sensors-3.1.1.tar.gz $ cd check_lm_sensors-3.1.1 $ perl Makefile.PL INSTALLSITESCRIPT=/usr/local/nagios/libexec $ make $ sudo make install

You're not done yet, you can't run the plugin before you install the Nagios::Plugin and Nagios::Plugin::Threshold Perl modules. Fortunately, Perl comes with a nice utlilty called CPAN, which allows you to install Perl modules easily:

Code:
$ sudo cpan $ install Nagios::Plugin

When I tried to install Nagios::Plugin::Threshold I was told by CPAN that this module was already installed. Perhaps it was installed as a depencency when I installed Nagios::Plugin. If it wasn't, you need to install it separately.

Now we need to integrate the plugin with our Nagios configuration. Edit /usr/local/nagios/etc/objects/commands.cfg and add:

Code:
define command{ command_name check_cputemp command_line $USER1$/check_lm_sensors --check 'CPU Temp'=$ARG1$,$ARG2$ }

This could be made to be more flexible, if you replace "CPU Temp" with another variable. I didn't, because I only want to monitor my CPU temperature.

You also need to define a service check. Edit the configuration file for the server you want to check. In my case, it was /usr/local/nagios/etc/objects/localhost.cfg:

Code:
define service{ use local-service host_name localhost service_description CPU Temperature check_command check_cputemp!75!90 notifications_enabled 0 }

Remember to add a variable here too, if you did so in the command definition.

After updating the Nagios configuration, you need to restart Nagios:

Code:
$ sudo /etc/init.d/nagios restart

You should now have temperature monitoring in Nagios, which'll be secured via digest authentication!

Posted in | no comments |



Leave a comment

Leave a comment