Host Dependency on service

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Host Dependency on service

Postby gaurangmaru » Mon Mar 20, 2017 4:33 am

Hello All,

I am looking to monitor services from one device which is working well as expected. However if host is not available nagios is still performing checks for all the services which should not be.

I tried to use host as parent in each service however it does not seem to be working. I checked all possible blogs however I learnt only service to service or host to host dependency can be used not service to host or host to service.


Seems like I am missing or lost with very silly thing. Please help me if this is feasible.




Regards,
Gaurang
gaurangmaru
 
Posts: 11
Joined: Thu Jun 02, 2016 1:35 am

Re: Host Dependency on service

Postby cdienger » Mon Mar 20, 2017 10:37 am

Greetings, provide the service and host definition files so we can review the configuration. What is name of the host and services you are seeing this behavior with?
User avatar
cdienger
 
Posts: 115
Joined: Tue Feb 07, 2017 11:26 am

Re: Host Dependency on service

Postby gaurangmaru » Mon Mar 20, 2017 11:32 am

define host{
use generic-switch
host_name 1001101004
alias YYYYYY-XXXX
address 71.162.157.82
hostgroups YYYYYY-XXXXZZ
}

define hostgroup{
hostgroup_name YYYYYY-XXXXZZ
alias YYYYYY-XXXX
}

define service{
use generic-service
hostgroup_name C16214360689-4KDBPU
service_description HTTPS Port
check_command check_tcp!8443
check_interval 60
retry_interval 30
display_name Device Availability
}

define service{
use generic-service
hostgroup_name YYYYYY-XXXX
service_description Firmware Version
parents HTTPS Port
check_command check_snmp!-C abcde_1001101004 -m CYBEROAM-MIB -o .1.3.6.1.4.1.21067.2.1.1.3
check_interval 604800
retry_interval 86400
notification_options u,c,w,r
notifications_enabled 1
display_name Device Information
}

Above is working one, however I want like below:

define service{
use generic-service
hostgroup_name YYYYYY-XXXX
service_description Firmware Version
parents 1001101004
check_command check_snmp!-C abcde_1001101004 -m CYBEROAM-MIB -o .1.3.6.1.4.1.21067.2.1.1.3
check_interval 604800
retry_interval 86400
notification_options u,c,w,r
notifications_enabled 1
display_name Device Information
}

With above , service does not start at all.


Hope this information is helpful
gaurangmaru
 
Posts: 11
Joined: Thu Jun 02, 2016 1:35 am

Re: Host Dependency on service

Postby cdienger » Mon Mar 20, 2017 12:00 pm

What command are you using to restart the service? Please provide any errors that you may get when you try restarting it.

Is there a definition for 1001101004 in the config file? Please provide this definition as well if there is, or create it if there isn't one already.
User avatar
cdienger
 
Posts: 115
Joined: Tue Feb 07, 2017 11:26 am

Re: Host Dependency on service

Postby rkennedy » Mon Mar 20, 2017 10:44 pm

check_interval 604800

Is this on purpose? I can't even think of a half baked reason to run a check every 420 days. :lol:

The only reason I ask is I could see it playing a role in your checks not running.

Also, post the templates for generic-service and generic-switch.
rkennedy
 
Posts: 6545
Joined: Mon Oct 05, 2015 11:45 am

Re: Host Dependency on service

Postby cdienger » Tue Mar 21, 2017 9:05 am

Hey Gaurang, Let us know once you have the info requested.
User avatar
cdienger
 
Posts: 115
Joined: Tue Feb 07, 2017 11:26 am

Re: Host Dependency on service

Postby gaurangmaru » Wed Mar 22, 2017 4:43 am

Hi ,

Please fine answer for each of the queries:

1. Error message:
--> Error: Service '1001101004' on host '1001101004' is not a valid parent for service '1001101004' on host 'Firmware Version'

Looking at error , I see 1001101004 is being considered as service not host. Not sure if any specific syntax to define host as parent in service.

2. Command used to restart nagios service:
--> service nagios restart

3. Check Interval :
--> All numbers are in seconds since I changed nagios.cfg to use seconds instead minutes :).

4. I am using default templates of switch and service



Regards,
Gaurang
gaurangmaru
 
Posts: 11
Joined: Thu Jun 02, 2016 1:35 am

Re: Host Dependency on service

Postby cdienger » Wed Mar 22, 2017 11:42 am

The service definitions require a host_name directive. The host definition can then use the parents directive to refer to the 1001101004 parent. Please see https://assets.nagios.com/downloads/nag ... ml#service

Also, the hostgroup_name directive is used to define a short name used to identify the host group - in this case it would be YYYYYY-XXXXZZ.

Lastly, both the host and hostgroup definitions use the same alias. While technically this probably isn't a problem, you may want to change this to avoid confusion. Alias is used to define is a longer name or description used to identify an object.
User avatar
cdienger
 
Posts: 115
Joined: Tue Feb 07, 2017 11:26 am

Re: Host Dependency on service

Postby gaurangmaru » Thu Mar 23, 2017 5:03 am

Hi ,

Thank you for your response , It seems like I made a typo while pasting my config , but yes after making changes error remains same:


define host{
use generic-switch
host_name 1001101004
alias abc1
address XX.XX.XX.XX
hostgroups abc
}

define hostgroup{
hostgroup_name abc
alias abc1
}
define service{
use generic-service
hostgroup_name abc
host_name 1001101004
service_description Firmware Version
parents 1001101004
check_command check_snmp!-C socv2_1001101004 -m CYBEROAM-MIB -o .1.3.6.1.4.1.21067.2.1.1.3
check_interval 604800
retry_interval 86400
notification_options u,c,w,r
notifications_enabled 1
display_name Device Information
}

Error is still same : Error: Service '1001101004' on host '1001101004' is not a valid parent for service '1001101004' on host 'Firmware Version'

From error I understand parents is trying to search since it is defined under service definition.

JFYI : Nagios core version is Version 4.2.2


Regards,
Gaurang
gaurangmaru
 
Posts: 11
Joined: Thu Jun 02, 2016 1:35 am

Re: Host Dependency on service

Postby cdienger » Thu Mar 23, 2017 10:11 am

If the snmp objects you are trying to query are on a server behind the switch, you would need to do something like this:

define host{
use generic-switch
host_name 1001101004
alias abc1
address XXX.XXX.XXX.XXX
hostgroups abc
}

define hostgroup{
hostgroup_name abc
alias abc1
}

define host{
use generic-host
host_name snmpserver
address YYY.YYY.YYY.YYY
hostgroups abc
parents 1001101004
max_check_attempts 5
}

define service{
use generic-service
hostgroup_name abc
host_name snmpserver
service_description Firmware Version
check_command check_snmp!-C socv2_1001101004 -m CYBEROAM-MIB -o .1.3.6.1.4.1.21067.2.1.1.3
check_interval 604800
retry_interval 86400
notification_options u,c,w,r
notifications_enabled 1
display_name Device Information
}

If the snmp objects are on the switch itself you would just need to remove the parents directive like this:

define host{
use generic-switch
host_name 1001101004
alias abc1
address XXX.XXX.XXX.XXX
hostgroups abc
}

define hostgroup{
hostgroup_name abc
alias abc1
}
define service{
use generic-service
hostgroup_name abc
host_name 1001101004
service_description Firmware Version
check_command check_snmp!-C socv2_1001101004 -m CYBEROAM-MIB -o .1.3.6.1.4.1.21067.2.1.1.3
check_interval 604800
retry_interval 86400
notification_options u,c,w,r
notifications_enabled 1
display_name Device Information
}
User avatar
cdienger
 
Posts: 115
Joined: Tue Feb 07, 2017 11:26 am

Next

Return to Nagios Core

Who is online

Users browsing this forum: Bing [Bot] and 15 guests