diff --git a/lib/ido/dbobject.cpp b/lib/ido/dbobject.cpp index c19aad7b9..e4da10a40 100644 --- a/lib/ido/dbobject.cpp +++ b/lib/ido/dbobject.cpp @@ -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(object->GetExtension("DbObject")); @@ -210,7 +224,6 @@ void DbObject::ObjectUnregisteredHandler(const DynamicObject::Ptr& object) return; OnUnregistered(dbobj); - //dbobj->SendUpdate(DbObjectRemoved); { ObjectLock olock(object); diff --git a/lib/ido/dbobject.h b/lib/ido/dbobject.h index e1b351904..0f6d47d71 100644 --- a/lib/ido/dbobject.h +++ b/lib/ido/dbobject.h @@ -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; diff --git a/lib/ido/servicedbobject.cpp b/lib/ido/servicedbobject.cpp index 576f27341..712c53e87 100644 --- a/lib/ido/servicedbobject.cpp +++ b/lib/ido/servicedbobject.cpp @@ -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(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(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 diff --git a/lib/ido/servicedbobject.h b/lib/ido/servicedbobject.h index 28a98b92a..7346e1afa 100644 --- a/lib/ido/servicedbobject.h +++ b/lib/ido/servicedbobject.h @@ -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); + }; }