Nagios installation on OpenSuse

This is the second post in the series on Nagios. In the first post, I explained what Nagios is.

This post goes through the installation and initial configuration. The third post in the series covers writing custom monitoring scripts; Finally a fourth post covers creating event handlers.

So here goes with the installation and configuration!

Before installing nagios we need to make sure the server has the following prerequisite packages installed:

C/C++ development libraries

Download Nagios from

Click on the Get Nagios Core link

Download the latest stable release as a .tar.gz file and place it on the server, in a suitable directory, e.g. /tmp

For the purposes of this guide, I will download version 3.3.1

NOTE: The rest of the installation will continue as the root user.

Extract the file:

#> cd /tmp
#> tar -xvzf nagios-3.3.1.tar.gz

Enter the nagios directory:

#> cd nagios

Create a nagios user:

#> /usr/sbin/useradd -m nagios

#> passwd nagios

And a nagios group:

#> /usr/sbin/groupadd nagios
#> /usr/sbin/usermod -G nagios nagios

Now create a group nagcmd for allowing external commands to be submitted through the web interface, along with adding both the nagios user and the apache user to it:

#> /usr/sbin/groupadd nagcmd
#> /usr/sbin/usermod -G nagcmd,nagios nagios
#> /usr/sbin/usermod -G nagcmd wwwrun

Compile and install nagios:

Run the configure command passing the command group (nagcmd):

#> ./configure --with-command-group=nagcmd

When this returns with no errors, compile the source code:

#> make all

Then install the binaries, init script, sample config files and set permissions on the external command directory:

#> make install
#> make install-init
#> make install-config
#> make install-commandmode

You will now see that nagios has been installed under /usr/local/nagios and sample configuration files exist under the etc directory.

Edit the /usr/local/nagios/etc/objects/contacts.cfg file, changing the email parameter under the nagiosadmin contact to be your email address

We will now configure the web interface, so install the nagios web config into the apache conf.d directory:

#> make install-webconf

Now create a nagiosadmin account for logging into the website. Remember the password you assign to this account!

#> htpasswd2 -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

And restart apache for the changes to take place:

#> service apache2 restart

Now install the nagios plugins. Download these from the nagios website, selecting Download then Get Nagios Plugins. Download the latest stable release, here we will install version 1.4.15

#> cd /tmp
#> tar -xvzf nagios-plugins-1.4.15.tar.gz

Configure and install the plugins:

#> cd nagios-plugins-1.4.15
#> ./configure --with-nagios-user=nagios --with-nagios-group=nagios
#> make
#> make install

Now start nagios. First add the service so that it starts when the server boots:

#> chkconfig --add nagios
#> chkconfig nagios on

Make sure the configuration files are sane:

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

This should return no errors, so start the service:

#> service nagios start

Now point your web browser at the nagios screen:


You should be asked for a username and password, enter nagiosadmin for the username, and the password you entered earlier as the password. Click on OK

You should then be presented with the main nagios screen.

Click on Hosts on the left, the right hand pane should then show the localhost. Click on localhost and then click on View Status Detail for this host.

This will show you all the configured checks and after a few minutes they should all come back in green indicating a successful check.

I then like to extend nagios, by making it keep a copy of all checks and their results in a database, such as MySQL. This can then be integrated into another application, or be used with adhoc queries to find out service history over a period of time. To do this we will install ndoutils.

Get this from the nagios page,

Click on Download, Get Nagios Addons, NDOUtils and then download the latest version. Here I will use version 1.5 against a MySQL database.

#> cd /tmp
#> tar -xvzf ndoutils-1.5.tar.gz
#> cd ndoutils-1.5

Now install the mysql packages:


Start the mysql database:

#> service mysql start

Then define the root password:

#> mysqladmin -u root password 'new-password'

Now install ndoutils:

#> ./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagcmd
#> make

There is no make install, so we have to copy some files manually:

#> cd src
#> cp ndomod-3x.o ndo2db-3x file2sock log2ndo /usr/local/nagios/bin
#> cd ../config
#> cp ndo2db.cfg-sample ndo2db.cfg
#> cp ndomod.cfg-sample ndomod.cfg
#> cp ndo2db.cfg ndomod.cfg /usr/local/nagios/etc

And change the permissions:

#> chmod 744 /usr/local/nagios/bin/ndo*
#> chown nagios:nagios /usr/local/nagios/etc/ndo*

Now create the nagios database:

#> mysql -u root -p mysql
mysql> create database nagios;
mysql> grant all on nagios.* to nagios@localhost identified by "nagios";
msqyl> exit;

Now run the database installation script:

#> cd /tmp/ndoutils-1.5/db
#> chmod +x installdb
#> ./installdb -u nagios -p nagios -h localhost -d nagios

Now we need to edit the /usr/local/nagios/etc/nagios.cfg adding the lines:

broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg

Edit the ndo2db.cfg file in the /usr/local/nagios/etc directory, changing the settings for db_name, prefix, username and password.

Stop the nagios service, then start ndoutils followed by nagios:

#> service nagios stop
#> /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg

Then restart nagios:

#> service nagios start

You should now have a working nagios system with checks being written to the mysql database. Stay tuned for the next installment in this series!

If you have found this article useful, please consider making a microdonation.

Matthew Harman

Matthew’s day job sees him running the Oracle and Server Team for the European side of a multi-national Automotive Outsourcing company headquartered in Warren, Michigan.

Matthew is a keen open-source advocate and is always keen to help others, through blogging, etc..

Matthew is always keen to connect via linkedin with similar minded professionals.


All rights reserved ©

3 Responses to Nagios installation on OpenSuse

  1. Pingback: Prevention is better than cure | Tuxers

  2. Pingback: Writing custom nagios check scripts (plugins) | Tuxers

  3. In my case the graphic components were missing and I had to recompile them with
    ./configure;make; make cgis;make install-cgis
    It generates cgi code for Map, Trends and Histogram.

Leave a Reply

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


6 − 3 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">