How to reset service state and Attempt

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
satheesh19870819
Posts: 43
Joined: Wed Mar 21, 2018 1:11 pm

How to reset service state and Attempt

Post 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 .
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to reset service state and Attempt

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
satheesh19870819
Posts: 43
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Post 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 )
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to reset service state and Attempt

Post 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.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
satheesh19870819
Posts: 43
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Post 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 ?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to reset service state and Attempt

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
satheesh19870819
Posts: 43
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to reset service state and Attempt

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked