Home > Linux, Monitoring > Installing NagiosQL 3 on CentOS Linux 5.4

Installing NagiosQL 3 on CentOS Linux 5.4

NagiosQL is a web front end for simplifying the set up of the configuration files for Nagios.  In this guide I will only be installing NagiosQL.  If you also need to install Nagios, an excellent guide to use for installing from source can be found at http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html.  Generally I prefer to install using an RPM package from a Yum repository, but I have not yet found a repository that contains the Nagios 3 package for CentOS/Red Hat.

First install the MySQL and PHP packages needed to support NagiosQL.  I am reinstalling, so hopefully the packages I’ve listed will pick up everything that is required:

shell# yum install mysql php php-mysql php-pear

Now install the HTML_Template_IT Pear module:

shell# pear install HTML_Template_IT

Download the NagiosQL archive from http://sourceforge.net/projects/nagiosql/, then extract the program files:

shell# tar zxvf nagiosql303.tar.gz

Rename the extracted directory for simplicity:

shell# mv nagiosql3 nagiosql

Now move the directory to the webroot

shell# mv nagiosql /var/www/html/

We need to set up new directories to hold the configuration files generated by NagiosQL:

shell# mkdir /etc/nagiosql
shell# mkdir /etc/nagiosql/hosts
shell# mkdir /etc/nagiosql/services
shell# mkdir /etc/nagiosql/backup
shell# mkdir /etc/nagiosql/backup/hosts
shell# mkdir /etc/nagiosql/backup/services

Next we’ll modify the main Nagios configuration file /usr/local/nagios/etc/nagios.cfg and add the following lines to tell Nagios where to look for our new configurations files generated by NagiosQL.  Before proceeding you may want to comment out the existing cfg_file and cfg_dir entries in the object configuration section of this file to simplify things and exclusively use the configuration files generated by NagiosQL.

Adding these lines to /usr/local/nagios/etc/nagios.cfg is required:

cfg_file=/etc/nagiosql/contacttemplates.cfg
cfg_file=/etc/nagiosql/contactgroups.cfg
cfg_file=/etc/nagiosql/contacts.cfg
cfg_file=/etc/nagiosql/timeperiods.cfg
cfg_file=/etc/nagiosql/commands.cfg
cfg_file=/etc/nagiosql/hostgroups.cfg
cfg_file=/etc/nagiosql/servicegroups.cfg
cfg_dir=/etc/nagiosql/hosts
cfg_dir=/etc/nagiosql/services

Optionally specify these lines as well:

cfg_file=/etc/nagiosql/hosttemplates.cfg
cfg_file=/etc/nagiosql/servicetemplates.cfg
cfg_file=/etc/nagiosql/servicedependencies.cfg
cfg_file=/etc/nagiosql/serviceescalations.cfg
cfg_file=/etc/nagiosql/hostdependencies.cfg
cfg_file=/etc/nagiosql/hostescalations.cfg
cfg_file=/etc/nagiosql/hostextinfo.cfg
cfg_file=/etc/nagiosql/serviceextinfo.cfg

Now let’s modify the permissions on several files and directories to ensure that Nagios will work correctly with our new configuration file structure.

Nagios main configuration files:

shell# ln -s /usr/local/nagios /etc/nagios
shell# chgrp nagios /etc/nagios
shell# chgrp nagios /etc/nagios/nagios.cfg
shell# chgrp nagios /etc/nagios/cgi.cfg
shell# chmod 775 /etc/nagios
shell# chmod 664 /etc/nagios/nagios.cfg
shell# chmod 664 /etc/nagios/cgi.cfg

NagiosQL generated configuration files:

shell# chmod 6755 /etc/nagiosql
shell# chown apache.nagios /etc/nagiosql
shell# chmod 6755 /etc/nagiosql/hosts
shell# chown apache.nagios /etc/nagiosql/hosts
shell# chmod 6755 /etc/nagiosql/services
shell# chown apache.nagios /etc/nagiosql/services
shell# chmod 6755 /etc/nagiosql/backup
shell# chown apache.nagios /etc/nagiosql/backup
shell# chmod 6755 /etc/nagiosql/backup/hosts
shell# chown apache.nagios /etc/nagiosql/backup/hosts
shell# chmod 6755 /etc/nagiosql/backup/services
shell# chown apache.nagios /etc/nagiosql/backup/services

Let’s ensure that the Nagios is executable by the Apache group:

shell# chown nagios.apache /usr/local/nagios/bin/nagios
shell# chmod 750 /usr/local/nagios/bin/nagios

Run the preflight check to verify that there are no errors in the nagios.cfg file (will not work until configuration files are created from NagiosQL):

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

We need to create a file in the NagiosQL install directory to allow us to proceed to the web based portion of the install:

shell# touch /var/www/html/nagiosql/install/ENABLE_INSTALLER

Also the Apache user needs write permissions to the nagiosql/config directory to write a settings file:

shell# chown apache /var/www/html/nagiosql/config

Now we point our browser to http://OurServer/nagiosql and are presented with this screen:

The installer will verify our environment and make sure everything is in order:

Now we need to enter our configuration information for server, database, users, and passwords:

We will now be informed that we need to delete the nagiosql/install directory to finish the installation, so back on the console:

shell# rm -rf /var/www/html/nagiosql/install

Log in to the web application by entering the admin password you specified earlier:

Now we’ll import the nagios commands configuration file, click Tools on the left:

Click Data Import under Tools:

In the Import file text box, highlight /etc/nagios/objects/commands.cfg and click Import.

At the bottom of the page it should display that records were successfully inserted.  In the Import file text box, highlight /etc/nagios/objects/timeperiods.cfg and click Import.

I have generally had the best success importing only these two configuration files and then manually adding my hosts and services in NagiosQL.  Good luck monitoring!

References:

http://fabux.wordpress.com/2009/04/22/nagios-and-nagiosql-integration-part-i/

Categories: Linux, Monitoring Tags: ,
  1. Ali
    July 5, 2012 at 7:55 am

    hell# ln -s /usr/local/nagios /etc/nagios

    why we do this our installed directory is /etcnagios then why we create link between these two files?

  2. vladan
    February 22, 2013 at 12:43 pm

    Hello,
    I am installing this for the first time and i did everything to editing nagios.cfg but i can’t find nagios,cfg file .Like it’s not created. Did I missed something ?/? Does someone have an idea ?

  1. March 21, 2011 at 1:57 am
  2. April 15, 2011 at 8:45 pm

Leave a comment