Duration of a state when state changes

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
saleemthupsee
Posts: 107
Joined: Wed Feb 15, 2017 4:22 am
Location: Paris France
Contact:

Duration of a state when state changes

Post by saleemthupsee »

Hello,

is there a way to obtain the duration of a state of a service in a prior state through the event handler ?

i.e. : The state of the service changed to OK prior to being in critical. Can the duration of the state of the service being in critical be obtained when the state changes to OK. I need that for reporting purposes through a script.

Saleem
Paris
Saleem THUPSEE
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Duration of a state when state changes

Post by mcapra »

If I'm understanding you correctly, this feature request should satisfy your use case:
https://github.com/NagiosEnterprises/na ... issues/451
Former Nagios employee
https://www.mcapra.com/
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Duration of a state when state changes

Post by lmiltchev »

Thanks @mcapra!

@saleemthupsee Is it OK to close this topic as a feature request has been filed already for adding this functionality?
Be sure to check out our Knowledgebase for helpful articles and solutions!
saleemthupsee
Posts: 107
Joined: Wed Feb 15, 2017 4:22 am
Location: Paris France
Contact:

Re: Duration of a state when state changes

Post by saleemthupsee »

Sure @mcapra. I have found another solution to keep going in the mean time is to use through the event handler the following variables:
"$SERVICESTATE$" $LASTSERVICESTATE$ $LASTSERVICEOK$ $LASTSERVICECRITICAL$. A combination of those variables having a timestamp get the job done, with a combination of any OK,CRITICAL states.

$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.
Saleem THUPSEE
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Duration of a state when state changes

Post by lmiltchev »

@saleemthupsee It seems like you found a solution. I am locking this topic, and marking it as resolved. If you have any more questions/issues, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked