cuongk6t's Blog

How they do that – step by step

NagiosQL

leave a comment »


(Centos 5.4 _ 5.5)
source :

http://aaronwalrath.wordpress.com/2010/02/28/installing-nagiosql-3-on-centos-linux-5-4/
http://fabux.wordpress.com/2009/04/22/nagios-and-nagiosql-integration-part-i/

NAGIOSQL

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:

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


Now install the HTML_Template_IT Pear module:


Code:
shell# pear install HTML_Template_IT


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


Code:
shell# tar zxvf nagiosql303.tar.gz


Rename the extracted directory for simplicity:


Code:
shell# mv nagiosql3 nagiosql


Now move the directory to the webroot


Code:
shell# mv nagiosql /var/www/html/


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


Code:
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:


Citation:
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:


Citation:
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:


Code:
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:


Code:
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:


Code:
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):


Code:
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:


Code:
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:


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

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

nagiosql12

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

nagiosql22

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

nagiosql32

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


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

nagiosql42

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

nagiosql52

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

nagiosql62

Click Data Import under Tools:

http://aaronwalrath.files.wordpress.com/2010/02/nagiosql72.png

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

nagiosql82

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!

About these ads

Written by cuongk6t

09/06/2011 at 2:42 pm

Posted in Nagios Tutorial

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: