mirror of https://github.com/Icinga/icinga2.git
Implement HOSTDURATIONSEC and SERVICEDURATIONSEC macros.
This commit is contained in:
parent
c3bcc2a474
commit
cbf82e1cb8
|
@ -96,6 +96,8 @@ hosts or services:
|
|||
LASTHOSTSTATE | The host's previous state. Can be one of `UNREACHABLE`, `UP` and `DOWN`.
|
||||
LASTHOSTSTATEID | The host's previous state. Can be one of `0` (up), `1` (down) and `2` (unreachable).
|
||||
LASTHOSTSTATETYPE | The host's previous state type. Can be one of `SOFT` and `HARD`.
|
||||
LASTHOSTSTATECHANGE | The last state change's timestamp.
|
||||
HOSTDURATIONSEC | The time since the last state change.
|
||||
HOSTLATENCY | The host's check latency.
|
||||
HOSTEXECUTIONTIME | The host's check execution time.
|
||||
HOSTOUTPUT | The last check's output.
|
||||
|
@ -123,6 +125,7 @@ services:
|
|||
LASTSERVICESTATEID | The service's previous state. Can be one of `0` (ok), `1` (warning), `2` (critical) and `3` (unknown).
|
||||
LASTSERVICESTATETYPE | The service's previous state type. Can be one of `SOFT` and `HARD`.
|
||||
LASTSERVICESTATECHANGE | The last state change's timestamp.
|
||||
SERVICEDURATIONSEC | The time since the last state change.
|
||||
SERVICELATENCY | The service's check latency.
|
||||
SERVICEEXECUTIONTIME | The service's check execution time.
|
||||
SERVICEOUTPUT | The last check's output.
|
||||
|
|
|
@ -609,6 +609,9 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
|
|||
} else if (macro == "LASTHOSTSTATECHANGE") {
|
||||
*result = Convert::ToString((long)hc->GetLastStateChange());
|
||||
return true;
|
||||
} else if (macro == "HOSTDURATIONSEC") {
|
||||
*result = Convert::ToString((long)(Utility::GetTime() - hc->GetLastStateChange()));
|
||||
return true;
|
||||
}
|
||||
|
||||
hccr = hc->GetLastCheckResult();
|
||||
|
|
|
@ -424,6 +424,9 @@ bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
|
|||
} else if (macro == "LASTSERVICESTATECHANGE") {
|
||||
*result = Convert::ToString((long)GetLastStateChange());
|
||||
return true;
|
||||
} else if (macro == "SERVICEDURATIONSEC") {
|
||||
*result = Convert::ToString((long)(Utility::GetTime() - GetLastStateChange()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cr) {
|
||||
|
|
Loading…
Reference in New Issue