]> granicus.if.org Git - icinga2/commitdiff
ido: Update hosts when their host check is updated.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 25 Jul 2013 06:30:02 +0000 (08:30 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 25 Jul 2013 06:30:02 +0000 (08:30 +0200)
lib/ido/dbobject.cpp
lib/ido/dbobject.h
lib/ido/servicedbobject.cpp
lib/ido/servicedbobject.h

index c19aad7b90369f6a613379e7e768168347f9dacd..e4da10a400dc52dc46bde50d6ed711ba9128d89d 100644 (file)
@@ -92,6 +92,8 @@ void DbObject::SendConfigUpdate(void)
        OnQuery(query2);
 
        m_LastConfigUpdate = Utility::GetTime();
+
+       OnConfigUpdate();
 }
 
 void DbObject::SendStatusUpdate(void)
@@ -118,6 +120,8 @@ void DbObject::SendStatusUpdate(void)
        OnQuery(query2);
 
        m_LastStatusUpdate = Utility::GetTime();
+
+       OnStatusUpdate();
 }
 
 double DbObject::GetLastConfigUpdate(void) const
@@ -149,6 +153,16 @@ bool DbObject::IsStatusAttribute(const String&) const
        return false;
 }
 
+void DbObject::OnConfigUpdate(void)
+{
+       /* Default handler does nothing. */
+}
+
+void DbObject::OnStatusUpdate(void)
+{
+       /* Default handler does nothing. */
+}
+
 DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
 {
        DbObject::Ptr dbobj = static_pointer_cast<DbObject>(object->GetExtension("DbObject"));
@@ -210,7 +224,6 @@ void DbObject::ObjectUnregisteredHandler(const DynamicObject::Ptr& object)
                return;
 
        OnUnregistered(dbobj);
-       //dbobj->SendUpdate(DbObjectRemoved);
 
        {
                ObjectLock olock(object);
index e1b351904a6fd1bcfdbe4d14e9e7eac724ab9671..0f6d47d7195e0f13272fdb36e41c33cb5bc3a4cb 100644 (file)
@@ -74,6 +74,9 @@ protected:
        virtual bool IsConfigAttribute(const String& attribute) const;
        virtual bool IsStatusAttribute(const String& attribute) const;
 
+       virtual void OnConfigUpdate(void);
+       virtual void OnStatusUpdate(void);
+
 private:
        String m_Name1;
        String m_Name2;
index 576f27341becca68e2b77b28a65af6620b83835c..712c53e87102f4b647838de49965feb1ab68eda9 100644 (file)
@@ -150,4 +150,42 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields(void) const
 bool ServiceDbObject::IsStatusAttribute(const String& attribute) const
 {
        return (attribute == "last_result");
+}
+
+void ServiceDbObject::OnConfigUpdate(void)
+{
+       Service::Ptr service = static_pointer_cast<Service>(GetObject());
+       Host::Ptr host = service->GetHost();
+
+       if (!host)
+               return;
+
+       if (host->GetHostCheckService() != service)
+               return;
+
+       DbObject::Ptr dbobj = GetOrCreateByObject(host);
+
+       if (!dbobj)
+               return;
+
+       dbobj->SendConfigUpdate();
+}
+
+void ServiceDbObject::OnStatusUpdate(void)
+{
+       Service::Ptr service = static_pointer_cast<Service>(GetObject());
+       Host::Ptr host = service->GetHost();
+
+       if (!host)
+               return;
+
+       if (host->GetHostCheckService() != service)
+               return;
+
+       DbObject::Ptr dbobj = GetOrCreateByObject(host);
+
+       if (!dbobj)
+               return;
+
+       dbobj->SendStatusUpdate();
 }
\ No newline at end of file
index 28a98b92aff34b294e8d429a9f74e52edf59de0e..7346e1afade6f6d6f2186b1ea3669a43e0b417e3 100644 (file)
@@ -41,7 +41,12 @@ public:
        virtual Dictionary::Ptr GetConfigFields(void) const;
        virtual Dictionary::Ptr GetStatusFields(void) const;
 
+protected:
        virtual bool IsStatusAttribute(const String& attribute) const;
+
+       virtual void OnConfigUpdate(void);
+       virtual void OnStatusUpdate(void);
+
 };
 
 }