Installing Nagios on Mac OS X 10.5 Server
Back when Tiger patrolled the Mac universe, I wrote about installing Nagios 2.X on Mac OS X 10.4 Server. Nagios is an open-source application that is really more of a network monitoring framework. It uses plugins to monitor network services and hosts, providing you with a a web-based interface to see the status of your network.
Installing Nagios allows you to turn any Mac running Mac OS X Server into a network monitoring station able to notify you of both hardware and software problems on your server, usually before anyone else notices you. Nagios can use both e-mail and SMS to notify you of both problems and recovery from problems. (The latter is important, since it can often save you from a late-night remote access session.) Since Nagios requires Perl, Apache, SNMP and a few other things that Mac OS X Server either ships with, or that can be installed with ease, it’s a great way for any network administrator to better monitor their network.
Nagios ships with a number of plugins, and many others can be found on the Web at various sites, most notably NagiosExchange. By using the plugins, you can monitor both the status of hosts and services running on those hosts. So, if you have an e-mail server, you can check if the server hardware is up on the network, and the status of the e-mail services on that server. In addition, the plugin architecture makes it easy to write your own plugins so that you can customize Nagios’ abilities to your needs.
A lot has changed since I posted my original instructions—most notably, major updates to both Mac OS X Server and Nagios. So here are updated instructions for Nagios 3.x and OS X 10.5 Server. I’m not going to repeat every step from the original article, as most steps have not changed; instead, I’m going to focus on the changes in the installation process.
How it’s done
While you can easily download and build Nagios from MacPorts in one step, the current version of Nagios on MacPorts is still 2.10, so to install Nagios, you’ll have to do it from source. While Nagios requires a few frameworks that don’t ship with Mac OS X 10.5 Server, you don’t have to install all of those manually. In my uses, I install as many of the component frameworks from MacPorts as I can. This includes:
Once you’ve installed MacPorts, the process to install those frameworks and Nagios is simple, and unchanged from the one I detailed in my linked article. If you want Nagios to be able to deal with MySQL hosts easier, you’ll want to install the MySQL libraries from Apple before you run the .configure script for Nagios. Those are available from Apple, which offers the download link and installation instructions.
Creating the Nagios users and groups are different in Mac OS X 10.5 Server than they were in Tiger, since there’s no Netinfo. I used System Preferences, since these are all local users. In the advanced options for the user accounts, I set the login shell to
/usr/bin/false and no home directory. You’ll also want to add the
_www user to the nagios group as well. (This will add what everyone else calls the
www user, but you have to add the
_www user with the underscore.
As with the 10.4 installation process, you’ll want to use SSL and .htaccess files to limit access to Nagios and encrypt the connections when you use it. One thing to keep an eye out for is that if you create a new SSL certificate for Nagios in Server Admin, and delete the original one, other web sites on that server may still try to access the old cert. This is due to Mac OS X Server’s Apache config files not being properly updated if you delete a cert via the Server Admin GUI. (Note that this was as of Mac OS X Server 10.5.2—it may be fixed in 10.5.3 or later.) If you’re having a problem with even non-SSL sites that won’t start after you create and set up the new cert, check system.log for errors that reference nonexistent SSL files.
When you set up the .htaccess configuration in the Apache 2 configuration files, you’ll want to make sure you make the changes to the configuration file for the actual site, not the main httpd.conf file. If you’re new to Mac OS X 10.5 Server, it uses Apache 2 by default, not Apache 1.X as in Mac OS X 10.4 Server. The Apache 2 config files are in
/etc/httpd/ directory and files are still there, but are there for situations that require Apache 1.X.
Changes to make
For my setup, I made the following changes to the site config, (located in /etc/apache2/sites/):
<Directory "/Library/WebServer/CGI-Executables"> AllowOverride None #AllowOverride AuthConfig AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user # Options None Options +ExecCGI Order allow,deny Allow from all </Directory>
<Directory "/usr/local/nagios/share"> #AllowOverride All <IfModule mod_dav.c> DAV Off </IfModule> AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user Options All -Includes +ExecCGI +MultiViews -Indexes </Directory>
When you install the base Nagios plugins, (a process I didn’t detail in my earlier article, but one that’s fairly straightforward), if you have a custom cgi-bin path you want to use, then you’ll want to edit the .configure file for the plugins to reflect that.
Other than the things I’ve mentioned, installing and setting up Nagios 3.X is pretty much the same as for version 2.X. Nagios has top-notch documentation, and if you’re new to the product, you’ll really want to spend some serious time reading it.
Configuring Nagios can be a bear for the uninitiated, and it’s easy to lead yourself down the garden path, making things much harder on yourself than necessary. Luckily, in addition to the documentation, Nagios has an thriving community, and I’ve found Nagios users more than willing to help, where they could, with any problems I’ve had.
[John C. Welch is a senior systems administrator for The Zimmerman Agency, and a long-time Mac IT pundit.]