Page 2 of 2

Re: Sync Missed?

Posted: Thu Jan 27, 2011 5:27 pm
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?

Re: Sync Missed?

Posted: Fri Jan 28, 2011 1:43 pm
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!

Re: Sync Missed?

Posted: Fri Jan 28, 2011 3:02 pm
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

Re: Sync Missed?

Posted: Fri Jan 28, 2011 4:36 pm
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?

Re: Sync Missed?

Posted: Fri Jan 28, 2011 5:04 pm
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.

Re: Sync Missed?

Posted: Mon Jan 31, 2011 10:29 am
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.

Re: Sync Missed?

Posted: Tue Feb 01, 2011 10:56 am
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.

Re: Sync Missed?

Posted: Thu Feb 03, 2011 11:10 am
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?

Re: Sync Missed?

Posted: Thu Feb 03, 2011 2:39 pm
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.

Re: Sync Missed?

Posted: Thu Feb 03, 2011 3:19 pm
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