Our network engineers are asking if we can do the following. I understand one is a host check the other a service check. Not sure if the service check can be dependent on whether the host check sent out a notification.
For host check
Device down over 5 min – notify
Device back up after down – notify
Device uptime < 15 min – only notify if the above 2 didn’t fire.
Can service check be dependent on host check
Re: Can service check be dependent on host check
You would need to set (for the host):
That would cover the device down over 5 minutes part (I would probably limit the check_interval 1 usage as much as possible, it really adds up depending on how many hosts/services you have and can have a negative impact on performance) and the recovery notification (which will occur once it's back up).
One way to meet your requirements would be to set host_down_disable_service_checks=1 in your /usr/local/nagios/etc/nagios.cfg and restart the nagios service, doing that will not even check the services if the host is in a down state so it would only notify if the host actually was up. That is a global change though so be aware of that.
Other than that you would likely need to script out a plugin to get access to the information via the API endpoints (see the Help > API section in the menu bar of the XI interface for working API query examples) or even by querying the status.dat file directly.
Code: Select all
check_interval 1
retry_interval 1
max_check_attempts 5
One way to meet your requirements would be to set host_down_disable_service_checks=1 in your /usr/local/nagios/etc/nagios.cfg and restart the nagios service, doing that will not even check the services if the host is in a down state so it would only notify if the host actually was up. That is a global change though so be aware of that.
Other than that you would likely need to script out a plugin to get access to the information via the API endpoints (see the Help > API section in the menu bar of the XI interface for working API query examples) or even by querying the status.dat file directly.
Re: Can service check be dependent on host check
I am not sure if this will do what they are asking. The 15 minute uptime check runs as a service and is assigned to a service template. The host template for that device will page the engineer of that device goes down. However, when the device comes back up and does the uptime service check it will see that the uptime is below the 15 minute threshold and send out a notification. What they want is if a host notification has gone out for that device, (meaning it has been down for 5 minutes ) then don't send any notification when the service check executes. However, if no host notification went out, (II.E. the device rebooted on its own) then send a notification about the uptime.
Thanks,
Greg
Thanks,
Greg
Re: Can service check be dependent on host check
What I listed is the closest I can get you given existing functionality. There isn't currently a way to do what you're trying to do regarding notifications. Services can only depend on services, hosts can only depend on hosts so a host/service dependency won't work.
The only way that you would be able to do this would be for you to write your own plugin that checks for the notification and then only returns a problem if that host notification exists.
The only way that you would be able to do this would be for you to write your own plugin that checks for the notification and then only returns a problem if that host notification exists.
Re: Can service check be dependent on host check
Ok, Thanks.
Appreciate your help.
Appreciate your help.
Re: Can service check be dependent on host check
No problem. You can have your plugin query the API to get that data (last_notification and current state), see here:
See here for the plugin development docs:
https://assets.nagios.com/downloads/nag ... inapi.html
https://nagios-plugins.org/doc/guidelines.html
Code: Select all
http://YOURXISERVER/nagiosxi/help/api-object-reference.php#objects-hoststatus
https://assets.nagios.com/downloads/nag ... inapi.html
https://nagios-plugins.org/doc/guidelines.html