ido: Update hosts when their host check is updated.

This commit is contained in:
Gunnar Beutner 2013-07-25 08:30:02 +02:00
parent 28726e5025
commit b2b1040090
4 changed files with 60 additions and 1 deletions

View 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);

View 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;

View File

@ -151,3 +151,41 @@ 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();
}

View 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);
};
}