cuongk6t's Blog

How they do that – step by step

How to install NagiosQL

with one comment



How to install NagiosQL

June 2, 2011 by techmajha (online) · Leave a Comment
Filed under: server services
 

NagiosQL is a web frontend for Nagios and Icinga.
It helps you to easily build a complex configuration with all options.
While installing NagiosQL we will learn to install/upgrade other depenedencies as well.

Main features of NagiosQL:

create, delete, modify and copy settings
create and export configuration files
create and download configuration files
easy configuration import
auto backup configuration files
consistency checks
syntax verification
user management
instant activation of new configs
many translations
easy Installation wizard
MySQL database platform

Prerequisites for NagiosQL:

NagiosQL-Requirement1[1]

The basic requirements are:

PHP 5.2.0 or greater including:
PHP Module: Session
PHP Module: MySQL
PHP Module: gettext
PHP Module: filter
PHP Module: XML
PHP Module: SimpleXML
PHP Module: FTP (optional)
PHP Module: curl (optional)
PECL Extension: SSH (optional)
php.ini options:
file_uploads on (for upload features)
session.auto_start needs to be off
A MySQL database server
Nagios 2.x/3.x or Icinga 1.x

We will start with installing dependencies for NagiosQL


# yum –y install mysql php php-mysql php-pear
# pear install HTML_Template_IT

NagiosQL : Download and extract


# cd /downloads/
# wget http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.1.1/nagiosql_311.tar.gz
# tar xvzf nagiosql_311.tar.gz
# mv nagiosql /var/www/html/

Configuration
Directory Structure:

It is recommended to have the following directory structure :

/etc/nagiosql/ -> Common configuration files
” /hosts -> Host configuration files
” /services -> Service configuration files
” /backup/ -> Backups of the common configuration files
” ” /hosts -> Backups of the host configuration files
” ” /services -> Backups of the service configuration files

So, we will create these directories to hold the configuration files generated by NagiosQL:


# mkdir /etc/nagiosql
# mkdir /etc/nagiosql/hosts
# mkdir /etc/nagiosql/services
# mkdir /etc/nagiosql/backup
# mkdir /etc/nagiosql/backup/hosts
# 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:


# vi /usr/local/nagios/etc/nagios.cfg
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

And optional:


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:


# chgrp nagios /etc/nagios
# chgrp nagios /etc/nagios/nagios.cfg
# chgrp nagios /etc/nagios/cgi.cfg
# chmod 775 /etc/nagios
# chmod 664 /etc/nagios/nagios.cfg
# chmod 664 /etc/nagios/cgi.cfg

NagiosQL Configuration folders:


# chgrp nagios /etc/nagios
# chgrp nagios /etc/nagios/nagios.cfg
# chgrp nagios /etc/nagios/cgi.cfg
# chmod 775 /etc/nagios
# chmod 664 /etc/nagios/nagios.cfg
# chmod 664 /etc/nagios/cgi.cfg
# chmod 6755 /etc/nagiosql
# chown apache.nagios /etc/nagiosql
# chmod 6755 /etc/nagiosql/hosts
# chown apache.nagios /etc/nagiosql/hosts
# chmod 6755 /etc/nagiosql/services
# chown apache.nagios /etc/nagiosql/services
# chmod 6755 /etc/nagiosql/backup
# chown apache.nagios /etc/nagiosql/backup
# chmod 6755 /etc/nagiosql/backup/hosts
# chown apache.nagios /etc/nagiosql/backup/hosts
# chmod 6755 /etc/nagiosql/backup/services
# chown apache.nagios /etc/nagiosql/backup/services

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


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

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


# chown apache.nagios /var/www/html/nagiosql/config

Now, we will start with GUI installation phase, open any browser and hit URL : {IP Address}/nagiosql

NagiosQL_1-300x240

I got error as shown in following image:

NagiosQL-installation-errors-300x240

Following steps are taken by me to resolve it:

For date.timezone settings Add following line:


# vi /etc/php.ini
date.timezone =Asia/Calcutta

Installing the SSH2 PHP extension on CentOS is actually pretty simple. Although it isn’t available through yum install.


# yum install gcc php-devel php-pear libssh2 libssh2-devel
# pecl install -f ssh2
# echo extension=ssh2.so >> /etc/php.ini
# vi /etc/php.ini
And verify whether extension=ssh2.so exist there.

Restart httpd
# /etc/init.d/httpd restart

# php -m | grep ssh2
ssh2

How to upgrade php 5.1.6 to php 5.3.6
Till now I had been working on php 5.1.6, but nagiosql requires php 5.2.0 or higher, so we will upgrade using remi yum repository.


# su -
# cd /etc/yum.repos.d
# wget http://rpms.famillecollet.com/enterprise/remi.repo

I tried to update php using following command, but it failed.
# yum update php php-* mysql-* --enablerepo=remi
# service restart httpd
# service restart mysql

Then, I tried to remove and install php using following 2 commands but I got error of conflicts for php-pear:
# yum remove php* mysql*
# yum install php php-* mysql-* --skip-broken

file /usr/share/pear/test/Date/tests/testunit_date.php conflicts between attem pted installs of php-pear-Date-1.4.7-7.el5.remi.noarch and php-pear-date-1.4.6-1 .el5.rf.noarch
file /usr/share/pear/test/Date/tests/testunit_date_span.php conflicts between attempted installs of php-pear-Date-1.4.7-7.el5.remi.noarch and php-pear-date-1. 4.6-1.el5.rf.noarch

Then I tried to remove and install php, php-pear individually and it worked.
# yum remove php-pear
# yum install php php-pear
# php -v
PHP 5.3.6 (cli) (built: May 16 2011 19:18:00)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

Then, I decided to entirely remove group "Web Server" and reinstall it, during all this process I observed that the yum installer downloaded files from remi repositories.
# yum -y groupremove "Web Server"
# yum -y groupinstall "Web Server"
# yum groupinstall 'MySQL Database'
# /usr/bin/mysql_secure_installation
# service restart httpd
# service restart mysql

NagiosQL_2-300x240

NagiosQL_3-300x240

NagiosQL_4-300x240

NagiosQL_5-300x240

As you can see I started getting Error : Table ‘mysql.servers’ doesn’t exist

You may receive a “Table ‘mysql.servers’ doesn’t exist” error message while adding a database user.
This problem mostly occurs after unpgrading Mysql server from an older to a newer version and the upgrade remains incomplete.

To overcome this problem, you need to run mysql_upgrade -u root -p command so that mysql database is updated with the latest contents thus fixing the privileges of the database users as well.


# mysql_upgrade -u root -p
# /usr/bin/mysql_secure_installation
# service mysqld start

NagiosQL_6-300x240

NagiosQL_7-300x240

Login credentials set by me:
username : admin
password : admin

 

6/2011 – cuongk6t

Written by cuongk6t

07/06/2011 at 5:21 pm

Posted in Nagios Tutorial

Tagged with ,

One Response

Subscribe to comments with RSS.


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

%d bloggers like this: