NConf on Ubuntu

NConf is a PHP based web-tool for configuring the Nagios monitoring software. It differs from similar tools by offering enterprise-class features like templates, dependencies and the ability to configure a large-scale, distributed Nagios server topology. It is mainly targeted at sysadmins, who already know Nagios, but are looking for a more convenient way of managing their configuration files.

Main features

  • effortlessly maintain a distributed Nagios topology
  • user-friendly web-GUI
  • host & service templates
  • graphical dependency viewer
  • multiple authentication modes
  • Nagios config importer
  • CSV file importer
  • perl database API
  • data schema customizable and expandable
  • runs on Linux / Apache / PHP / MySQL

Installing Dependencies

apt-get install apache2 php5 php5-mysql mysql-server perl libdbi-perl libdbd-mysql-perl gawk
/etc/init.d/apache2 restart

Download NConf & Extracting it to Web Directory

mkdir ~/downloads
cd ~/downloads
wget http://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz
cd /var/www
tar zxvf ~/downloads/nconf-1.2.6-0.tgz
cd /var/www/nconf
chown www-data config output static_cfg temp
chmod 777 /usr/local/nagios/bin/nagios

Creating database for NConf in MySQL

mysql -u root -p
mysql>create database nconf;
mysql>grant all on nconf.* to nconf@localhost identified by 'nconf';

Start Installation by typing http://localhost/nconf in your web browser
Click on click here to start the installation.

At the next screen NConf will check pre-installation dependencies. If NConf find any missing dependencies, installaer will not start the setup process. Click on Next button to go further.

Give your MySQL database details. In our setup
DBHOST = localhost
DBNAME = nconf
DBUSER = nconf
DBPASS = nconf

Click Next to go further

In General configuration
NCONFDIR = /var/www/nconf
NAGIOS_BIN = /usr/local/nagios/bin/nagios
TEMPLATE_DIR = nconf_fresh

In Authentication configuration, We are disabling authentication.

If everything goes well you will get Finish screen without any error. Don’t click on Finish button after getting this screen please run below commands and then click on finish button.

cd /var/www/nconf/
rm -rf INSTALL INSTALL.php UPDATE UPDATE.php

Once installed you can add host via the main contol panel.

After adding host click on Generate Nagios config. It will genrate config files in /var/www/nconf/output.

To apply Nconf configuration first we need to copy NConf files to Nagios directory and also make it’s entry in nagios.cfg
Following script will rename the existing .cfg to with cfg.bak and add new cfg files location in nagios.cfg
Create a file name nconf_nagios.sh in /root and copy following lines in it

#!/bin/bash
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
#renaming existing files in /usr/local/nagios/etc/objects from .cfg to .cfg.bak
cd /usr/local/nagios/etc/objects
ORIGINAL=`ls -l | grep -v "total" | gawk '{ print $NF }'`
for BACKUP in $ORIGINAL
	do
        mv $BACKUP $BACKUP.bak
	done
chown nagios:nagios /usr/local/nagios/etc/objects/*
chmod 644 /usr/local/nagios/etc/objects/*
#Copying new .cfg files to /usr/local/nagios/etc/objects/
cd /var/www/nconf/output
rm -rf global Default_collector
tar zxvf NagiosConfig.tgz
cp -av /var/www/nconf/output/global/* /usr/local/nagios/etc/objects/
cp -av /var/www/nconf/output/Default_collector/* /usr/local/nagios/etc/objects/
chown nagios:nagios /usr/local/nagios/etc/objects/*
chmod 644 /usr/local/nagios/etc/objects/*
#Adding new cfg files entry in /usr/local/nagios/etc/nagios.cfg
sed -i 's/^cfg_file=/#cfg_file=/g' /usr/local/nagios/etc/nagios.cfg
ls -l /usr/local/nagios/etc/objects/ | grep -v "total" | gawk '{ print $NF}' | grep -v "bak" | sed 's/^/cfg_file=\/usr\/local\/nagios\/etc\/objects\//g' >> /usr/local/nagios/etc/nagios.cfg

Now run the script

chmod 777 /root/nconf_nagios.sh
/root/nconf_nagios.sh

Now our NConf and Nagios are working fine. Next time whenever you update or add any host/service in NConf run following script to apply the changes in Nagios. We are naming the script as nconf_update.sh. The script is in /root folder.

#!/bin/bash
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
#Copying files from Nconf output directory to Nagios objects directory
cd /var/www/nconf/output
rm -rf global Default_collector
tar zxvf NagiosConfig.tgz
mv /var/www/nconf/output/global/* /usr/local/nagios/etc/objects/
mv /var/www/nconf/output/Default_collector/* /usr/local/nagios/etc/objects/
chown nagios:nagios /usr/local/nagios/etc/objects/*
chmod 644 /usr/local/nagios/etc/objects/*
/etc/init.d/nagios restart

To run the script

chmod 777 /root/nconf_update.sh
/root/nconf_update.sh

How to Snort on CentOS 64-bit

Snort® is an open source network intrusion prevention and detection system (IDS/IPS) developed by Sourcefire.

Pre-requisites Softwares

Mysql
mysql-bench
mysql-server
mysql-devel
mysqlclient10 (more…)

NETFLOW to Monitor Traffic at Cisco Router

By default Cisco IOS doesn’t provide any traffic monitoring tools like iftop or iptraff available in Linux. While there are lots of proprietary solutions for this purpose including Cisco Netflow Collection, you are free to choose nfdump and nfsen open source software to monitor traffic of one or many Cisco routers and get detailed monitoring data through your Linux command line or as graphs at absolutely no cost. (more…)

Nagios on Ubuntu

Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.
Nagios monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. In the event of a failure, Nagios can alert technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers. With Nagios you’ll never be left having to explain why a unseen infrastructure outage hurt your organization’s bottom line. (more…)

Page 2 of 2«12
rss twitter facbook

Categories

Archives