Check Settings and Event Handler Behavior

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
kenneth59
Posts: 23
Joined: Tue Apr 16, 2024 10:03 pm

Check Settings and Event Handler Behavior

Post by kenneth59 »

Hi,
I have some questions regarding Nagios settings and would appreciate any help.

1. Clarification on "Check Settings" in Nagios:
I’m seeking a clearer understanding of the "check settings" tab in host and service management. While I understand how check intervals, retry intervals, and maximum check attempts work, I’m confused about the options for null, skips, off, and on under check settings.

What do these options mean, and how do they function? I’ve found some forum information on the difference between skips and null, but how do skipping or null differ from simply turning the checks on or off? Could someone provide more detailed explanations or point me to relevant resources?

Below is the forum I found explaining the difference between null and skip:
viewtopic.php?t=8948

I also found some mention of skip in this documentation:
https://assets.nagios.com/downloads/nag ... gement.pdf


2. Event Handler Behavior and Timing:
I’d also like to ask about event handlers in Nagios. From what I’ve read on the Nagios website and based on my understanding, it seems that the event handler is a state-based event, meaning it fires immediately when there’s a change in the service or host state.

Is there any way to configure the event handler to follow the check intervals, retry intervals, and maximum check attempts? For example, instead of triggering the event handler immediately when there’s a state change, can it be set to wait until the state is confirmed after the configured check intervals or retry attempts?

Below is where I got the information on event handlers: https://assets.nagios.com/downloads/nag ... dlers.html
sgardil
Posts: 225
Joined: Wed Aug 09, 2023 9:58 am

Re: Check Settings and Event Handler Behavior

Post by sgardil »

kenneth59 wrote: Sun Sep 08, 2024 8:15 am Hi,
I have some questions regarding Nagios settings and would appreciate any help.

1. Clarification on "Check Settings" in Nagios:
I’m seeking a clearer understanding of the "check settings" tab in host and service management. While I understand how check intervals, retry intervals, and maximum check attempts work, I’m confused about the options for null, skips, off, and on under check settings.

What do these options mean, and how do they function? I’ve found some forum information on the difference between skips and null, but how do skipping or null differ from simply turning the checks on or off? Could someone provide more detailed explanations or point me to relevant resources?

Below is the forum I found explaining the difference between null and skip:
viewtopic.php?t=8948

I also found some mention of skip in this documentation:
https://assets.nagios.com/downloads/nag ... gement.pdf


2. Event Handler Behavior and Timing:
I’d also like to ask about event handlers in Nagios. From what I’ve read on the Nagios website and based on my understanding, it seems that the event handler is a state-based event, meaning it fires immediately when there’s a change in the service or host state.

Is there any way to configure the event handler to follow the check intervals, retry intervals, and maximum check attempts? For example, instead of triggering the event handler immediately when there’s a state change, can it be set to wait until the state is confirmed after the configured check intervals or retry attempts?

Below is where I got the information on event handlers: https://assets.nagios.com/downloads/nag ... dlers.html
Hey @kenneth59

From my understanding skip and null differ from on and off in the sense that they are changing the values from any template inheritance you may have. For example when you have skip it will inherit the value of a template if there is one but not turn it on if there is not. Where as null will make it so that it will not inherit the value from the template.

As for the event handlers you are right that it will fire immediately on the state change. To get what you want you would want to make sure that the event handler you are using only runs on a hard state. Theres a link in the documentation you posted that explains the differences between soft and hard states fairly well.
snapier3
Posts: 115
Joined: Tue Apr 23, 2019 7:12 pm

Re: Check Settings and Event Handler Behavior

Post by snapier3 »

Is there any way to configure the event handler to follow the check intervals, retry intervals, and maximum check attempts? For example, instead of triggering the event handler immediately when there’s a state change, can it be set to wait until the state is confirmed after the configured check intervals or retry attempts?
IMHO Your handler is where you work with this logic.

Using the Nagios macros you can pass the needed variables to the command that executes your handler.
https://assets.nagios.com/downloads/nag ... olist.html

You can use the HARD/SOFT designation from $HOSTSTATETYPE$ or $SERVICESTATETYPE$ to determine the point in the check process you're at.

You can use $MAXHOSTATTEMPTS$ vs $HOSTATTEMPT$ macro values to understand the number of iterations of the host check and $MAXSERVICEATTEMPTS$ /$SERVICEATTEMPT$ to do the same for services.

Small Note: Nagios Core 4.5.0 added enhancements for handler time period changes.
https://www.nagios.org/projects/nagios-core/4x/

--SN
kenneth59
Posts: 23
Joined: Tue Apr 16, 2024 10:03 pm

Re: Check Settings and Event Handler Behavior

Post by kenneth59 »

sgardil wrote: Mon Sep 09, 2024 11:08 am As for the event handlers you are right that it will fire immediately on the state change. To get what you want you would want to make sure that the event handler you are using only runs on a hard state. Theres a link in the documentation you posted that explains the differences between soft and hard states fairly well.
snapier3 wrote: Mon Sep 09, 2024 11:40 am Your handler is where you work with this logic.

Using the Nagios macros you can pass the needed variables to the command that executes your handler.
https://assets.nagios.com/downloads/nag ... olist.html

You can use the HARD/SOFT designation from $HOSTSTATETYPE$ or $SERVICESTATETYPE$ to determine the point in the check process you're at.

You can use $MAXHOSTATTEMPTS$ vs $HOSTATTEMPT$ macro values to understand the number of iterations of the host check and $MAXSERVICEATTEMPTS$ /$SERVICEATTEMPT$ to do the same for services.

Small Note: Nagios Core 4.5.0 added enhancements for handler time period changes.
https://www.nagios.org/projects/nagios-core/4x/

--SN
Hi @sgardil and @snapier3,

Thank you for your response. The method in both of your proposals seems to require adding an additional condition to the handler itself to either check the state or the number of attempts. Is there any method within the Nagios UI that allows me to configure the system to check the state before triggering the event handler?
kenneth59
Posts: 23
Joined: Tue Apr 16, 2024 10:03 pm

Re: Check Settings and Event Handler Behavior

Post by kenneth59 »

sgardil wrote: Mon Sep 09, 2024 11:08 am
From my understanding skip and null differ from on and off in the sense that they are changing the values from any template inheritance you may have. For example when you have skip it will inherit the value of a template if there is one but not turn it on if there is not. Where as null will make it so that it will not inherit the value from the template.
Hi sgardil,

Do correct me if I misunderstood what you mean.
Assuming that this service has an event handler from a linked template and also has its own event handler configured, I will refer to the handler inherited from the template as the "inherited handler" and the service’s own handler as the "service handler."
  • If I set "event handler enable" to null, the service will use its own event handler, which is the "service handler."
  • If I set "event handler enable" to skip, the service will use the inherited event handler, which is the "inherited handler."
  • I assume setting "event handler enable" to off will completely stop the handler from being triggered, meaning neither the "service handler" nor the "inherited handler" will be triggered.
  • If I set "event handler enable" to on, it will first use the "service handler." If the "service handler" is missing, it will fall back to the "inherited handler."
Is this understanding correct?
snapier3
Posts: 115
Joined: Tue Apr 23, 2019 7:12 pm

Re: Check Settings and Event Handler Behavior

Post by snapier3 »

Assuming that this service has an event handler from a linked template and also has its own event handler configured, I will refer to the handler inherited from the template as the "inherited handler" and the service’s own handler as the "service handler."
The handler set in the Service configuration will take precedence over the setting in the template. You can read more about that in the Object Inheritance documentation.
https://assets.nagios.com/downloads/nag ... tance.html


Nagios Event Handler Intro
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
sgardil
Posts: 225
Joined: Wed Aug 09, 2023 9:58 am

Re: Check Settings and Event Handler Behavior

Post by sgardil »

kenneth59 wrote: Thu Sep 12, 2024 10:30 pm Hi sgardil,

Do correct me if I misunderstood what you mean.
Assuming that this service has an event handler from a linked template and also has its own event handler configured, I will refer to the handler inherited from the template as the "inherited handler" and the service’s own handler as the "service handler."
  • If I set "event handler enable" to null, the service will use its own event handler, which is the "service handler."
  • If I set "event handler enable" to skip, the service will use the inherited event handler, which is the "inherited handler."
  • I assume setting "event handler enable" to off will completely stop the handler from being triggered, meaning neither the "service handler" nor the "inherited handler" will be triggered.
  • If I set "event handler enable" to on, it will first use the "service handler." If the "service handler" is missing, it will fall back to the "inherited handler."
Is this understanding correct?
To follow up a little on your example, using null and skip are for that specific item. So if you put skip in on the event handler enabled, it will use the value from the template for the event handler enabled section. @snapier3 gave a nice concise answer for how it works and I would highly recommend taking a look at the documentation they linked about object inheritance.
kenneth59
Posts: 23
Joined: Tue Apr 16, 2024 10:03 pm

Re: Check Settings and Event Handler Behavior

Post by kenneth59 »

Hi @sgardil and @snapier3,

Thank you for both of your explanations, @snapier3. After reviewing your last post and going through the documentation, I also conducted a test on my VM. I now understand how off and null work and how the inheritance functions. However, I still don’t see any difference between setting the event handler to on and skip.

Here’s my current understanding:
  • null: Will use the local event handler, even if no event handler is set.
  • off: Will completely disable the event handler, preventing it from being triggered.
When the local event handler is empty:
  • skip and on: Will take the handler from the template.
When the local event handler is not empty (with a "service handler"):
  • skip and on: Will use the local event handler.

Additional note:
From the documentation I was initially looking at, it seems that skip is supposed to inherit the event handler from the template. However, based on my test in Nagios 5.8.9, it appears that skip is actually taking the value from the local event handler (service handler).

If there’s something I’m missing, I’d appreciate any clarification.
snapier3
Posts: 115
Joined: Tue Apr 23, 2019 7:12 pm

Re: Check Settings and Event Handler Behavior

Post by snapier3 »

I urge you to upgrade your version of XI to 5.10 at a minimum.
--SN
kenneth59
Posts: 23
Joined: Tue Apr 16, 2024 10:03 pm

Re: Check Settings and Event Handler Behavior

Post by kenneth59 »

Thank you for your suggestion. We will consider upgrading it.
Post Reply