mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
ido: Update hosts when their host check is updated.
This commit is contained in:
parent
28726e5025
commit
b2b1040090
@ -92,6 +92,8 @@ void DbObject::SendConfigUpdate(void)
|
|||||||
OnQuery(query2);
|
OnQuery(query2);
|
||||||
|
|
||||||
m_LastConfigUpdate = Utility::GetTime();
|
m_LastConfigUpdate = Utility::GetTime();
|
||||||
|
|
||||||
|
OnConfigUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbObject::SendStatusUpdate(void)
|
void DbObject::SendStatusUpdate(void)
|
||||||
@ -118,6 +120,8 @@ void DbObject::SendStatusUpdate(void)
|
|||||||
OnQuery(query2);
|
OnQuery(query2);
|
||||||
|
|
||||||
m_LastStatusUpdate = Utility::GetTime();
|
m_LastStatusUpdate = Utility::GetTime();
|
||||||
|
|
||||||
|
OnStatusUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
double DbObject::GetLastConfigUpdate(void) const
|
double DbObject::GetLastConfigUpdate(void) const
|
||||||
@ -149,6 +153,16 @@ bool DbObject::IsStatusAttribute(const String&) const
|
|||||||
return false;
|
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 DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
|
||||||
{
|
{
|
||||||
DbObject::Ptr dbobj = static_pointer_cast<DbObject>(object->GetExtension("DbObject"));
|
DbObject::Ptr dbobj = static_pointer_cast<DbObject>(object->GetExtension("DbObject"));
|
||||||
@ -210,7 +224,6 @@ void DbObject::ObjectUnregisteredHandler(const DynamicObject::Ptr& object)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
OnUnregistered(dbobj);
|
OnUnregistered(dbobj);
|
||||||
//dbobj->SendUpdate(DbObjectRemoved);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(object);
|
ObjectLock olock(object);
|
||||||
|
@ -74,6 +74,9 @@ protected:
|
|||||||
virtual bool IsConfigAttribute(const String& attribute) const;
|
virtual bool IsConfigAttribute(const String& attribute) const;
|
||||||
virtual bool IsStatusAttribute(const String& attribute) const;
|
virtual bool IsStatusAttribute(const String& attribute) const;
|
||||||
|
|
||||||
|
virtual void OnConfigUpdate(void);
|
||||||
|
virtual void OnStatusUpdate(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_Name1;
|
String m_Name1;
|
||||||
String m_Name2;
|
String m_Name2;
|
||||||
|
@ -151,3 +151,41 @@ bool ServiceDbObject::IsStatusAttribute(const String& attribute) const
|
|||||||
{
|
{
|
||||||
return (attribute == "last_result");
|
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();
|
||||||
|
}
|
@ -41,7 +41,12 @@ public:
|
|||||||
virtual Dictionary::Ptr GetConfigFields(void) const;
|
virtual Dictionary::Ptr GetConfigFields(void) const;
|
||||||
virtual Dictionary::Ptr GetStatusFields(void) const;
|
virtual Dictionary::Ptr GetStatusFields(void) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual bool IsStatusAttribute(const String& attribute) const;
|
virtual bool IsStatusAttribute(const String& attribute) const;
|
||||||
|
|
||||||
|
virtual void OnConfigUpdate(void);
|
||||||
|
virtual void OnStatusUpdate(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user