Last post was about how to install nagios on debian or Ubuntu. Nagios is a famous monitoring script but problem is it is command based, however several third party web interfaces are available, one of which is nconf.
Download nconf
1 2 3 |
wget http://downloads.sourceforge.net/project/nconf/nconf/1.2.6-0/nconf-1.2.6-0.tgz tar xzvf nconf-1.2.6-0.tgz -C /var/www |
Change the web owner for nconf
1 |
chown -R www-data:www-data /var/www/nconf |
Create a database/username/password to use for nconf, you can use phpmyadmin for this purpose if you have it install.
- Now browse http://your_ip_address/nconf
- Follow steps to install nconf
- Use everything default except NAGIOS_BIN variable to /usr/sbin/nagios3
at the end it will ask you to delete following files and directories
1 |
rm -rf INSTALL INSTALL.php UPDATE UPDATE.php |
Nagios configuration
Now its time to configure nagios for nconf
- Open /etc/nagios3/nagios.cfg
- comment out all the lines that begin with cfg_dir= or cfg_file=
- Add following 2 lines and save file
1 2 |
cfg_dir=/etc/nagios3/global cfg_dir=/etc/nagios3/Default_collector |
Now create directory
1 |
mkdir /etc/nagios3/import |
Nconf configuration for nagios
Open
1 |
nano -w /var/www/nconf/ADD-ONS/deploy_local.sh |
and correct the following 2 paths
1 2 |
OUTPUT_DIR="/var/www/nconf/output" NAGIOS_DIR="/etc/nagios3/" |
Now run
1 2 3 |
chmod +x deploy_local.sh ./deploy_local.sh |
Also go to http://your_ip_address/nconf and click on “Generate nagios config”
This command will generate an output named “NagiosConfig.tgz” in /var/www/nconf/output
Extract this and it will give you 2 directories named “global” and “Default_collector”
Copy both of them to /etc/nagios3
1 2 |
mv global /etc/nagios3 mv Default_collector /etc/nagios3 |
And we are almost done
Restart nagios
1 2 3 |
localhost:~# /etc/init.d/nagios3 restart Restarting nagios3 monitoring daemon: nagios3 . |
Add crontab
1 2 |
localhost:~# crontab -e * * * * * /var/www/nconf/ADD-ONS/deploy_local.sh |
Hello,
I found 2 mistakes in the deploy_local.sh script:
1. It is important to set a / after output in the OUTPUT_DIR variable!
So do not OUTPUT_DIR=”/var/www/nconf/output” but OUTPUT_DIR=”/var/www/nconf/output/”.
2. Also, you have to chance the line /etc/init.d/nagios to /etc/init.d/nagios3.
Only after I chance both, the configuration from NConf can be seen in nagios.