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
Duration of a state when state changes
-
saleemthupsee
- Posts: 107
- Joined: Wed Feb 15, 2017 4:22 am
- Location: Paris France
- Contact:
Duration of a state when state changes
Saleem THUPSEE
Re: Duration of a state when state changes
If I'm understanding you correctly, this feature request should satisfy your use case:
https://github.com/NagiosEnterprises/na ... issues/451
https://github.com/NagiosEnterprises/na ... issues/451
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Duration of a state when state changes
Thanks @mcapra!
@saleemthupsee Is it OK to close this topic as a feature request has been filed already for adding this functionality?
@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
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.
"$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
Re: Duration of a state when state changes
@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!