Page 1 of 1
Looking for the equivalent of $LASTSERVICESTATETYPE$
Posted: Wed Feb 12, 2014 2:46 pm
by skynardo
I am in need of determining the $LASTSERVICESTATETYPE$ (Hard or Soft) and found that this Macro is not available. I was trying to find a way to determine this using the Macros that are available. So if current service state is OK, would like to find out if lastservicestate was not OK, and if not, was that lastservicestate a Hard or Soft state type?
Re: Looking for the equivalent of $LASTSERVICESTATETYPE$
Posted: Wed Feb 12, 2014 3:23 pm
by abrist
There are actually a bunch of macros with last* information. The one in particular you are looking for is:
Code: Select all
$LASTSERVICESTATEID$ A number that corresponds to the last state of the service: 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN.
Some others of interest:
Code: Select all
$LASTSERVICECHECK$
This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which a check of the service was last performed.
$LASTSERVICESTATECHANGE$
This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time the service last changed state.
$LASTSERVICEOK$
This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the service was last detected as being in an OK state.
$LASTSERVICEWARNING$
This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the service was last detected as being in a WARNING state.
$LASTSERVICEUNKNOWN$
This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the service was last detected as being in an UNKNOWN state.
$LASTSERVICECRITICAL$
This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the service was last detected as being in a CRITICAL state.
Check them out yourself at:
http://nagios.sourceforge.net/docs/3_0/ ... icestateid
Re: Looking for the equivalent of $LASTSERVICESTATETYPE$
Posted: Wed Feb 12, 2014 3:41 pm
by skynardo
Correct, but none of those tell me what the $LASTSERVICESTATE$ "TYPE" is. I need to know if it was a Hard or Soft "TYPE". I apologise if I am missing something obvious here.
Re: Looking for the equivalent of $LASTSERVICESTATETYPE$
Posted: Wed Feb 12, 2014 5:45 pm
by abrist
Dang, I missed that. I have yet to test these macros, but I would suspect that they are agnostic in relation to the type of the previous state. I will test tomorrow if I have time.
Worse case scenario, you could track the type yourself with a custom event handler, but I feel that this may be worthy of a feature request on
http://tracker.nagios.org