Problem: Event handler runs in soft state

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
parisa
Posts: 62
Joined: Tue Sep 25, 2018 3:18 am

Problem: Event handler runs in soft state

Post by parisa »

Hello
I have around 100 hosts and I defined around 25 services for each host in Nagios XI (around 2500 services.), I use SNMP Trap (passive check) to check our services.
Also I have defined "event handler" , "retry interval" and "max check attempts" for each service.
When I receive a trap for a service, the soft state of service changes but because of I have defined setting as below:
Retry interval: 10 mins
Max check attempts: 4
it's expected that soft state changes to hard state after 30 minutes if the alarm remained, then run event handler.

But I faced with a problem, the event handler run in soft state immediately.
is it true that event handler run in hard state even in passive check, I don't have any idea why this case happens.
would you please guide me about this?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Problem: Event handler runs in soft state

Post by npolovenko »

Hello, @parisa. Event handlers run in soft and hard states.
When Are Event Handlers Executed?
Event handlers are executed when a service or host:

Is in a SOFT problem state
Initially goes into a HARD problem state
Initially recovers from a SOFT or HARD problem state
https://assets.nagios.com/downloads/nag ... dlers.html

If you want the event handler to ONLY execute on a hard critical state you can either:
Create a condition in the event handler script that checks whether the state is hard or soft before executing the main part of the script.
Or you can try assigning your event handler script as a notification command. Notification commands only activate of Hard states.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
parisa
Posts: 62
Joined: Tue Sep 25, 2018 3:18 am

Re: Problem: Event handler runs in soft state

Post by parisa »

Thanks for your answer @npolovenko .
So, I should use "state_type" field from "nagios_servicestatus" table or "SERVICESTATETYPE$" macro in event-handler scripts to be able to recognize hard/soft state.

I have another question ,when an alarm happens and recovers before it goes to hard state (recovers in soft state), are state_type=soft in OK state of that service ?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Problem: Event handler runs in soft state

Post by lmiltchev »

I have another question ,when an alarm happens and recovers before it goes to hard state (recovers in soft state), are state_type=soft in OK state of that service ?
Yes, this would be a soft recovery.

Quote from our official documentation:
When a service or host recovers from a soft error. This is considered a soft recovery.
https://assets.nagios.com/downloads/nag ... types.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
parisa
Posts: 62
Joined: Tue Sep 25, 2018 3:18 am

Re: Problem: Event handler runs in soft state

Post by parisa »

I faced with another reaction, I have a service that it has been configured as below:
Retry interval =1
Max check attempts=2
Active checks enabled=off
Active checks enabled=on

But based attached file, When the service recovered from a soft state error, OK state is hard. Would you please guide me about the case?
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Problem: Event handler runs in soft state

Post by lmiltchev »

You may see a "HARD" state in the GUI, but the service could've been is a "SOFT" state prior to this. A soft recovery is marked as SOFT;x;OK then it goes to HARD set to 1 in the interface. To be sure, you will need to check the nagios log.

Also, you posted this:
Retry interval =1
Max check attempts=2
Active checks enabled=off
Active checks enabled=on
What is the actual value of active check enabled - on or off? What is the version of Nagios XI that you are currently using?
Be sure to check out our Knowledgebase for helpful articles and solutions!
parisa
Posts: 62
Joined: Tue Sep 25, 2018 3:18 am

Re: Problem: Event handler runs in soft state

Post by parisa »

Excuse me, I use passive check (SNMP Trap )the config is as below:
Retry interval =1
Max check attempts=2
Active checks enabled=off
Passive checks enabled=on

I have installed last version (5.5.11)
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Problem: Event handler runs in soft state

Post by lmiltchev »

There was a bug with soft recoveries, but since you are using the latest XI, the bug would be fixed on your system.

As I mentioned - "A soft recovery is marked as SOFT;x;OK then it goes to HARD set to 1 in the interface." Did you have a chance to review the nagios.log?
Be sure to check out our Knowledgebase for helpful articles and solutions!
parisa
Posts: 62
Joined: Tue Sep 25, 2018 3:18 am

Re: Problem: Event handler runs in soft state

Post by parisa »

excuse me for my delay
I checked nagios.log and observe the same log.
related log is attached.
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Problem: Event handler runs in soft state

Post by lmiltchev »

Oh, I believe you are experiencing a different bug. You service never went to a hard non-ok state, but it recovered to a hard ok state on the very last check attempt (Max check attempts=2).

The issue is described here:

https://github.com/NagiosEnterprises/na ... issues/624
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked