Upgrading to NConf 1.3.0 on Ubuntu 11.10 Oneiric Ocelot

Congrats to the NConf crew for reaching the 1.3.0 milestone! Two years in the making, but I’m excited to see the project continuing to move forward.

It’s been over a year since I originally installed and configured Nagios and NConf 1.2.6 on my Lucid Lynx server. In the meantime, I’ve upgraded the hardware and moved to Ubuntu 11.10 Oneiric Ocelot, mostly to keep up with the current releases. Not a whole lot has changed for what I use this server for, but keeping up with the Nagios releases in the repos has been convenient.

If you’re following along with this guide but starting fresh with Nagios and Nconf, you’ll probably want to take a look at my previous guide and the NConf installation documentation to get some background information. I’ll try to provide some notes for those of you doing a fresh install, but since I’m just upgrading, I can’t make any promises.

Backups!

Log into your server and make them backups!

sudo cp -rp /var/www/nconf /var/www/nconf.bak
mysqldump -u root -p nconf > ~/nconf_sql.bak

I also backed up my Nagios configs

sudo cp -rp /etc/nagios3 /etc/nagios3.bak

Download and Unpack

Wget or otherwise download the latest version on Nconf. Wget has that issue with following SourceForge links so you may need to rename the file.

Unpack the files and then copy them to where you installed NConf before, or do it all in one step:

sudo tar xzvf nconf-1.3.0-0.tgz -C /var/www

Then fix the permissions for the NConf folder, setting them back to your apache user:

sudo chown -R www-data:www-data /var/www/nconf

Upgrade

Browse to http://<yourserver>/nconf/UPDATE.php

Follow the prompts to proceed with the interactive update. NConf’s documentation on the update process has screenshots that I won’t repost here.

After the upgrade, you’ll need to remove some files and folders. Browse to your NConf folder and nuke them. I also had to remove the call_ajax.php file, which wasn’t in the original documentation.

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

There’s been a few changes/additions to the NConf conf file, so open up config/nconf.php and add the following lines:

define('CHECK_UPDATE', 1);
define("DEBUG_GENERATE", 3); # [1=ERROR|2=WARN|3=INFO|4=DEBUG|5=TRACE]
define('CHECK_STATIC_SYNTAX', 1);

Also, set the ALLOW_DEPLOYMENT variable to 1 to enable deploying configs directly from NConf and comment out the other CONF_DEPLOY_ variables, as they aren’t used anymore.

define('ALLOW_DEPLOYMENT', 1);
#define('CONF_DEPLOY_URL', "https://webserver.mydomain.com/incoming_config.php");
#define('CONF_DEPLOY_USER', "deployUser");
#define('CONF_DEPLOY_PWD', "deployPass");

At this point, you should be able to log into NConf 1.3.0 and look around.

Migrating Deployment

With NConf 1.2.6, I used the ADD-ONS/deploy_local.sh script and a cron job to deploy configuration changes to Nagios. In 1.3.0, they’ve integrated this a little better into the core of the application, but it required some adjustment in my setup.

Start off by coping the deployment.ini sample configuration file to the config folder:

sudo cp /var/www/nconf/config.orig/deployment.ini /var/www/nconf/config/deployment.ini

Open up the config/deployment.ini file, uncomment the LOCAL deployment section except for the [copy nagios.cfg] section and change the target_file variables to reference the nagios3 folder where Ubuntu places the config files.

Also, add the reload command (sudo /etc/init.d/nagios3 reload) at the bottom of the [copy global config] section. When you’re done the file will look similar to the following:

;; 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 = "/etc/nagios/Default_collector/"
target_file = "/etc/nagios3/Default_collector/"
action = copy

[copy global config]
type = local
source_file = "/tmp/global/"
;target_file = "/etc/nagios/global/"
target_file = "/etc/nagios3/global/"
action = copy
; *** add the line below
reload_command = "sudo /etc/init.d/nagios3 reload"
; *** keep this section and the rest of the file commented out
;[copy nagios.cfg]
;type = local
;source_file = "/tmp/static_cfg/nagios.cfg"
;target_file = "/etc/nagios/nagios.cfg"
;action = copy
;reload_command = "sudo /etc/rc.d/init.d/nagios reload"

This process replaces the deploy_local.sh script, but we’ll need to allow the web user to issue the Nagios reload. To do that, we need to modify the sudoers file:

sudo visudo

Then add the following lines:

# Allow www-data (apache) user to reload nagios
www-data ALL=NOPASSWD: /etc/init.d/nagios3 reload

Save and quit.

Finally, remove the entry in the root crontab entry that launched the old deploy script:

sudo crontab -e

And remove the line reading:

* * * * * /var/www/nconf/ADD-ONS/deploy_local.sh

Deployment Testing and Cleanup

Let’s make sure the new deployment procedure works. Back in the NConf GUI, click Generate Nagios config. You should hopefully see something like:

[INFO]  Starting generate_config script
[INFO]  Generating global config files
[INFO]  Generating config for Nagios-collector 'Default Nagios'
[INFO]  Ended generate_config script

If the config files generate successfully, you’ll see a button aptly labeled ‘Deploy’.

Click Deploy, and with any luck you’ll be presented with three OK messages in NConf  and your Nagios Event Log should show a SIGHUP message.

Relax, and enjoy some JQuerified NConf 1.3.0 goodness! Gold star!

I did notice that the original deployment method left a bunch of old config tgz bundles, so if you’re feeling like cleaning those up, just remove the whole lot:

sudo rm /var/www/nconf/output/NagiosConfig.tgz.*

Update (6/25/12): You’ll want to remove the extended_host_info.cfg and extended_service_info.cfg files from your target config directory (/etc/nagios3/Default_collector/), or you might get weird problems trying to deploy later on. I just found this out six months later.

Troubleshooting Notes

  • The biggest problems I had were just remembering to reference nagios3 rather than nagios for paths and commands.  Make sure you reference the correct locations. This caused me all sorts of weird grief with the sudoers file, and I didn’t catch it until later.
  • While NConf will run without the additional variables in config/nconf.php, it’ll log warnings until you add them.
  • I had to remove an extra file (call_ajax.php) before NConf would run. The file has been replaced with call_file.php which apparently fixes a security issue. At the time of this writing, removing this file wasn’t in the docs, but it complains until you nuke it.

Fresh Install of Nagios and NConf

From what I can tell, you can follow all the steps in my old guide for installing 1.3.0 up until you get to Configuring NConf to Deploy Nagios Configurations Automatically. At that point, follow the Migrating Deployment instructions from this guide.

Please leave a comment and let me know if you do a fresh install. I’d be curious to know how it works for you.

More Information

 (edit 6/25/12 to add additional file cleanup instructions)

 

This entry was posted in Software, System Administration and tagged , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

12 Comments

  1. Posted March 23, 2012 at 8:54 am | Permalink

    There are no folders under etc for nagios3 or import under that folder. Is it suposse to be the folder /usr/local/nagios which is where the install did everything – I am using Ubuntu Server 11.10 and nagios 3.3.1 – or am I suppose to make a folder under etc for nagios 3 and then import – what should be in it – thanks

    • Posted March 23, 2012 at 12:36 pm | Permalink

      Did you download and install Nagios yourself? Last I checked, the Oneric repository still has Nagios 3.2.3. I installed from the repos and modified the install accordingly, so these instructions follow that track.

      If you did install it manually, then you may need to create folders and then modify my steps accordingly. At first glance, things may go in /usr/local/nagios/etc but you may want to double check. Good luck!

  2. spall
    Posted May 4, 2012 at 6:59 am | Permalink

    I keep getting this error, have you seen this before?

    [ERROR] Could not open /var/www/nconf/temp/test/Default_collector.cfg for writing

    • Posted May 4, 2012 at 7:02 am | Permalink

      Either move your deploy location from /var/www/ to somewhere else (I used /tmp/) or change the permissions to allow writes to your /var/www/nconf/temp/test/ folder. It’s more than likely a permissions issue.

    • spall
      Posted May 4, 2012 at 7:24 am | Permalink

      ah just, chmodded it, and it works ;)

  3. spall
    Posted May 4, 2012 at 7:26 am | Permalink

    one other question is:

    if you already had a configuration inplace, how to load it back in using nconf, is it possible?

    btw thanks for the article, it helped me out

  4. Pabu
    Posted August 27, 2012 at 7:49 pm | Permalink

    Thanks dude, it’s very helpful.

  5. shk
    Posted August 31, 2012 at 11:59 am | Permalink

    I did a fresh install of nconf 1.3
    everything worked fine, and deployed.
    then I went to “show hosts” and deleted “hplj2605dn, linksys-srw224p and winserver”
    then click on “generate nagios configuration” but it give error
    —————–

    Nagios Core 3.2.1
    Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
    Copyright (c) 1999-2009 Ethan Galstad
    Last Modified: 03-09-2010
    License: GPL

    Website: http://www.nagios.org
    Reading configuration data…
    Read main config file okay…
    Processing object config file ‘/var/www/nconf/temp/global/timeperiods.cfg’…
    Processing object config file ‘/var/www/nconf/temp/global/contacts.cfg’…
    Processing object config file ‘/var/www/nconf/temp/global/misccommands.cfg’…
    Processing object config file ‘/var/www/nconf/temp/global/checkcommands.cfg’…
    Processing object config file ‘/var/www/nconf/temp/global/host_templates.cfg’…
    Processing object config file ‘/var/www/nconf/temp/global/service_templates.cfg’…
    Processing object config file ‘/var/www/nconf/temp/global/contactgroups.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/service_dependencies.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/host_dependencies.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/advanced_services.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/services.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/servicegroups.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/hosts.cfg’…
    Processing object config file ‘/var/www/nconf/temp/Default_collector/hostgroups.cfg’…
    Processing object config directory ‘/var/www/nconf/static_cfg’…
    Error: Could not find any host matching ‘hplj2605dn’ (config file ‘/var/www/nconf/temp/Default_collector/hostgroups.cfg’, starting on line 13)
    Error: Could not expand members specified in hostgroup (config file ‘/var/www/nconf/temp/Default_collector/hostgroups.cfg’, starting on line 13)
    Error processing object config files!

    ***> The name of the main configuration file looks suspicious…

    Make sure you are specifying the name of the MAIN configuration file on
    the command line and not the name of another configuration file. The
    main configuration file is typically ‘/usr/local/nagios/etc/nagios.cfg’

    ***> One or more problems was encountered while processing the config files…

    Check your configuration file(s) to ensure that they contain valid
    directives and data defintions. If you are upgrading from a previous
    version of Nagios, you should be aware that some variables/definitions
    may have been removed or modified in this version. Make sure to read
    the HTML documentation regarding the config files, as well as the
    ‘Whats New’ section to find out what has changed.

    ———————-

    there is nothing in /var/www/nconf/temp/, neither I see any where that /var/www/nconf/temp/ is being used in nconf setting..I use /tmp in config/deployment.ini
    and /var/www/nconf/ADD-ONS/deploy_local.sh is running without any problem.
    can you help me in this?

    • Posted September 1, 2012 at 7:56 am | Permalink

      What type of deployment are you defining in deployment.ini? NConf 1.3.0 doesn’t use the deploy_local.sh script anymore, so if you’re seeing that file, there might be some remnants of a previous version floating around.

  6. shk
    Posted September 1, 2012 at 8:33 am | Permalink

    deployment.ini is same as you defined above.
    I installed nconf 1.3 from scratch..therefore should be any remnant of previous version unless the nconf is including it in the package of 1.3

    • Posted September 1, 2012 at 8:15 pm | Permalink

      Looking at your issue again, it may just be that deleting the hosts didn’t clear the hostgroup entries. Check through the hostgroups and clear them as appropriate. I left winserver there and just set it to not monitored so I never noticed a problem like this.

One Trackback

  • By Nagios and NConf on Ubuntu 10.04 Lucid Lynx on January 29, 2012 at 2:44 pm

    [...] As of December 2011, NConf has released version 1.3.0 which changes the deployment methods for configs. Take a look at my NConf 1.3.0 upgrade guide! [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

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>