Page 1 of 1
Duration of a state when state changes
Posted: Tue Nov 28, 2017 6:28 am
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
Re: Duration of a state when state changes
Posted: Tue Nov 28, 2017 9:43 am
by mcapra
If I'm understanding you correctly, this feature request should satisfy your use case:
https://github.com/NagiosEnterprises/na ... issues/451
Re: Duration of a state when state changes
Posted: Tue Nov 28, 2017 10:48 am
by lmiltchev
Thanks @mcapra!
@saleemthupsee Is it OK to close this topic as a feature request has been filed already for adding this functionality?
Re: Duration of a state when state changes
Posted: Wed Nov 29, 2017 10:04 am
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.
Re: Duration of a state when state changes
Posted: Wed Nov 29, 2017 10:15 am
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.