Using Nagios to monitor your network, Part 1: Installation

—by Joel Rennich, mactroll@afp548.com

11 September 2002

Nagios, formerly Netsaint, is a very full-featured network-monitoring package. Through a Web interface you are able to make sure that all of your servers are running the way that they should be. Plus you are able to track uptime and be automatically alerted when things go wrong.

While Mac OS X Server 10.2 brings some of these features in the Server Status application or the Server Monitor application, the former only monitors Mac OS X 10.2 Servers and the latter only monitors XServes. Nagios, however, will be able to monitor services on any machine that your server can contact over the network.

You can check out www.nagios.org for more information and a better look at what the package can do.

To install Nagios, we are first going to need to install some additional libraries to allow it to look as good as it can. Nagios wants the GD libraries, which give an application the ability to create and use images. The GD libraries want the JPEG and PNG libraries to be able to understand images in the first place. We’ll compile all three and then get on to Nagios itself.

Before we get started we’re going to create a temporary directory to keep all of the packages that we’ll be working on. When everything is done you can through the folder away and reduce the clutter. Open up a new terminal window and type the following commands:

mkdir nagios-install
cd nagios-install

We’ll take care of the libpng library first.

curl -O http://www.libpng.org/pub/png/src/libpng-1.2.4.tar.gz
gnutar -xzvf libpng-1.2.4.tar.gz
cd libpng-1.2.4
cd scripts
cp makefile.darwin ../makefile
cd ..
make
sudo make install
sudo ranlib /usr/local/lib/libpng.a
cd ..

Not too hard so far. Now on to the JPEG libraries.

curl -O  ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
gnutar -xzvf jpegsrc.v6b.tar.gz
cd jpeg6b
./configure
make
sudo mkdir /usr/local/man/man1
sudo make install-lib
sudo ranlib /usr/local/lib/libjpeg.a
cd ..

Finally we can get to the GD libraries themselves. Don’t worry about it complaining about the lack of some X-Windows directories.

curl -O http://www.boutell.com/gd/http/gd-1.8.4.tar.gz
gnutar -xzvf gd-1.8.4.tar.gz
cd gd-1.8.4
make
sudo make install
cd ..

Now on to Nagios itself. The software comes in two parts, the actual application and then a collection of plug-ins. The application compiles fine, the plug-ins not so well. I’ve cleaned up the problems and have packaged them up for your downloading pleasure. If you want to compile them yourself, I’ll let you know what I did at the end of this article.

Before we start the compilation, we are going to need a Nagios user and group set up on the system. You can do this in what ever way you want, using NetInfo, System Preferences, or Workgroup Manager. Just make sure to make the nagios user as minimal as possible. Give it no home directory, no shell and make the password just “*". Then make the nagios group and put the nagios user into it.

Also we need to make a home for Nagios:

sudo mkdir /usr/local/nagios

Now go out and grab the application itself:

curl -O http://telia.dl.sourceforge.net/sourceforge/nagios/nagios-1.0b5.tar.gz
gnutar -xzvf nagios-1.0b5.tar.gz
cd nagios-1.0b5

The next step is to configure the application. Since I run my own DNS and my own Web server, I like to create a domain specifically for the application (such as monitor.afp548.com). The configuration options that we are going to use will reflect that. Read the documentation if you need it set up a different way.

./configure --prefix=/usr/local/nagios --with-cgiurl=/Library/Webserver/CGI-Executables --with-htmurl=/
make all
sudo make install
sudo make install-commandmode
sudo make install-config
cd ..

Now download the plug-ins from us.

curl -O http://idisk.mac.com/atropos/Public/Nagios/plugs.tgz
gnutar -xzvf plugs.tgz
sudo mv libexec /usr/local/nagios/

Now to tidy up a few things.

sudo cp /usr/local/nagios/sbin/* /Library/Webserver/CGI-Executables/

Also you’ll want to create a new site for your Web server. Make sure that CGIs are enabled and point the site to /usr/local/nagios/share.

You’re done with the installation—that was the easy part. Configuring Nagios the first time can be daunting. You can either dive into it now with help from the Nagios site, or wait for part two of our series where we’ll give you a hand with making it all work.


Notes for those who want to compile their own plug-ins package

The installation is fairly straightforward, with the exception of two things:

(1) The package didn’t like the automake that came with 10.2, so I installed the latest version to get around this:

curl -O http://ftp.gnu.org/gnu/automake/automake-1.6.3.tar.gz
gnutar -xzvf automake-1.6.3.tar.gz
./configure
make
sudo make install
cd ..
rehash

(2) There were a few problems with the libraries. You’ll need to update the table of contents for two of them, libgetopt.a and libsnprintf.a, so change into the “plugins” directory of the plug-ins source:

sudo ranlib libgetopt.a
sudo ranlib libsnprintf.a

You’re not done yet. Two plug-ins don’t install: check_procs.c and check_vsz.c don’t work. You’ll need to get rid of all references to them in the main makefile and the makefile inside the “plugins” directory.

After all that it should be fairly simple:

./configure
make
sudo make install