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 .
How to reset service state and Attempt
-
- Posts: 43
- Joined: Wed Mar 21, 2018 1:11 pm
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to reset service state and Attempt
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
hosts
https://old.nagios.org/developerinfo/ex ... and_id=112
services
https://old.nagios.org/developerinfo/ex ... and_id=113
-
- Posts: 43
- Joined: Wed Mar 21, 2018 1:11 pm
Re: How to reset service state and Attempt
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 )
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 )
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to reset service state and Attempt
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.
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.
-
- Posts: 43
- Joined: Wed Mar 21, 2018 1:11 pm
Re: How to reset service state and Attempt
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 ?
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 ?
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to reset service state and Attempt
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
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
-
- Posts: 43
- Joined: Wed Mar 21, 2018 1:11 pm
Re: How to reset service state and Attempt
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
https://assets.nagios.com/downloads/nag ... olist.html
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to reset service state and Attempt
Sorry, there are no macros for thosesatheesh19870819 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