Need help on Macro name

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Need help on Macro name

Post by bsivavani »

Hi,

Can you let me know the macro name for red highlighted value (2). We would like to restart the service at SOFT 2.

Event Handler 2017-10-25 20:03:12 SERVICE EVENT HANDLER: s910a3000;test_service_restart;CRITICAL;SOFT;2;gwd_service_restart
Event Handler 2017-10-25 20:03:12 GLOBAL SERVICE EVENT HANDLER: s910a3000;test_service_restart;CRITICAL;SOFT;2;xi_service_event_handler
Service Critical 2017-10-25 20:03:12 SERVICE ALERT: s910a3000;test_service_restart;CRITICAL;SOFT;2;iphlpsvc: Stopped

Kindly advice ?
kyang

Re: Need help on Macro name

Post by kyang »

You are probably looking for the macro of $HOSTSTATETYPE$ or $SERVICESTATETYPE$
The $HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of "SOFT" when event handlers are executed, which allows your event handler scripts to know when they should take corrective action. More information on event handlers can be found here
Here's the link for an explanation as well.

https://assets.nagios.com/downloads/nag ... types.html

Does this help?
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Re: Need help on Macro name

Post by bsivavani »

Hi,

We would like to execute the service at SOFT 2, not in HARD and SOFT1 state.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Need help on Macro name

Post by npolovenko »

Thanks for the reference, @kyang!
@bsivavani, Seems like the macro that you're looking for is called $SERVICESTATETYPE$ .
We would like to execute the service at SOFT 2, not in HARD and SOFT1 state.
Generally, in Nagios OK state refers to 1(SOFT STATE), WARNING is 2(soft state), and CRITICAL is 3(hard state).

Could you describe what you're trying to achieve? Seems like you want the event handler to start working after the second warning, but before the critical state?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Need help on Macro name

Post by mcapra »

In a pseudocode, to capture a SOFT 2:

Code: Select all

if(($SERVICESTATETYPE$ == 'SOFT') && ($SERVICESTATEID$ == 2)) {
    // do the thing
}
Former Nagios employee
https://www.mcapra.com/
kyang

Re: Need help on Macro name

Post by kyang »

Thanks for the example @mcapra!

@bsivavani, does this help?
bsivavani
Posts: 339
Joined: Tue Oct 06, 2015 9:17 am

Re: Need help on Macro name

Post by bsivavani »

Hi,

Thanks for the update. We have tested the suggested solution but it is not working, the macro SERVICESTATEID has different definition.

$SERVICESTATEID$ - A number that corresponds to the current state of the service: 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Need help on Macro name

Post by mcapra »

Ah, I've been out of the game too long ;)

In the context of those log entries, the 2 actually represents the current attempt (logging.c#L270-L275), eg how many times a problem state has been detected since the last OK state. See if $SERVICEATTEMPT$ gets you what you're looking for:

Code: Select all

if(($SERVICESTATETYPE$ == 'SOFT') && ($SERVICEATTEMPT$ == 2)) {
    // do the thing
}
Former Nagios employee
https://www.mcapra.com/
kyang

Re: Need help on Macro name

Post by kyang »

Thanks again for the example @mcapra!

@bsivavani, let us know if this works for you.
Locked