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 ?
Need help on Macro name
-
kyang
Re: Need help on Macro name
You are probably looking for the macro of $HOSTSTATETYPE$ or $SERVICESTATETYPE$
https://assets.nagios.com/downloads/nag ... types.html
Does this help?
Here's the link for an explanation as well.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
https://assets.nagios.com/downloads/nag ... types.html
Does this help?
Re: Need help on Macro name
Hi,
We would like to execute the service at SOFT 2, not in HARD and SOFT1 state.
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
Thanks for the reference, @kyang!
@bsivavani, Seems like the macro that you're looking for is called $SERVICESTATETYPE$ .
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?
@bsivavani, Seems like the macro that you're looking for is called $SERVICESTATETYPE$ .
Generally, in Nagios OK state refers to 1(SOFT STATE), WARNING is 2(soft state), and CRITICAL is 3(hard state).We would like to execute the service at SOFT 2, not in HARD and SOFT1 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.
Re: Need help on Macro name
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/
https://www.mcapra.com/
Re: Need help on Macro name
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.
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.
Re: Need help on Macro name
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:
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/
https://www.mcapra.com/