diff --git a/lib/icinga/comment.ti b/lib/icinga/comment.ti index b8ad6f7f252..e51281b33b6 100644 --- a/lib/icinga/comment.ti +++ b/lib/icinga/comment.ti @@ -52,11 +52,13 @@ class Comment : ConfigObject < CommentNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/dependency.ti b/lib/icinga/dependency.ti index 41de7ba23cf..4c139078dee 100644 --- a/lib/icinga/dependency.ti +++ b/lib/icinga/dependency.ti @@ -42,11 +42,13 @@ class Dependency : CustomVarObject < DependencyNameComposer } }}} navigate {{{ - if (GetChildServiceName().IsEmpty()) - return nullptr; + if (!GetChildServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetChildHostName()); + if (host) + return host->GetServiceByShortName(GetChildServiceName()); + } - Host::Ptr host = Host::GetByName(GetChildHostName()); - return host->GetServiceByShortName(GetChildServiceName()); + return nullptr; }}} }; @@ -69,11 +71,13 @@ class Dependency : CustomVarObject < DependencyNameComposer } }}} navigate {{{ - if (GetParentServiceName().IsEmpty()) - return nullptr; + if (!GetParentServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetParentHostName()); + if (host) + return host->GetServiceByShortName(GetParentServiceName()); + } - Host::Ptr host = Host::GetByName(GetParentHostName()); - return host->GetServiceByShortName(GetParentServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/downtime.ti b/lib/icinga/downtime.ti index 21e97313eae..f6aeecd626c 100644 --- a/lib/icinga/downtime.ti +++ b/lib/icinga/downtime.ti @@ -43,11 +43,13 @@ class Downtime : ConfigObject < DowntimeNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti index 48536075748..b7db178b5a3 100644 --- a/lib/icinga/notification.ti +++ b/lib/icinga/notification.ti @@ -61,11 +61,13 @@ class Notification : CustomVarObject < NotificationNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/scheduleddowntime.ti b/lib/icinga/scheduleddowntime.ti index 1653f27e74d..69a7153d5bc 100644 --- a/lib/icinga/scheduleddowntime.ti +++ b/lib/icinga/scheduleddowntime.ti @@ -44,11 +44,13 @@ class ScheduledDowntime : CustomVarObject < ScheduledDowntimeNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} };