Page 1 of 2

Host Dependency on service

Posted: Mon Mar 20, 2017 4:33 am
by gaurangmaru
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

Re: Host Dependency on service

Posted: Mon Mar 20, 2017 10:37 am
by cdienger
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?

Re: Host Dependency on service

Posted: Mon Mar 20, 2017 11:32 am
by gaurangmaru
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

Re: Host Dependency on service

Posted: Mon Mar 20, 2017 12:00 pm
by cdienger
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.

Re: Host Dependency on service

Posted: Mon Mar 20, 2017 10:44 pm
by rkennedy
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.

Re: Host Dependency on service

Posted: Tue Mar 21, 2017 9:05 am
by cdienger
Hey Gaurang, Let us know once you have the info requested.

Re: Host Dependency on service

Posted: Wed Mar 22, 2017 4:43 am
by gaurangmaru
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

Re: Host Dependency on service

Posted: Wed Mar 22, 2017 11:42 am
by cdienger
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.

Re: Host Dependency on service

Posted: Thu Mar 23, 2017 5:03 am
by gaurangmaru
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

Re: Host Dependency on service

Posted: Thu Mar 23, 2017 10:11 am
by cdienger
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
}