From f39eff323ecfb7a66b65eda753b6574ce7f83ce2 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 29 Oct 2013 15:54:43 +0100 Subject: [PATCH 1/5] Implement DbQuery::Category field. Refs #4782 --- .../db_ido_mysql/idomysqlconnection.cpp | 2 ++ lib/db_ido/dbconnection.cpp | 4 +++ lib/db_ido/dbobject.cpp | 2 ++ lib/db_ido/dbquery.h | 24 +++++++++++++++++- lib/db_ido/hostdbobject.cpp | 8 ++++++ lib/db_ido/hostgroupdbobject.cpp | 2 ++ lib/db_ido/servicedbobject.cpp | 25 +++++++++++++++++++ lib/db_ido/servicegroupdbobject.cpp | 2 ++ lib/db_ido/timeperioddbobject.cpp | 2 ++ lib/db_ido/usergroupdbobject.cpp | 2 ++ 10 files changed, 72 insertions(+), 1 deletion(-) diff --git a/components/db_ido_mysql/idomysqlconnection.cpp b/components/db_ido_mysql/idomysqlconnection.cpp index e380a26b4..7797106b2 100644 --- a/components/db_ido_mysql/idomysqlconnection.cpp +++ b/components/db_ido_mysql/idomysqlconnection.cpp @@ -405,6 +405,8 @@ void IdoMysqlConnection::ExecuteQuery(const DbQuery& query) { boost::mutex::scoped_lock lock(m_ConnectionMutex); + ASSERT(query.Category != DbCatInvalid); + if (!m_Connected) return; diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 8b70f354e..75b9b93db 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -60,6 +60,7 @@ void DbConnection::InsertRuntimeVariable(const String& key, const Value& value) DbQuery query; query.Table = "runtimevariables"; query.Type = DbQueryInsert; + query.Category = DbCatProgramStatus; query.Fields = boost::make_shared(); query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query.Fields->Set("varname", key); @@ -72,6 +73,7 @@ void DbConnection::ProgramStatusHandler(void) DbQuery query1; query1.Table = "programstatus"; query1.Type = DbQueryDelete; + query1.Type = DbCatProgramStatus; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ DbObject::OnQuery(query1); @@ -79,6 +81,7 @@ void DbConnection::ProgramStatusHandler(void) DbQuery query2; query2.Table = "programstatus"; query2.Type = DbQueryInsert; + query2.Category = DbCatProgramStatus; query2.Fields = boost::make_shared(); query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ @@ -100,6 +103,7 @@ void DbConnection::ProgramStatusHandler(void) DbQuery query3; query3.Table = "runtimevariables"; query3.Type = DbQueryDelete; + query3.Category = DbCatProgramStatus; query3.WhereCriteria = boost::make_shared(); query3.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ DbObject::OnQuery(query3); diff --git a/lib/db_ido/dbobject.cpp b/lib/db_ido/dbobject.cpp index 99669f635..e9248a7b1 100644 --- a/lib/db_ido/dbobject.cpp +++ b/lib/db_ido/dbobject.cpp @@ -78,6 +78,7 @@ void DbObject::SendConfigUpdate(void) DbQuery query; query.Table = GetType()->GetTable() + "s"; query.Type = DbQueryInsert | DbQueryUpdate; + query.Type = DbCatConfig; query.Fields = fields; query.Fields->Set(GetType()->GetIDColumn(), GetObject()); query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ @@ -103,6 +104,7 @@ void DbObject::SendStatusUpdate(void) DbQuery query; query.Table = GetType()->GetTable() + "status"; query.Type = DbQueryInsert | DbQueryUpdate; + query.Category = DbCatState; query.Fields = fields; query.Fields->Set(GetType()->GetIDColumn(), GetObject()); query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ diff --git a/lib/db_ido/dbquery.h b/lib/db_ido/dbquery.h index 4e47f55e1..4dac75357 100644 --- a/lib/db_ido/dbquery.h +++ b/lib/db_ido/dbquery.h @@ -32,11 +32,33 @@ enum DbQueryType DbQueryDelete = 4 }; +enum DbQueryCategory +{ + DbCatInvalid, + + DbCatConfig, + DbCatState, + + DbCatAcknowledgement, + DbCatComment, + DbCatDowntime, + DbCatEventHandler, + DbCatExternalCommand, + DbCatFlapping, + DbCatCheck, + DbCatLog, + DbCatNotification, + DbCatProgramStatus, + DbCatRetention, + DbCatStateHistory +}; + class DbObject; struct DbQuery { int Type; + DbQueryCategory Category; String Table; Dictionary::Ptr Fields; Dictionary::Ptr WhereCriteria; @@ -45,7 +67,7 @@ struct DbQuery bool StatusUpdate; DbQuery(void) - : Type(0), ConfigUpdate(false), StatusUpdate(false) + : Type(0), Category(DbCatInvalid), ConfigUpdate(false), StatusUpdate(false) { } }; diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index d456ca580..106a9d6b7 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -197,6 +197,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query_del1; query_del1.Table = GetType()->GetTable() + "_parenthosts"; query_del1.Type = DbQueryDelete; + query_del1.Category = DbCatConfig; query_del1.WhereCriteria = boost::make_shared(); query_del1.WhereCriteria->Set(GetType()->GetTable() + "_id", DbValue::FromObjectInsertID(GetObject())); OnQuery(query_del1); @@ -204,6 +205,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query_del2; query_del2.Table = GetType()->GetTable() + "dependencies"; query_del2.Type = DbQueryDelete; + query_del2.Category = DbCatConfig; query_del2.WhereCriteria = boost::make_shared(); query_del2.WhereCriteria->Set("dependent_host_object_id", host); OnQuery(query_del2); @@ -220,6 +222,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query1; query1.Table = GetType()->GetTable() + "_parenthosts"; query1.Type = DbQueryInsert; + query1.Category = DbCatConfig; query1.Fields = fields1; OnQuery(query1); @@ -232,6 +235,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query2; query2.Table = GetType()->GetTable() + "dependencies"; query2.Type = DbQueryInsert; + query2.Category = DbCatConfig; query2.Fields = fields2; OnQuery(query2); } @@ -253,6 +257,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query_contact; query_contact.Table = GetType()->GetTable() + "_contacts"; query_contact.Type = DbQueryInsert; + query_contact.Category = DbCatConfig; query_contact.Fields = fields_contact; OnQuery(query_contact); } @@ -270,6 +275,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query_contact; query_contact.Table = GetType()->GetTable() + "_contactgroups"; query_contact.Type = DbQueryInsert; + query_contact.Category = DbCatConfig; query_contact.Fields = fields_contact; OnQuery(query_contact); } @@ -281,6 +287,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query_del3; query_del3.Table = "customvariables"; query_del3.Type = DbQueryDelete; + query_del3.Category = DbCatConfig; query_del3.WhereCriteria = boost::make_shared(); query_del3.WhereCriteria->Set("object_id", host); OnQuery(query_del3); @@ -310,6 +317,7 @@ void HostDbObject::OnConfigUpdate(void) DbQuery query3; query3.Table = "customvariables"; query3.Type = DbQueryInsert; + query3.Category = DbCatConfig; query3.Fields = fields3; OnQuery(query3); } diff --git a/lib/db_ido/hostgroupdbobject.cpp b/lib/db_ido/hostgroupdbobject.cpp index 74f9167ac..3e20c8c96 100644 --- a/lib/db_ido/hostgroupdbobject.cpp +++ b/lib/db_ido/hostgroupdbobject.cpp @@ -55,6 +55,7 @@ void HostGroupDbObject::OnConfigUpdate(void) DbQuery query1; query1.Table = DbType::GetByName("HostGroup")->GetTable() + "_members"; query1.Type = DbQueryDelete; + query1.Category = DbCatConfig; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("hostgroup_id", DbValue::FromObjectInsertID(group)); OnQuery(query1); @@ -63,6 +64,7 @@ void HostGroupDbObject::OnConfigUpdate(void) DbQuery query2; query2.Table = DbType::GetByName("HostGroup")->GetTable() + "_members"; query2.Type = DbQueryInsert; + query2.Category = DbCatConfig; query2.Fields = boost::make_shared(); query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.Fields->Set("hostgroup_id", DbValue::FromObjectInsertID(group)); diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index ab723e216..78dfb8811 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -217,6 +217,7 @@ void ServiceDbObject::OnConfigUpdate(void) DbQuery query_del1; query_del1.Table = GetType()->GetTable() + "dependencies"; query_del1.Type = DbQueryDelete; + query_del1.Category = DbCatConfig; query_del1.WhereCriteria = boost::make_shared(); query_del1.WhereCriteria->Set("dependent_service_object_id", service); OnQuery(query_del1); @@ -233,6 +234,7 @@ void ServiceDbObject::OnConfigUpdate(void) DbQuery query1; query1.Table = GetType()->GetTable() + "dependencies"; query1.Type = DbQueryInsert; + query1.Category = DbCatConfig; query1.Fields = fields1; OnQuery(query1); } @@ -251,6 +253,7 @@ void ServiceDbObject::OnConfigUpdate(void) DbQuery query_contact; query_contact.Table = GetType()->GetTable() + "_contacts"; query_contact.Type = DbQueryInsert; + query_contact.Category = DbCatConfig; query_contact.Fields = fields_contact; OnQuery(query_contact); } @@ -268,6 +271,7 @@ void ServiceDbObject::OnConfigUpdate(void) DbQuery query_contact; query_contact.Table = GetType()->GetTable() + "_contactgroups"; query_contact.Type = DbQueryInsert; + query_contact.Category = DbCatConfig; query_contact.Fields = fields_contact; OnQuery(query_contact); } @@ -278,6 +282,7 @@ void ServiceDbObject::OnConfigUpdate(void) DbQuery query_del2; query_del2.Table = "customvariables"; query_del2.Type = DbQueryDelete; + query_del2.Category = DbCatConfig; query_del2.WhereCriteria = boost::make_shared(); query_del2.WhereCriteria->Set("object_id", service); OnQuery(query_del2); @@ -308,6 +313,7 @@ void ServiceDbObject::OnConfigUpdate(void) DbQuery query2; query2.Table = "customvariables"; query2.Type = DbQueryInsert; + query2.Category = DbCatConfig; query2.Fields = fields2; OnQuery(query2); } @@ -444,6 +450,7 @@ void ServiceDbObject::AddCommentByType(const DynamicObject::Ptr& object, const D query1.Table = "commenthistory"; } query1.Type = DbQueryInsert; + query1.Category = DbCatComment; query1.Fields = fields1; OnQuery(query1); } @@ -460,6 +467,7 @@ void ServiceDbObject::RemoveComments(const Service::Ptr& service) DbQuery query1; query1.Table = "comments"; query1.Type = DbQueryDelete; + query1.Category = DbCatComment; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("object_id", service); OnQuery(query1); @@ -489,6 +497,7 @@ void ServiceDbObject::RemoveComment(const Service::Ptr& service, const Dictionar DbQuery query1; query1.Table = "comments"; query1.Type = DbQueryDelete; + query1.Category = DbCatComment; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("object_id", service); query1.WhereCriteria->Set("internal_comment_id", comment->Get("legacy_id")); @@ -509,6 +518,7 @@ void ServiceDbObject::RemoveComment(const Service::Ptr& service, const Dictionar DbQuery query2; query2.Table = "commenthistory"; query2.Type = DbQueryUpdate; + query2.Category = DbCatComment; Dictionary::Ptr fields2 = boost::make_shared(); fields2->Set("deletion_time", DbValue::FromTimestamp(deletion_time)); @@ -610,6 +620,7 @@ void ServiceDbObject::AddDowntimeByType(const DynamicObject::Ptr& object, const query1.Table = "downtimehistory"; } query1.Type = DbQueryInsert; + query1.Category = DbCatDowntime; query1.Fields = fields1; OnQuery(query1); } @@ -626,6 +637,7 @@ void ServiceDbObject::RemoveDowntimes(const Service::Ptr& service) DbQuery query1; query1.Table = "scheduleddowntime"; query1.Type = DbQueryDelete; + query1.Category = DbCatDowntime; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("object_id", service); OnQuery(query1); @@ -655,6 +667,7 @@ void ServiceDbObject::RemoveDowntime(const Service::Ptr& service, const Dictiona DbQuery query1; query1.Table = "scheduleddowntime"; query1.Type = DbQueryDelete; + query1.Category = DbCatDowntime; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("object_id", service); query1.WhereCriteria->Set("internal_downtime_id", downtime->Get("legacy_id")); @@ -674,6 +687,7 @@ void ServiceDbObject::RemoveDowntime(const Service::Ptr& service, const Dictiona DbQuery query3; query3.Table = "downtimehistory"; query3.Type = DbQueryUpdate; + query3.Category = DbCatDowntime; Dictionary::Ptr fields3 = boost::make_shared(); fields3->Set("was_cancelled", downtime->Get("was_cancelled") ? 1 : 0); @@ -713,6 +727,7 @@ void ServiceDbObject::TriggerDowntime(const Service::Ptr& service, const Diction DbQuery query1; query1.Table = "scheduleddowntime"; query1.Type = DbQueryUpdate; + query1.Category = DbCatDowntime; Dictionary::Ptr fields1 = boost::make_shared(); fields1->Set("was_started", 1); @@ -739,6 +754,7 @@ void ServiceDbObject::TriggerDowntime(const Service::Ptr& service, const Diction DbQuery query3; query3.Table = "downtimehistory"; query3.Type = DbQueryUpdate; + query3.Category = DbCatDowntime; Dictionary::Ptr fields3 = boost::make_shared(); fields3->Set("was_started", 1); @@ -777,6 +793,7 @@ void ServiceDbObject::AddAcknowledgementHistory(const Service::Ptr& service, con DbQuery query1; query1.Table = "acknowledgements"; query1.Type = DbQueryInsert; + query1.Category = DbCatAcknowledgement; Dictionary::Ptr fields1 = boost::make_shared(); fields1->Set("entry_time", DbValue::FromTimestamp(entry_time)); @@ -822,6 +839,7 @@ void ServiceDbObject::AddContactNotificationHistory(const Service::Ptr& service, DbQuery query1; query1.Table = "contactnotifications"; query1.Type = DbQueryInsert; + query1.Category = DbCatNotification; Dictionary::Ptr fields1 = boost::make_shared(); fields1->Set("contact_object_id", user); @@ -862,6 +880,7 @@ void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const DbQuery query1; query1.Table = "notifications"; query1.Type = DbQueryInsert; + query1.Category = DbCatNotification; Dictionary::Ptr fields1 = boost::make_shared(); fields1->Set("notification_type", 1); /* service */ @@ -912,6 +931,7 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const D DbQuery query1; query1.Table = "statehistory"; query1.Type = DbQueryInsert; + query1.Category = DbCatStateHistory; Dictionary::Ptr fields1 = boost::make_shared(); fields1->Set("state_time", DbValue::FromTimestamp(state_time)); @@ -1246,6 +1266,7 @@ void ServiceDbObject::AddLogHistory(const Service::Ptr& service, String buffer, DbQuery query1; query1.Table = "logentries"; query1.Type = DbQueryInsert; + query1.Category = DbCatLog; Dictionary::Ptr fields1 = boost::make_shared(); fields1->Set("logentry_time", DbValue::FromTimestamp(entry_time)); @@ -1284,6 +1305,7 @@ void ServiceDbObject::AddFlappingHistory(const Service::Ptr& service, FlappingSt DbQuery query1; query1.Table = "flappinghistory"; query1.Type = DbQueryInsert; + query1.Category = DbCatFlapping; Dictionary::Ptr fields1 = boost::make_shared(); @@ -1339,6 +1361,7 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const DbQuery query1; query1.Table = "servicechecks"; query1.Type = DbQueryInsert; + query1.Category = DbCatCheck; Dictionary::Ptr fields1 = boost::make_shared(); Dictionary::Ptr attrs; @@ -1410,6 +1433,7 @@ void ServiceDbObject::AddEventHandlerHistory(const Service::Ptr& service) DbQuery query1; query1.Table = "eventhandlers"; query1.Type = DbQueryInsert; + query1.Category = DbCatEventHandler; Dictionary::Ptr fields1 = boost::make_shared(); @@ -1447,6 +1471,7 @@ void ServiceDbObject::AddExternalCommandHistory(double time, const String& comma DbQuery query1; query1.Table = "externalcommands"; query1.Type = DbQueryInsert; + query1.Category = DbCatExternalCommand; Dictionary::Ptr fields1 = boost::make_shared(); diff --git a/lib/db_ido/servicegroupdbobject.cpp b/lib/db_ido/servicegroupdbobject.cpp index 86e7a315a..5d24cb3b5 100644 --- a/lib/db_ido/servicegroupdbobject.cpp +++ b/lib/db_ido/servicegroupdbobject.cpp @@ -54,6 +54,7 @@ void ServiceGroupDbObject::OnConfigUpdate(void) DbQuery query1; query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members"; query1.Type = DbQueryDelete; + query1.Category = DbCatConfig; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("servicegroup_id", DbValue::FromObjectInsertID(group)); OnQuery(query1); @@ -62,6 +63,7 @@ void ServiceGroupDbObject::OnConfigUpdate(void) DbQuery query2; query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members"; query2.Type = DbQueryInsert; + query2.Category = DbCatConfig; query2.Fields = boost::make_shared(); query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group)); diff --git a/lib/db_ido/timeperioddbobject.cpp b/lib/db_ido/timeperioddbobject.cpp index f4af8635f..d7c2d4381 100644 --- a/lib/db_ido/timeperioddbobject.cpp +++ b/lib/db_ido/timeperioddbobject.cpp @@ -58,6 +58,7 @@ void TimePeriodDbObject::OnConfigUpdate(void) DbQuery query_del1; query_del1.Table = GetType()->GetTable() + "_timeranges"; query_del1.Type = DbQueryDelete; + query_del1.Category = DbCatConfig; query_del1.WhereCriteria = boost::make_shared(); query_del1.WhereCriteria->Set("timeperiod_id", DbValue::FromObjectInsertID(tp)); OnQuery(query_del1); @@ -109,6 +110,7 @@ void TimePeriodDbObject::OnConfigUpdate(void) DbQuery query; query.Table = GetType()->GetTable() + "_timeranges"; query.Type = DbQueryInsert; + query.Category = DbCatConfig; query.Fields = boost::make_shared(); query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query.Fields->Set("timeperiod_id", DbValue::FromObjectInsertID(tp)); diff --git a/lib/db_ido/usergroupdbobject.cpp b/lib/db_ido/usergroupdbobject.cpp index eb5af31f7..928b71374 100644 --- a/lib/db_ido/usergroupdbobject.cpp +++ b/lib/db_ido/usergroupdbobject.cpp @@ -55,6 +55,7 @@ void UserGroupDbObject::OnConfigUpdate(void) DbQuery query1; query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members"; query1.Type = DbQueryDelete; + query1.Category = DbCatConfig; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("instance_id", 0); query1.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group)); @@ -64,6 +65,7 @@ void UserGroupDbObject::OnConfigUpdate(void) DbQuery query2; query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members"; query2.Type = DbQueryInsert; + query2.Category = DbCatConfig; query2.Fields = boost::make_shared(); query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group)); From 8c5bff3f759c0ba2952e6d46e6f3598c6863eaf9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 29 Oct 2013 16:08:52 +0100 Subject: [PATCH 2/5] Implement data processing options (DbConnection::categories). Refs #4782 --- components/db_ido_mysql/idomysqlconnection.cpp | 3 +++ lib/db_ido/dbconnection.cpp | 2 +- lib/db_ido/dbconnection.ti | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/db_ido_mysql/idomysqlconnection.cpp b/components/db_ido_mysql/idomysqlconnection.cpp index 7797106b2..1a74beb75 100644 --- a/components/db_ido_mysql/idomysqlconnection.cpp +++ b/components/db_ido_mysql/idomysqlconnection.cpp @@ -407,6 +407,9 @@ void IdoMysqlConnection::ExecuteQuery(const DbQuery& query) ASSERT(query.Category != DbCatInvalid); + if ((query.Category & GetCategories()) == 0) + return; + if (!m_Connected) return; diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 75b9b93db..1d1b35e09 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -73,7 +73,7 @@ void DbConnection::ProgramStatusHandler(void) DbQuery query1; query1.Table = "programstatus"; query1.Type = DbQueryDelete; - query1.Type = DbCatProgramStatus; + query1.Category = DbCatProgramStatus; query1.WhereCriteria = boost::make_shared(); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ DbObject::OnQuery(query1); diff --git a/lib/db_ido/dbconnection.ti b/lib/db_ido/dbconnection.ti index d7132cdc7..dd595a890 100644 --- a/lib/db_ido/dbconnection.ti +++ b/lib/db_ido/dbconnection.ti @@ -1,3 +1,4 @@ +#include "db_ido/dbquery.h" #include "base/dynamicobject.h" #include @@ -13,6 +14,14 @@ class DbConnection : DynamicObject [config] Dictionary::Ptr cleanup { default {{{ return boost::make_shared(); }}} }; + + [config] int categories { + default {{{ + return DbCatConfig | DbCatState | DbCatAcknowledgement | + DbCatComment | DbCatDowntime | DbCatEventHandler | DbCatExternalCommand | DbCatFlapping | + DbCatLog | DbCatNotification | DbCatProgramStatus | DbCatRetention | DbCatStateHistory; + }}} + }; }; -} \ No newline at end of file +} From ff737e4cb5eecd40405fb59076b152423780a05d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 30 Oct 2013 09:09:44 +0100 Subject: [PATCH 3/5] Add script constants for the DbCat* filter categories. Refs #4782 --- itl/constants.conf | 19 +++++++++++++++++++ lib/db_ido/dbquery.h | 30 +++++++++++++++--------------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/itl/constants.conf b/itl/constants.conf index c082cacc5..289765519 100644 --- a/itl/constants.conf +++ b/itl/constants.conf @@ -62,3 +62,22 @@ set DomainPrivCommand = (1<<2) set DomainPrivReadOnly = (DomainPrivRead) set DomainPrivReadWrite = (DomainPrivRead | DomainPrivCheckResult | DomainPrivCommand) + +/* + * IDO filter categories + */ +set DbCatConfig = (1 << 0) +set DbCatState = (1 << 1) +set DbCatAcknowledgement = (1 << 2) +set DbCatComment = (1 << 3) +set DbCatDowntime = (1 << 4) +set DbCatEventHandler = (1 << 5) +set DbCatExternalCommand = (1 << 6) +set DbCatFlapping = (1 << 7) +set DbCatCheck = (1 << 8) +set DbCatLog = (1 << 9) +set DbCatNotification = (1 << 10) +set DbCatProgramStatus = (1 << 11) +set DbCatRetention = (1 << 12) +set DbCatStateHistory = (1 << 13) + diff --git a/lib/db_ido/dbquery.h b/lib/db_ido/dbquery.h index 4dac75357..bea545f02 100644 --- a/lib/db_ido/dbquery.h +++ b/lib/db_ido/dbquery.h @@ -34,23 +34,23 @@ enum DbQueryType enum DbQueryCategory { - DbCatInvalid, + DbCatInvalid = -1, - DbCatConfig, - DbCatState, + DbCatConfig = (1 << 0), + DbCatState = (1 << 1), - DbCatAcknowledgement, - DbCatComment, - DbCatDowntime, - DbCatEventHandler, - DbCatExternalCommand, - DbCatFlapping, - DbCatCheck, - DbCatLog, - DbCatNotification, - DbCatProgramStatus, - DbCatRetention, - DbCatStateHistory + DbCatAcknowledgement = (1 << 2), + DbCatComment = (1 << 3), + DbCatDowntime = (1 << 4), + DbCatEventHandler = (1 << 5), + DbCatExternalCommand = (1 << 6), + DbCatFlapping = (1 << 7), + DbCatCheck = (1 << 8), + DbCatLog = (1 << 9), + DbCatNotification = (1 << 10), + DbCatProgramStatus = (1 << 11), + DbCatRetention = (1 << 12), + DbCatStateHistory = (1 << 13) }; class DbObject; From 1a8a838de90a6c15f9cd569ad564243ba6a2b874 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 30 Oct 2013 08:47:23 +0100 Subject: [PATCH 4/5] Add documentation for the DbCat* filters. Refs #4782 --- doc/4.3-object-types.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/4.3-object-types.md b/doc/4.3-object-types.md index 0203cfa67..3a7c98c12 100644 --- a/doc/4.3-object-types.md +++ b/doc/4.3-object-types.md @@ -523,7 +523,9 @@ Example: cleanup = { downtimehistory_age = 48h, logentries_age = 31d, - } + }, + + categories = (DbCatConfig | DbCatState) } Attributes: @@ -539,6 +541,7 @@ Attributes: instance\_name |**Optional.** Unique identifier for the local Icinga 2 instance. Defaults to "default". instance\_description|**Optional.** Description for the Icinga 2 instance. cleanup |**Optional.** Dictionary with items for historical table cleanup. + categories |**Optional.** The types of information that should be written to the database. Cleanup Items: @@ -560,6 +563,27 @@ Cleanup Items: servicechecks_age |**Optional.** Max age for servicechecks table rows (start_time). Defaults to 0 (never). systemcommands_age |**Optional.** Max age for systemcommands table rows (start_time). Defaults to 0 (never). +Data Categories: + + Name | Description + ---------------------|---------------- + DbCatConfig | Configuration data + DbCatState | Current state data + DbCatAcknowledgement | Acknowledgements + DbCatComment | Comments + DbCatDowntime | Downtimes + DbCatEventHandler | Event handler data + DbCatExternalCommand | External commands + DbCatFlapping | Flap detection data + DbCatCheck | Check results + DbCatLog | Log messages + DbCatNotification | Notifications + DbCatProgramStatus | Program status data + DbCatRetention | Retention data + DbCatStateHistory | Historical state data + +Multiple categories can be combined using the `|` operator. + ### LiveStatusListener Livestatus API interface available as TCP or UNIX socket. From c69a0c39ef0bb774b21d1373074d4c115b16ba84 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 30 Oct 2013 10:06:53 +0100 Subject: [PATCH 5/5] Remove unused methods from IdoMysqlConnection. Refs #4782 --- components/db_ido_mysql/idomysqlconnection.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/db_ido_mysql/idomysqlconnection.h b/components/db_ido_mysql/idomysqlconnection.h index 876fef840..d114e0c60 100644 --- a/components/db_ido_mysql/idomysqlconnection.h +++ b/components/db_ido_mysql/idomysqlconnection.h @@ -44,9 +44,6 @@ protected: virtual void Start(void); virtual void Stop(void); - virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const; - virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes); - virtual void ActivateObject(const DbObject::Ptr& dbobj); virtual void DeactivateObject(const DbObject::Ptr& dbobj); virtual void ExecuteQuery(const DbQuery& query);