How to reset service state and Attempt

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

How to reset service state and Attempt

Postby satheesh19870819 » Tue Apr 24, 2018 1:32 am

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 .
satheesh19870819
 
Posts: 14
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Postby scottwilkerson » Tue Apr 24, 2018 3:03 pm

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/externalcommands/commandinfo.php?command_id=112
services
https://old.nagios.org/developerinfo/externalcommands/commandinfo.php?command_id=113
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
CTO
 
Posts: 9816
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How to reset service state and Attempt

Postby satheesh19870819 » Thu Apr 26, 2018 8:12 am

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 )
satheesh19870819
 
Posts: 14
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Postby scottwilkerson » Thu Apr 26, 2018 9:10 am

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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
CTO
 
Posts: 9816
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How to reset service state and Attempt

Postby satheesh19870819 » Thu May 10, 2018 4:59 am

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 ?
satheesh19870819
 
Posts: 14
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Postby scottwilkerson » Thu May 10, 2018 2:44 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
CTO
 
Posts: 9816
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: How to reset service state and Attempt

Postby satheesh19870819 » Mon May 21, 2018 2:23 am

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/nagioscore/docs/nagioscore/3/en/macrolist.html
satheesh19870819
 
Posts: 14
Joined: Wed Mar 21, 2018 1:11 pm

Re: How to reset service state and Attempt

Postby scottwilkerson » Mon May 21, 2018 2:03 pm

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/nagioscore/docs/nagioscore/3/en/macrolist.html


Sorry, there are no macros for those
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
CTO
 
Posts: 9816
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests