Dependies with multi config files

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
MINT
Posts: 3
Joined: Mon Nov 06, 2017 10:02 am

Dependies with multi config files

Post by MINT »

Hello,

First of all I am pretty new to nagios and really like the product.
My System is working as expected but I have one issue with testing the dependencies.

I took the servicedependency from the documentation and configured as described.

Code: Select all

define servicedependency{
	host_name			TRUNK
	service_description		check-host-alive
	dependent_host_name		Database
	dependent_service_description	Unprocessed_queued_alerts
	execution_failure_criteria	c
	notification_failure_criteria	w,u,c,p
	}
This is configured in TRUNK.cfg and the DATABASE Configuration is stored in DATABASE.cfg to have a better overview and usage of the config files.


I get the Error Message:
referenced host 'DATABASE' does not exist in TRUNK.cfg:11

This makes sense because DATABASE is defined in a different config file.
Is there a solution for this to use service dependency with multi config files?
In other words:
Is there a way to use the host "DATABASE" which is configured in DATABASE.cfg in the config file TRUNK.cfg?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Dependies with multi config files

Post by mcapra »

MINT wrote: I get the Error Message:
referenced host 'DATABASE' does not exist in TRUNK.cfg:11
What is the exact command you are running that is producing this error?

Can you also share your main Nagios configuration file? It's typically found here:

Code: Select all

/usr/local/nagios/etc/nagios.cfg
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Dependies with multi config files

Post by dwhitfield »

@MINT, if you could provide the info @mcapra is asking for, that would be great. If you don't want it public, feel free to PM me.
MINT
Posts: 3
Joined: Mon Nov 06, 2017 10:02 am

Re: Dependies with multi config files

Post by MINT »

Thanks for your investigation.
nagios.cfg is empty at the moment. I am still at testing.
The problem is caused because I use more then one service file to define services.
I define the services for each host in a single .cfg file.

Here is the full command: (changed some parts I don't want to share)
ca2.cfg:

Code: Select all

define service {
  service_description            Unprocessed_queued_alerts
  host_name                      CA2
  use                            generic-service-intervall15
  check_command                  check_oracle_count_of_stuck!PublicIPSlave!PrivatIpServer!nameoftheschema!SQLstatementtocheckalerts
  icon_image                     oracle.jpg
  process_perf_data              1
}
#dependency
define servicedependency{
	host_name			TRUNK/US11
	service_description		check-host-alive
	dependent_host_name		CA2
	dependent_service_description	Unprocessed_queued_alerts
	execution_failure_criteria	c
	notification_failure_criteria	w,u,c,p
	}
US11.cfg:

Code: Select all

define host {
  host_name                      US11
  alias                          TRUNK/US11
  address                        52.6.132.96
  parents                        US-DB
  use                            windows-server
  display_name                   US11
  icon_image                     file_server.jpg
  process_perf_data              1
  statusmap_image                file_server.jpg
}

define service {
  service_description            check-host-alive
  host_name                      TRUNK/US11
  use                            generic-service
  check_command                  check-host-alive
  icon_image                     Thumb-up-icon.png
}
When I commit ca2.cfg the config check alerts:

Code: Select all

referenced host 'TRUNK/US11' does not exist in ca2.cfg:11
Of course it does not exist in ca2.cfg because this definition:

Code: Select all

define servicedependency{
	host_name			TRUNK/US11
is defined here: us11.cfg

Thanks for your help.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Dependies with multi config files

Post by dwhitfield »

MINT wrote: nagios.cfg is empty at the moment. I am still at testing.
Well, once you get a nagios.cfg, but the following in it so nagios know where your configs are:

cfg_dir=<directory_name>

You can read more about the config options at https://assets.nagios.com/downloads/nag ... gmain.html


What version of Core are you using? Was it compiled from source or installed from distro repos? On what OS/version is nagios running? cat /etc/*-release may be of use. Those questions will help us determine file paths/names so that we can help you.
MINT
Posts: 3
Joined: Mon Nov 06, 2017 10:02 am

Re: Dependies with multi config files

Post by MINT »

Hi dwhitfield,

I did a stupid mistake. I am sorry, :oops: used the alias and not the host name in the dependency.
You can the this in my second post.
Nice product, works as expected!

Thank you for the investigation.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Dependies with multi config files

Post by npolovenko »

@MINT, Nice! I will close this thread as resolved then. But if you encounter any other issues feel free to open a new one.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked