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

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 |
Related content:

You rock! I have subscribed to your RSS feed. Cheers.