trtsandbx01: Nagios

Hardware:
Software: Nagios, Nagios Plugins(fping, perl-Net-SNMP + deps), Navoula
Configuration:
IP: DHCP 255.255.255.0 192.168.2.1
Hostname: trtsandbx01.localnet

upgrade all rpms via yum:
yum update
yum upgrade

install/configure apt:
wget http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.3.4-1...
http://dag.wieers.com/packages/apt/apt-0.5.15lorg3.1-4.el4.rf.i386.rpm
rpm -Uhv rpmforge-release-0.3.4-1.el4.rf.i386.rpm apt-0.5.15lorg3.1-4.el4.rf.i386.rpm
apt-get update
apt-get upgrade

install nagios:
apt-get install nagios nagios-nrpe nagios-plugins nagios-plugins-nrpe
yum install perl-Net-SNMP net-snmp-utils

edit nagios confs:
vi /etc/nagios/nagios.cfg and comment all “cfg_file=/xxx/xxx/xxx/xx.cfg”’s except “cfg_file=/etc/nagios/minimal.cfg”

vi /etc/nagios/nagios.cfg and change to match the following line
check_external_commands=1

vi /etc/nagios/cgi.cfg and configure cgi rules to allow your htaccess users(also enable nagios check command)

create htaccess.users:
htpasswd -c /etc/nagios/htpasswd.users admin
htpasswd /etc/nagios/htpasswd.users jengstro

create .htaccess:
vi /usr/share/nagios/.htaccess
AuthType Basic
AuthName Restricted Files
AuthUserFile /etc/nagios/htpasswd.users
Require valid-user

install Navolua:
download Navolua from
http://www.nagiosexchange.org/Image_Packs.75.0.html?&tx_netnagext_pi1[p_view]=252&tx_netnagext_pi1[page]=10%3A10

unpack
tar -xzvf nagios-nuvola-1.0.3.tar.gz

backup /usr/share/nagios
cp -R /usr/share/nagios/ /usr/share/nagios_org

move contents of Navolua html folder and subfolders to /usr/share/nagios (overwrite all)
cp -R –reply=yes html/* /usr/share/nagios

vi /usr/share/nagios/config.js and modify the following line…
//var nagiosQLpath = “/nagiosQL/”;

change it to…
var nagiosQLpath = “http://trtmon01.crucial-solutions.com/nagiosQL/”;

install NagiosQL:
download NagiosQL from http://www.nagiosql.org

MYSQL Server
yum install mysql-server
yum install phpmysql
/etc/init.d/mysqld start

mysql -u root mysql
set password for root@localhost = password(’N4g105′);
flush privileges;
exit

PEAR
pear install HTML_Template_IT
cp -R /usr/share/pear/HTML/ /usr/lib/php4

Files
Unpack the lastest nagiosql-xxx.tar.gz into your webserver’s root, a subdirectory “nagiosQL” will be created:
cd /var/www/html/
cp nagiosql-xxx.tar.gz /var/www/html/
tar zxvf nagiosql-xxx.tar.gz

Database
Create the MySQL database:
cd /var/www/html/nagiosQL/config
mysql -u root -p < nagiosql_41.sql
Password: N4g105

It is very important to set a new password for the user:
mysql -u root -p
Password: xxxx
use mysql;
UPDATE user SET Password=PASSWORD("nagiosqlpw") WHERE User="nagiosqlusr";
FLUSH PRIVILEGES;
exit

/etc/init.d/mysqld restart

Webserver settings
The webserver directory for nagiosQL must be set up that .htaccess files are read and interpreted.
vi /etc/httpd/conf/httpd.conf and add...

AllowOverride All

Nagios configuration structure
The configuration directories must have the following structure:
cd /etc/nagios/
mkdir hosts
mkdir services
mkdir backup
mkdir backup/hosts
mkdir backup/services

Nagios settings
Modify settings.ini (vi /var/www/html/nagiosQL/config/settings.ini) and change only the lines noted

here…
physical = /var/www/html/nagiosQL/
username = nagiosqlusr
password = nagiosqlpw
lang = lang_en.ini
binary = “/usr/bin/nagios”
cmdfile = “/var/log/nagios/rw/nagios.cmd”

Modify nagios.cfg…
vi /etc/nagios/nagios.cfg
#cfg_file=/etc/nagios/minimal.cfg
cfg_file=/etc/nagios/checkcommands.cfg
cfg_file=/etc/nagios/misccommands.cfg
cfg_file=/etc/nagios/contactgroups.cfg
cfg_file=/etc/nagios/contacts.cfg
cfg_file=/etc/nagios/timeperiods.cfg
cfg_file=/etc/nagios/hostgroups.cfg
cfg_file=/etc/nagios/servicegroups.cfg
#cfg_file=/etc/nagios/servicedependencies.cfg
#cfg_file=/etc/nagios/serviceescalations.cfg
#cfg_file=/etc/nagios/hostdependencies.cfg
#cfg_file=/etc/nagios/hostescalations.cfg
#cfg_file=/etc/nagios/hostextinfo.cfg
#cfg_file=/etc/nagios/serviceextinfo.cfg
cfg_dir=/etc/nagios/hosts
cfg_dir=/etc/nagios/services

Make sure the above files exsist before continuing on…
touch contactgroups.cfg
touch contacts.cfg
touch timeperiods.cfg
touch hostgroups.cfg
touch servicegroups.cfg

Rights
As configuration directory is used /etc/nagios:
chmod 6755 /etc/nagios
chown apache.nagios /etc/nagios
chmod 6755 /etc/nagios/hosts
chown apache.nagios /etc/nagios/hosts
chmod 6755 /etc/nagios/services
chown apache.nagios /etc/nagios/services
chmod 6755 /etc/nagios/backup
chown apache.nagios /etc/nagios/backup
chmod 6755 /etc/nagios/backup/hosts
chown apache.nagios /etc/nagios/backup/hosts
chmod 6755 /etc/nagios/backup/services
chown apache.nagios /etc/nagios/backup/services
chmod 644 /etc/nagios/*.cfg
chown apache.nagios /etc/nagios/*.cfg
chmod 644 /etc/nagios/hosts/*.cfg
chown apache.nagios /etc/nagios/hosts/*.cfg
chmod 644 /etc/nagios/services/*.cfg
chown apache.nagios /etc/nagios/services/*.cfg

Also the Nagios binary must be allowed to be execute by the web server user:
chown nagios.apache /usr/bin/nagios
chmod 750 /usr/bin/nagios

start applications:
/etc/init.d/httpd start
/etc/init.d/nagios start
/etc/init.d/nrpe start

set applications to start on boot:
chkconfig httpd on
chkconfig nagios on
chkconfig nrpe on
chkconfig mysqld on

view web interface(username and password from htpasswd step above required):
http://trtsandbx01.localnet/nagios

Last the web server user must be allowed to write to the Nagios commandfile:
chown nagios.apache /var/log/nagios/rw/nagios.cmd
chmod 660 /var/log/nagios/rw/nagios.cmd

chown -R apache /var/www/html/nagiosQL/

Using
Now you can start NagiosQL 2005 with any browser you want:
http://trtsandbx01.localnet/nagiosQL/index.php

Requirements for the browser:
* Javascript accepted
* Cookies accepted

The first login can be done with the following user:
Username: admin
Password: N4g105