[icinga-checkins] icinga.org: icinga2/master: service: add IsHostCheck helper

git at icinga.org git at icinga.org
Tue Jul 9 16:59:49 CEST 2013


Module: icinga2
Branch: master
Commit: 30236860422af4f49d23ac119f869014483b29fe
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=30236860422af4f49d23ac119f869014483b29fe

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue Jul  9 16:59:31 2013 +0200

service: add IsHostCheck helper

---

 lib/icinga/host.cpp    |    1 +
 lib/icinga/service.cpp |   13 +++++++++++++
 lib/icinga/service.h   |    2 ++
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index 635b886..8ca6738 100644
--- a/lib/icinga/host.cpp
+++ b/lib/icinga/host.cpp
@@ -314,6 +314,7 @@ int Host::GetTotalServices(void) const
 {
 	return GetServices().size();
 }
+
 void Host::InvalidateServicesCache(void)
 {
 	{
diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp
index f1ca518..f70e29a 100644
--- a/lib/icinga/service.cpp
+++ b/lib/icinga/service.cpp
@@ -200,6 +200,19 @@ String Service::GetShortName(void) const
 		return m_ShortName;
 }
 
+bool Service::IsHostCheck(void) const
+{
+	ASSERT(!OwnsLock());
+
+	Service::Ptr hc = GetHost()->GetHostCheckService();
+
+	if (!hc)
+		return false;
+
+	return (hc->GetName() == GetName());
+
+}
+
 bool Service::IsReachable(void) const
 {
 	ASSERT(!OwnsLock());
diff --git a/lib/icinga/service.h b/lib/icinga/service.h
index 4305321..1535947 100644
--- a/lib/icinga/service.h
+++ b/lib/icinga/service.h
@@ -122,6 +122,8 @@ public:
 	std::set<Host::Ptr> GetParentHosts(void) const;
 	std::set<Service::Ptr> GetParentServices(void) const;
 
+	bool IsHostCheck(void) const;
+
 	bool IsVolatile(void) const;
 
 	bool IsReachable(void) const;





More information about the icinga-checkins mailing list