Page 1 of 1

How to reset service state and Attempt

Posted: Tue Apr 24, 2018 1:32 am
by satheesh19870819
Hello Team,

I am in the process of writing a wrapper script . I need to do the logic in a way that if the service state turn to critical then in next 5 mins i need to check another check command if that results ok then service need to be exit ok ..

Event handler does not supports me as i want this to be in service output and triger alert .

Normal check interval 30
retry check interval 5
max check attempt 3

Now i wrote a script where for the first attempt of he script will check the first commands and returns the exit code . Second attempt will be reached when the service state is critical and if the attempt is two am running second command and returns the result to service .

During the third attempt it will force check for desired timing as per schedule .

Problem :

My problem is attempt is getting calculated even for warning and unknown states . Is it possible to reset the attempt to 1 for next check if the current state unknown or warning .

Re: How to reset service state and Attempt

Posted: Tue Apr 24, 2018 3:03 pm
by scottwilkerson
You can modify this as runtime changes through the command pipe with the following commands, here are some examples
hosts
https://old.nagios.org/developerinfo/ex ... and_id=112
services
https://old.nagios.org/developerinfo/ex ... and_id=113

Re: How to reset service state and Attempt

Posted: Thu Apr 26, 2018 8:12 am
by satheesh19870819
Thanks a lot for answering my query .

the above link shows how to change the number of attempts for a host/service on the go ..

My query is during the second attempt if my condition satisfied in the script then the attempt should go to 1 again in the same non-ok state (without changing the state )

Re: How to reset service state and Attempt

Posted: Thu Apr 26, 2018 9:10 am
by scottwilkerson
With all due respect, that doesn't make any sense. You are asking to reduce the amount of attempts it takes to make a notification to 1 AFTER, it has already performed the second attempt.

You cannot NOT get a result once you started plugin running.

Maybe a different plan is to make a wrapper plugin that performs a second (or third) attempt if the first one doesn't exit with a 0 exit code.

Re: How to reset service state and Attempt

Posted: Thu May 10, 2018 4:59 am
by satheesh19870819
i made a wrapper now .

I am facing another issue now . Issue is with the attempt . am getting the serviceattempt macro as one of the argument in the script . ahen a new service added initial while executing the script argumens are like

Attempt 1 ; service state OK ;

while executing script , the output is CRITICAL and exit 2 . During the next attempt

Attempt 1 ; service state CRITICAL ;

Actually the attempt should be 2 am i right . why it is again showing 1 in the marco while passing as argument .
--------------------------------------------------------------------------------------------------------------------------------------------

Second issue

i set the max check attempts as 2 , But when a new service is added its running the script 3 attempts . Why the first attempt is getting ignored ?

Re: How to reset service state and Attempt

Posted: Thu May 10, 2018 2:44 pm
by scottwilkerson
The attempt # that is being passed in is the number of times it was in the previous state.

Chen it changed to critical, the attempts still gets set to 1 because is was in critical 1 time.

There is a chare here that describes this
https://assets.nagios.com/downloads/nag ... types.html

Re: How to reset service state and Attempt

Posted: Mon May 21, 2018 2:23 am
by satheesh19870819
Thanks a lot for your clear information. I have designed the script in such way . If possible please let me know is there any Macro available for normal check interval and retry check interval as there is no macro available in the below URL
https://assets.nagios.com/downloads/nag ... olist.html

Re: How to reset service state and Attempt

Posted: Mon May 21, 2018 2:03 pm
by scottwilkerson
satheesh19870819 wrote:Thanks a lot for your clear information. I have designed the script in such way . If possible please let me know is there any Macro available for normal check interval and retry check interval as there is no macro available in the below URL
https://assets.nagios.com/downloads/nag ... olist.html
Sorry, there are no macros for those