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