import of service dependencies

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ktservices
Posts: 19
Joined: Mon Mar 26, 2012 6:20 am
Location: Germany
Contact:

import of service dependencies

Post by ktservices »

Hi all,

i'm migrating our old nagios core server into Nagios XI. i do it with a script, which reads all servicedescriptons from the old configfiles a generates new ones in the directory "/usr/local/nagios/etc/import". Then i do "apply configuration" and e voila the hosts appear in the hostgroups. This works fine, but the script also generates files with service_dependencies like this in an another subdir:

define servicedependency {
dependent_host_name ares01
dependent_service_description IBM.CSMAgentRMd,IBM.DRMd,IBM.ServiceRMd,cron,dsmcad,hats_diskhb,hats_nim,hatsd,java,rmcd,sendmail,snmpd,snmpmibd,syslogd,xntpd,Current_Load,SSH,Filesystems,Users,SystemLoad,Filesystem_/home,Filesystem_/home/dmae,Filesystem_/gpfs/admira,Process-Zombies,Processes,Mounts,Paging
host_name ares01
service_description PING
inherits_parent 1
execution_failure_criteria w,u,c,
notification_failure_criteria w,u,c,
dependency_period 24x7

}

When import this file, a new servicedependency will we generated, but many services are missing in the servicedependencies and i had to add them manually.
Why ist that and what is wrong with the above lines?

Hope anybody can help me.

Best Regards
Reinhold Krinninger
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: import of service dependencies

Post by lmiltchev »

The service dependency definition looks fine. When you said that you used a script for the migration, did you mean you used the config import prep tool?

http://assets.nagios.com/downloads/nagi ... p_Tool.pdf

Also, do you follow the correct order, when importing the configs in the Nagios XI?

Code: Select all

commands -> timeperiods -> contacttemplates -> contacts -> contactgroups -> hosttemplates -> hosts -> hostgroups -> servicetemplates -> services -> servicegroups 
Be sure to check out our Knowledgebase for helpful articles and solutions!
ktservices
Posts: 19
Joined: Mon Mar 26, 2012 6:20 am
Location: Germany
Contact:

Re: import of service dependencies

Post by ktservices »

no, the script is selfcreated, as we need some changes in the configfiles. it reads from the old configfiles and generates new ones with corrected hostnames and sometimes additional services, configurable with arguments.

whether the sequence of imports is correct, I can not say. What we do is, we dissolve an existing nagios-core server and import all the hosts and services into an existing nagios xi server. the import of the hosts and its services works already fine, but the import of the servicedependencies does not work. i have notice the following: only new services are imported in the servicedependencies, existing services no longer beeing imported. example: if i import a server with a total of 31 checks and 30 checks are already in Nagios XI available and one check is new, only the one new is added to the servicedepenecies.

today i tried to use the included import script from Nagios XI. i tried it on the configfiles, generated by my script. the same problem occurs. the servicedependency-file looks equal before and after executing the php import-script.

what else can i do?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: import of service dependencies

Post by lmiltchev »

I tried to import a bunch of service dependencies, and was not able to recreate the issue. Are you comparing the file in the "/usr/local/nagios/etc/cfgprep" to the one in the "/usr/local/nagios/etc/cfgprep/orig" directory? Also, when you import the files from the Web interface (CCM->Import Config Files...), do you have the "Overwrite Database" checkbox selected? Do you check your configuration with the Write Config Files, prior to Applying Configuration?
Be sure to check out our Knowledgebase for helpful articles and solutions!
ktservices
Posts: 19
Joined: Mon Mar 26, 2012 6:20 am
Location: Germany
Contact:

Re: import of service dependencies

Post by ktservices »

i compare the servicesdependency-file created from my script and the one generated by the nagios xi php-script. they look equal for me and so the same "error" occurs if i import the one from my script or from the nagios xi php-script.

The checkbox "overwrite database" is always on. Today i tried with "write config files" before applying the new configuration. nothing changes.
we have also a test machine, where i did the first tries with the selfmade-script. even on this machine the same happens, the checks are imported correctly but only new servicedependencies are imported.

is there another way to import servicedepencies? like direct access to the database or via external commands (i would prefer the second)?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: import of service dependencies

Post by abrist »

ktservices wrote:is there another way to import servicedepencies? like direct access to the database or via external commands (i would prefer the second)?
Since the database is highly relational, crafting a custom query to add a dependency is risky. The best way is to run the standard import, but in your case that is not working. You could recreate the dependencies by hand in the CCM, but that is less than ideal. You could use the static directory, and just place your dependency configs there, but you will be unable to manage them from the XI ui.

Just to be sure, are you preparing the configs before importing?
http://assets.nagios.com/downloads/nagi ... p_Tool.pdf
http://assets.nagios.com/downloads/nagi ... nto_XI.pdf
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ktservices
Posts: 19
Joined: Mon Mar 26, 2012 6:20 am
Location: Germany
Contact:

Re: import of service dependencies

Post by ktservices »

i did a simple test on my testserver. It's VM on KVM with a rather fresh installation of nagios xi and only a vew hosts with a few checks.
I added to the existing host a new check. The new check has the same name as another check on an other host already has.
i created manually a file with the following content under this directory "/usr/loca/nagios/etc/nagioscore_mig":

define servicedependency{
host_name localhost
service_description PING
dependent_host_name localhost
dependent_service_description Apache-Webserver
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
}

Then i imported this file as described in this document http://assets.nagios.com/downloads/nagi ... nto_XI.pdf:
- importing the file >> OK
- writing and verifing the config files >> OK
- apply configuration >> OK

then i took a look at legacy ccm and found a new servicedependency for "localhost" and under "Dependent Services" is "Apache-Webserver" is written. But when i open the servicedependency is "Dependent Services" empty. It seems, only parts of the servicedependency are imported and the configuration is not completed. Both of my Nagios-XI Servers do the same, even the rather new installed Testserver with the newest avaialable Version of Nagios XI 2012 R2.9.
What is the error?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: import of service dependencies

Post by abrist »

Did you run the config prep tool before the import?
http://assets.nagios.com/downloads/nagi ... p_Tool.pdf
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ktservices
Posts: 19
Joined: Mon Mar 26, 2012 6:20 am
Location: Germany
Contact:

Re: import of service dependencies

Post by ktservices »

i made a new test on my testserver. i run the import php-script against the script with the servicedependencies, imported the newly generated file, did everything to do in "write config" and applied the configuration, all without any errors.
The result is same, i got a new servicedependency but without any depentent services. this result is not unexpected, as both files (my own and that from the import php-script) are equal expect some tabs.
I'm not sure if I somehow make a mistake here.
is it certain that I can import services with names that exist already in the system into service dependencies?
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: import of service dependencies

Post by sreinhardt »

I am doubting that you made any major mistakes, you logic seems sound. However importing configs with dependencies in XI is a little tricky. If all dependencies are not met, that config option will often be dropped as the relation within the database cannot be created yet. What I would actaully suggest, if you got all of your hosts and services that were expected, but not all dependencies, try and run another import with the same files (post both scripts). This will not cause duplicates, but will only update configurations. If the dependencies are now met, they should be applied to your services.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked