Nagios, Nconf and Nrpe Debian/Ubuntu part 2/3

installation and configuration of nconf 1.3.0

move to directory /var/www

cd /var/www
wget http://sourceforge.net/projects/nconf/files/nconf/1.3.0-0/nconf-1.3.0-0.tgz
tar zxvf nconf-1.3.0-0.tgz

cd /var/www/nconf
chmod 777 config/
chmod 777 output/
chmod 777 static_cfg/
chmod 777 temp/

on the browser type:

http://server_ip/nconf

Start Nconf configuration

Input the database configuration

Nconf path: /var/www/nconf

Nagios path: /usr/local/nagios/bin/nagios

For a better security enable "auth_enabled" and type a password.

Delete the following files before click on finish:

rm -rf INSTALL
rm -rf UPDATE
rm INSTALL.php
rm UPDATE.php

now click on finish and then insert username and password
username: admin
password: the one you chose

Bug: nconf has a bug. To solve it download the patch from this website:
http://forum.nconf.org/viewtopic.php?f=17&t=872#p3050

nconf-1.3.0-0_not_used_advanced_services_wont_be_written.patch.zip

unzip nconf-1.3.0-0_not_used_advanced_services_wont_be_written.patch.zip
cp nconf-1.3.0-0_not_used_advanced_services_wont_be_written.patch /var/www/nconf
patch -p0 --verbose < nconf-1.3.0-0_not_used_advanced_services_wont_be_written.patch

Hmm…  Looks like a unified diff to me…
The text leading up to this was:
————————–
|— bin/lib/NConf/ExportNagios.pm.orig    2011-12-24 13:57:38.620626845 +0100
|+++ bin/lib/NConf/ExportNagios.pm    2011-12-24 14:02:16.870751718 +0100
————————–
Patching file bin/lib/NConf/ExportNagios.pm using Plan A…
Hunk #1 succeeded at 1014.
Hunk #2 succeeded at 1078.
Hunk #3 succeeded at 1111.
done

Now copy nagios.cfg in /var/www/nconf/static_cfg
first create a backup copy of nagios.cfg

cp /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfg.orig
cp /usr/local/nagios/etc/nagios.cfg /var/www/nconf/static_cfg/

edit nconf.cfg in /var/www/nconf/static_cfg
vim nagios.cfg

comment all cfg_file e cfg_dir and insert these:

cfg_dir=/usr/local/nagios/etc/global
cfg_dir=/usr/local/nagios/etc/Default_collector

save and exit:
:wq

set the permissions etc and nagios.log
chmod 777 /usr/local/nagios/var/nagios.log
chmod -R 777 /usr/local/nagios/etc/

Another bug in nconf:

Add the line "define('CHECK_STATIC_SYNTAX', 0);" in the file /config/nconf.php

save and exit:
:wq

copy logos and images:

cp -R /var/www/nconf/img /usr/local/nagios/share/images

Configure the automatic deploy on nagios:

edit the file /var/www/nconf/config/deployment.ini
change the following lines as written here:

vim /var/www/nconf/config/deployment.ini

;; LOCAL deployment ;;

[extract config]
type        = local
source_file = "/var/www/nconf/output/NagiosConfig.tgz"
target_file = "/tmp/"
action      = extract

[copy collector config]
type        = local
source_file = "/tmp/Default_collector/"
target_file = "/usr/local/nagios/etc/Default_collector/"
action      = copy

[copy global config]
type        = local
source_file = "/tmp/global/"
target_file = "/usr/local/nagios/etc/global/"
action      = copy

[copy nagios.cfg]
type        = local
source_file = "/tmp/static_cfg/nagios.cfg"
target_file = "/usr/local/nagios/etc/nagios.cfg"
action      = copy
reload_command = "echo password | sudo /etc/init.d/nagios reload"

save and exit:
:wq

the reload of nagios must be done by the superuser, so my solution is  "echo password | sudo /etc/init.d/nagios reload"

Now Nconf is configured to interact with Nagios.

This post is also available in: Italian

2 comments on “Nagios, Nconf and Nrpe Debian/Ubuntu part 2/3

  1. Ryan says:

    Thank you so much for this info. I was having a lot of problems with the advanced_services.cfg bug.

  2. Mark says:

    Got it all working on a raspberry pi2 except the restart of nagios. The nconf directory is under the /var/www/html directory and owned by www-data. The only way I could find to get this to work was to modify the deployment.ini and sudoers as below.

    /var/www/html/nconf/config/deployment.ini

    ;; LOCAL deployment ;;

    [extract config]
    type        = local
    source_file = "/var/www/html/nconf/output/NagiosConfig.tgz"
    target_file = "/tmp/"
    action      = extract

    [copy collector config]
    type        = local
    source_file = "/tmp/Default_collector/"
    target_file = "/usr/local/nagios/etc/Default_collector/"
    action      = copy

    [copy global config]
    type        = local
    source_file = "/tmp/global/"
    target_file = "/usr/local/nagios/etc/global/"
    action      = copy

    [copy nagios.cfg]
    type        = local
    source_file = "/tmp/static_cfg/nagios.cfg"
    target_file = "/usr/local/nagios/etc/nagios.cfg"
    action      = copy
    reload_command = "sudo /etc/init.d/nagios reload"

    Add the following line in /etc/sudoers using visudo:

    www-data ALL=NOPASSWD: /etc/init.d/nagios reload

Leave a Reply to Ryan Cancel reply

Your email address will not be published. Required fields are marked *

CAPTCHA Image

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>