Tested on
OS: CentOS 5.6 i386, CentOS 5.7 i386, CentOS 5.7 x86_64
Nagios: version 3.3.1
Nconf: 1.3
About
Nconf is a configuration application for Nagios. It helps you generate Nagios configuration files and then use it on your Nagios system.
Nconf Requirements
- Install Nconf prerequisites packages
yum install mysql-server perl-DBI perl-DBD-MySQL php-mysql sudo -y
- Configure mysql-server to run at startup and start it
chkconfig mysqld on service mysqld start
- Restart apache
service httpd restart
Nconf installation
- Download Nconf and extract Nconf
cd /usr/local/src/nagios wget https://sourceforge.net/projects/nconf/files/nconf/1.3.0-0/nconf-1.3.0-0.tgz -O nconf.tgz tar zxvf nconf.tgz
- Move Nconf extracted folder to /usr/local/nagios/share
mv nconf /usr/local/nagios/share/nconf
- Give permission to the webserver user on nconf folder
chown -R apache:apache /usr/local/nagios/share/nconf
- Give execute permission to nconf/bin/* files
chmod 775 /usr/local/nagios/share/nconf/bin/*
- Create database for Nconf
mysqladmin create nconf
- Create a user to access the database, grant the appropriate privileges
- Enter mysql console
mysql
- In mysql console grant permission to your nconf user
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON nconf.* TO 'nconf'@'localhost' IDENTIFIED BY 'nconf'; q;
- Start interactive installation process by browsing to https://nconf_server_ip/nagios/nconf/INSTALL.php
- Welcome to NConf setup – This page will check if your computer have all Nconf requirements installed -> Click Next if all OK
- MySQL database configuration – In this page you will need to enter Nconf DB host, DB name, DB user and DB password you set earlier -> Click Next when you finish -> Click Next again if all OK
- General configuration – In this page Nconf need to set the right path of Nconf install dir and Nagios binary -> Click Next
- Authentication configuration – Allows you to active basic authentication. Since I put nconf in Nagios share folder I am already using Nagios authentication so I disable Nconf authentication -> Click Next
- Check if config files are present – Give a summary report of the installation. In this step you need to go back to the Nconf server shell and remove the following files and directories: INSTALL, INSTALL.php, UPDATE, UPDATE.php -> Click finish
cd /usr/local/nagios/share/nconf rm -rf INSTALL INSTALL.php UPDATE UPDATE.php
- Create symbolic link for Nagios bin file
ln -s /usr/local/nagios/bin/nagios /usr/local/nagios/share/nconf/bin/nagios
Configure Nagios to work with Nconf
Nconf installation completed now we will configure Nagios to work with Nconf generated files and create a configuration that will apply Nconf changes.
- Open Nagios configuration file, comment out all Nagios default configuration files and add Nconf configuration directories
vi /usr/local/nagios/etc/nagios.cfg
… # You can specify individual object config files as shown below: #cfg_file=/usr/local/nagios/etc/objects/commands.cfg #cfg_file=/usr/local/nagios/etc/objects/contacts.cfg #cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg #cfg_file=/usr/local/nagios/etc/objects/templates.cfg # Definitions for monitoring the local (Linux) host #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg # Definitions for monitoring a Windows machine #cfg_file=/usr/local/nagios/etc/objects/windows.cfg # Definitions for monitoring a router/switch #cfg_file=/usr/local/nagios/etc/objects/switch.cfg # Definitions for monitoring a network printer #cfg_file=/usr/local/nagios/etc/objects/printer.cfg # You can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below: cfg_dir=/usr/local/nagios/etc/global cfg_dir=/usr/local/nagios/etc/Default_collector …
- Create deployment configuration for Nconf generated files
vi /usr/local/nagios/share/nconf/config/deployment.ini
... ;; LOCAL deployment ;; [deploy config] type = local source_file = "/usr/local/nagios/share/nconf/output/NagiosConfig.tgz" target_file = "/usr/local/nagios/etc/" action = extract reload_command = sudo -u nagios /etc/init.d/nagios reload ...
- Add nagios reload command to apache user and remove the default reuiqre tty setting in sudo configuration file
visudo
... #Defaults requiretty ... apache ALL = (nagios) NOPASSWD: /etc/init.d/nagios reload
- Copy Nagios images to the right directory
cp -a /usr/local/nagios/share/images/logos /tmp/base mv /tmp/base /usr/local/nagios/share/images/logos/base
- Browse to https://nconf_server_ip/nagios/nconf and generate and deploy nagios configuration files
Click Generate Nagios config Click Deploy
You can install another Nagios addon for making graphs using this guide:
For more information about using Nconf please visit https://www.nconf.org