diff --git a/lib/icinga/comment.ti b/lib/icinga/comment.ti index 8fbb2da17..2863f5608 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 6d6249d9f..6cd85742b 100644 --- a/lib/icinga/dependency.ti +++ b/lib/icinga/dependency.ti @@ -44,11 +44,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; }}} }; @@ -71,11 +73,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 b1530abe1..2193732db 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 e8c4418cd..7ee3d88fb 100644 --- a/lib/icinga/notification.ti +++ b/lib/icinga/notification.ti @@ -69,11 +69,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 c44228b1c..15b7b59d4 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; }}} };