Sync Missed?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Sync Missed?

Post by mguthrie »

Do you have duplicate entries for either your hosts or hostgroups in the CCM?

What browser are you using?

Are the host groups relationships showing up in XI after configuration is applied?
User avatar
SeanFromIT
Posts: 105
Joined: Sun Dec 12, 2010 9:07 pm

Re: Sync Missed?

Post by SeanFromIT »

Using Chrome. Here's what I believe started the issue-
There are duplicate host group entries, for each duplicate one is not marked active and one is marked active. I don't know where the inactive entries came from, probably an import of configuration file from our older Nagios environment. Since they're not active, I went ahead and deleted the inactive host group entries. This is when the problem began. So when I restored to the last working snapshot, they came back. But if I delete them Nagios starts spitting out the verification errors. If I don't delete them, Nagios verification is fine but it looks like we start magically losing host group members.

Maybe I should restore to last working snapshot, and directly remove the inactive host groups from the database? Should I do this in postgres or mysql? Any guidance you could provide would be great!
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Sync Missed?

Post by mguthrie »

There are duplicate host group entries, for each duplicate one is not marked active and one is marked active. I don't know where the inactive entries came from, probably an import of configuration file from our older Nagios environment.
These came from an unprepped import script. If you have a comma separated list with spaces you'll get this issue. We have a script that preps file for imports that should be used on all files being imported into XI. If you prep the script, and then import the prepped script, your group configs should import correctly. Here's the doc for that.

http://assets.nagios.com/downloads/nagi ... ngfromcore
Since they're not active, I went ahead and deleted the inactive host group entries. This is when the problem began. So when I restored to the last working snapshot, they came back. But if I delete them Nagios starts spitting out the verification errors. If I don't delete them, Nagios verification is fine but it looks like we start magically losing host group members.
What's happening is that those inactive entries are actually acting as markers for host -> hostgroup relationships. They don't look like they're doing anything, but when you delete them the relationship disappears. Follow the docs above and things should import correctly.
Maybe I should restore to last working snapshot, and directly remove the inactive host groups from the database? Should I do this in postgres or mysql? Any guidance you could provide would be great!
We have a doc on backing up and restoring an XI installation, but it requires the backup to be made first. Use whatever method seems best to you to clear out the imported hostgroup config that caused the bad results. There's no host/service config data in postgresql, it's only in mysql. Unless you've got a huge number of hostgroup relationships to clean up, you can probably just delete them manually and reimport.
http://assets.nagios.com/downloads/nagi ... kuprestore
User avatar
SeanFromIT
Posts: 105
Joined: Sun Dec 12, 2010 9:07 pm

Re: Sync Missed?

Post by SeanFromIT »

Yeah, it's a pretty large number. Here's what I tried: Delete all host groups, use prep tool on host groups file, import the prepped file. This creates the host groups as expected, all active. I need to reimport hosts after this to get the host-host group relations back. But the hosts can't be from the old environment, they need to be from the last working snapshot. If I try deleting all hosts and importing the hosts folder from last snapshot, the inactive host groups are created again. Do I need to run the prep tool on each host file from last snapshot? If so, is there any way to point xiprepimport.php at a directory instead of a single file?
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Sync Missed?

Post by mguthrie »

Do I need to run the prep tool on each host file from last snapshot? If so, is there any way to point xiprepimport.php at a directory instead of a single file?
Yes. If it has a comma separated list (with spaces) then you'll need to. If there are no spaces in between the list items then you should be fine.

For processing all files in the directory.
I forget the exact syntax for it, (you'll have to google it) but you could write a simple shell script that looks something like the following (written in pseudo-code, you'll have to look up the correct shell syntax)

Code: Select all

DIR=<your hosts directory>  

foreach (-f  in -d $DIR) do
{
  /usr/bin/php <prep_tool path>  <file> <output directory> 
}
The guy who writes our shell scripts it out today, otherwise he could probably tell you this in a few seconds.
User avatar
SeanFromIT
Posts: 105
Joined: Sun Dec 12, 2010 9:07 pm

Re: Sync Missed?

Post by SeanFromIT »

For anyone interested

Code: Select all

#!/bin/bash

for myfile in /usr/local/nagios/etc/cfgprep/orig/hosts/*
do
    /usr/bin/php /usr/local/nagiosxi/tools/xiprepimport.php "$myfile"
done
However, the problem still exists. I guess I'm going to have to go into every file and try and find those spaces. If you'd like a copy of one of the config files for improving xiprepimport.php let me know.
Last edited by SeanFromIT on Thu Feb 03, 2011 11:51 am, edited 1 time in total.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Sync Missed?

Post by mguthrie »

Yeah actually we'd definitely like to use that config file as a sample. Our testing environments can be somewhat limited at times. I'll send you the patched script as well if you want.

What version of XI are you using? We just released our 1.4 version. I'll attach the latest fix script, maybe see if the result is any different.
You do not have the required permissions to view the files attached to this post.
User avatar
SeanFromIT
Posts: 105
Joined: Sun Dec 12, 2010 9:07 pm

Re: Sync Missed?

Post by SeanFromIT »

Here's a copy of one of the files that the old script wasn't scrubbing correctly.

Code: Select all

###############################################################################
#
# Host configuration file
#
# Created by: Nagios QL Version 3.0.3
# Date:	      2011-01-21 15:29:26
# Version:    Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND --- 
# Nagios QL will overwite all manual settings during the next update
#
###############################################################################

define host {
	host_name			hostname
	use				generic-server
	alias				hostname
	address				00.00.00.00
	parents				somerouter
	hostgroups			 check-basic-network, check-basic-nrpe, check-basic-services, check-basic-windows, windows-servers,some-servers
	register			1
	}	

###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
I used a text editor to get rid of the spaces. Now the only thing I have left to figure out is service groups...no space issues like host groups had, but hosts are not showing as selected. I'm going to try running your new xi import script against the service files and see if that helps.

Do you have an upgrade document for 1.3G (official VM) to 1.4?
User avatar
SeanFromIT
Posts: 105
Joined: Sun Dec 12, 2010 9:07 pm

Re: Sync Missed?

Post by SeanFromIT »

Looks like the new script cleaned the service files well, service group memberships are working again. But some Performance Graphs are no longer graphing. Is there any way to kick start those, short of deleting the old rrd files? Looking at the file properties, I see that the xml files were written to when I last imported configs but the rrd files have not been updating. This is only for some services for a given host, not all of them - some are working, some aren't.
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

Re: Sync Missed?

Post by rdedon »

This can happen for a variety of reasons, but there are several simple solutions that resolve this issue for most people:

* Reset Security Credentials
Select the Reset Security Credentials option in the Admin menu and click Update
* Reset File Permissions
Execute the following command to reset your configuration file permissions:

Code: Select all

 /usr/local/nagiosxi/scripts/reset_config_perms
Rene deDon
Technical Team
___
Nagios Enterprises, LLC
Web: http://www.nagios.com
Locked