mirror of https://github.com/Icinga/icinga2.git
parent
097bb5ac97
commit
fc7d7cc9eb
|
@ -1420,7 +1420,6 @@ ALTER TABLE icinga_servicechecks ADD COLUMN endpoint_object_id bigint default NU
|
|||
ALTER TABLE icinga_statehistory ADD COLUMN endpoint_object_id bigint default NULL;
|
||||
ALTER TABLE icinga_systemcommands ADD COLUMN endpoint_object_id bigint default NULL;
|
||||
|
||||
|
||||
-- -----------------------------------------
|
||||
-- add index (delete)
|
||||
-- -----------------------------------------
|
||||
|
|
|
@ -44,7 +44,7 @@ INITIALIZE_ONCE(&DynamicObject::StaticInitialize);
|
|||
|
||||
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStarted;
|
||||
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStopped;
|
||||
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStateChanged;
|
||||
boost::signals2::signal<void (const DynamicObject::Ptr&, const String&)> DynamicObject::OnStateChanged;
|
||||
boost::signals2::signal<void (const DynamicObject::Ptr&, const String&, bool)> DynamicObject::OnAuthorityChanged;
|
||||
|
||||
void DynamicObject::StaticInitialize(void)
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStarted;
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStopped;
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStateChanged;
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&, const String&)> OnStateChanged;
|
||||
static boost::signals2::signal<void (const DynamicObject::Ptr&, const String&, bool)> OnAuthorityChanged;
|
||||
|
||||
Value InvokeMethod(const String& method, const std::vector<Value>& arguments);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "db_ido/dbtype.h"
|
||||
#include "db_ido/dbvalue.h"
|
||||
#include "icinga/service.h"
|
||||
#include "cluster/endpoint.h"
|
||||
#include "base/dynamictype.h"
|
||||
#include "base/objectlock.h"
|
||||
#include "base/utility.h"
|
||||
|
@ -41,7 +42,7 @@ DbObject::DbObject(const shared_ptr<DbType>& type, const String& name1, const St
|
|||
void DbObject::StaticInitialize(void)
|
||||
{
|
||||
/* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */
|
||||
DynamicObject::OnStateChanged.connect(boost::bind(&DbObject::StateChangedHandler, _1));
|
||||
DynamicObject::OnStateChanged.connect(boost::bind(&DbObject::StateChangedHandler, _1, _2));
|
||||
}
|
||||
|
||||
void DbObject::SetObject(const DynamicObject::Ptr& object)
|
||||
|
@ -95,10 +96,12 @@ void DbObject::SendConfigUpdate(void)
|
|||
OnConfigUpdate();
|
||||
}
|
||||
|
||||
void DbObject::SendStatusUpdate(void)
|
||||
void DbObject::SendStatusUpdate(const String& authority)
|
||||
{
|
||||
Dictionary::Ptr fields = GetStatusFields();
|
||||
|
||||
Endpoint::Ptr endpoint = Endpoint::GetByName(authority);
|
||||
|
||||
if (!fields)
|
||||
return;
|
||||
|
||||
|
@ -109,6 +112,10 @@ void DbObject::SendStatusUpdate(void)
|
|||
query.Fields = fields;
|
||||
query.Fields->Set(GetType()->GetIDColumn(), GetObject());
|
||||
query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
if (endpoint)
|
||||
query.Fields->Set("endpoint_object_id", endpoint);
|
||||
|
||||
query.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
|
||||
query.WhereCriteria = make_shared<Dictionary>();
|
||||
query.WhereCriteria->Set(GetType()->GetIDColumn(), GetObject());
|
||||
|
@ -183,12 +190,12 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const DynamicObject::Ptr& object)
|
|||
return dbobj;
|
||||
}
|
||||
|
||||
void DbObject::StateChangedHandler(const DynamicObject::Ptr& object)
|
||||
void DbObject::StateChangedHandler(const DynamicObject::Ptr& object, const String& authority)
|
||||
{
|
||||
DbObject::Ptr dbobj = GetOrCreateByObject(object);
|
||||
|
||||
if (!dbobj)
|
||||
return;
|
||||
|
||||
dbobj->SendStatusUpdate();
|
||||
dbobj->SendStatusUpdate(authority);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
static boost::signals2::signal<void (const DbQuery&)> OnQuery;
|
||||
|
||||
void SendConfigUpdate(void);
|
||||
void SendStatusUpdate(void);
|
||||
void SendStatusUpdate(const String& authority = String());
|
||||
|
||||
double GetLastConfigUpdate(void) const;
|
||||
double GetLastStatusUpdate(void) const;
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
double m_LastConfigUpdate;
|
||||
double m_LastStatusUpdate;
|
||||
|
||||
static void StateChangedHandler(const DynamicObject::Ptr& object);
|
||||
static void StateChangedHandler(const DynamicObject::Ptr& object, const String& authority);
|
||||
|
||||
friend class DbType;
|
||||
};
|
||||
|
|
|
@ -417,7 +417,7 @@ void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& autho
|
|||
OnNewCheckResult(GetSelf(), cr, authority);
|
||||
|
||||
/* signal status updates to for example db_ido */
|
||||
OnStateChanged(GetSelf());
|
||||
OnStateChanged(GetSelf(), authority);
|
||||
|
||||
if (hardChange)
|
||||
OnStateChange(GetSelf(), cr, StateTypeHard, authority);
|
||||
|
|
Loading…
Reference in New Issue