diff --git a/doc/14-migrating-from-icinga-1x.md b/doc/14-migrating-from-icinga-1x.md index 890e82736..64cb7b035 100644 --- a/doc/14-migrating-from-icinga-1x.md +++ b/doc/14-migrating-from-icinga-1x.md @@ -1040,6 +1040,7 @@ Changes to service runtime macros LASTSERVICESTATEID | service.last_state_id LASTSERVICESTATETYPE | service.last_state_type LASTSERVICESTATECHANGE | service.last_state_change + SERVICEDOWNTIME | service.downtime_depth SERVICEDURATIONSEC | service.duration_sec SERVICELATENCY | service.latency SERVICEEXECUTIONTIME | service.execution_time @@ -1070,6 +1071,7 @@ Changes to host runtime macros LASTHOSTSTATEID | host.last_state_id LASTHOSTSTATETYPE | host.last_state_type LASTHOSTSTATECHANGE | host.last_state_change + HOSTDOWNTIME | host.downtime_depth HOSTDURATIONSEC | host.duration_sec HOSTLATENCY | host.latency HOSTEXECUTIONTIME | host.execution_time diff --git a/doc/3-monitoring-basics.md b/doc/3-monitoring-basics.md index 3d01e9c98..7a8563999 100644 --- a/doc/3-monitoring-basics.md +++ b/doc/3-monitoring-basics.md @@ -2034,6 +2034,7 @@ hosts or services: host.last_state_id | The host's previous state. Can be one of `0` (up), `1` (down) and `2` (unreachable). host.last_state_type | The host's previous state type. Can be one of `SOFT` and `HARD`. host.last_state_change | The last state change's timestamp. + host.downtime_depth | The number of active downtimes. host.duration_sec | The time since the last state change. host.latency | The host's check latency. host.execution_time | The host's check execution time. @@ -2066,6 +2067,7 @@ services: service.last_state_id | The service's previous state. Can be one of `0` (ok), `1` (warning), `2` (critical) and `3` (unknown). service.last_state_type | The service's previous state type. Can be one of `SOFT` and `HARD`. service.last_state_change | The last state change's timestamp. + service.downtime_depth | The number of active downtimes. service.duration_sec | The time since the last state change. service.latency | The service's check latency. service.execution_time | The service's check execution time. diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 05c73f731..5d56d8ab8 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -234,6 +234,9 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *res } else if (macro == "last_state_change") { *result = Convert::ToString((long)GetLastStateChange()); return true; + } else if (macro == "downtime_depth") { + *result = Convert::ToString((long)GetDowntimeDepth()); + return true; } else if (macro == "duration_sec") { *result = Convert::ToString((long)(Utility::GetTime() - GetLastStateChange())); return true; diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index 4b526a4f6..fde4edae4 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -157,6 +157,9 @@ bool Service::ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Valu } else if (macro == "last_state_change") { *result = Convert::ToString((long)GetLastStateChange()); return true; + } else if (macro == "downtime_depth") { + *result = Convert::ToString((long)GetDowntimeDepth()); + return true; } else if (macro == "duration_sec") { *result = Convert::ToString((long)(Utility::GetTime() - GetLastStateChange())); return true;