Looking for the equivalent of $LASTSERVICESTATETYPE$

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Looking for the equivalent of $LASTSERVICESTATETYPE$

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Looking for the equivalent of $LASTSERVICESTATETYPE$

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Re: Looking for the equivalent of $LASTSERVICESTATETYPE$

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Looking for the equivalent of $LASTSERVICESTATETYPE$

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked