diff --git a/components/db_ido_mysql/idomysqlconnection.cpp b/components/db_ido_mysql/idomysqlconnection.cpp index fa4361ac7..093fb651b 100644 --- a/components/db_ido_mysql/idomysqlconnection.cpp +++ b/components/db_ido_mysql/idomysqlconnection.cpp @@ -233,6 +233,7 @@ void IdoMysqlConnection::ClearConfigTables(void) { /* TODO make hardcoded table names modular */ ClearConfigTable("commands"); + ClearConfigTable("comments"); ClearConfigTable("contact_addresses"); ClearConfigTable("contact_notificationcommands"); ClearConfigTable("contactgroup_members"); @@ -246,6 +247,7 @@ void IdoMysqlConnection::ClearConfigTables(void) ClearConfigTable("hostgroup_members"); ClearConfigTable("hostgroups"); ClearConfigTable("hosts"); + ClearConfigTable("scheduleddowntime"); ClearConfigTable("service_contactgroups"); ClearConfigTable("service_contacts"); ClearConfigTable("servicedependencies"); diff --git a/components/db_ido_pgsql/idopgsqlconnection.cpp b/components/db_ido_pgsql/idopgsqlconnection.cpp index 56320fc98..a0eb66df5 100644 --- a/components/db_ido_pgsql/idopgsqlconnection.cpp +++ b/components/db_ido_pgsql/idopgsqlconnection.cpp @@ -237,6 +237,7 @@ void IdoPgsqlConnection::ClearConfigTables(void) { /* TODO make hardcoded table names modular */ ClearConfigTable("commands"); + ClearConfigTable("comments"); ClearConfigTable("contact_addresses"); ClearConfigTable("contact_notificationcommands"); ClearConfigTable("contactgroup_members"); @@ -250,6 +251,7 @@ void IdoPgsqlConnection::ClearConfigTables(void) ClearConfigTable("hostgroup_members"); ClearConfigTable("hostgroups"); ClearConfigTable("hosts"); + ClearConfigTable("scheduleddowntime"); ClearConfigTable("service_contactgroups"); ClearConfigTable("service_contacts"); ClearConfigTable("servicedependencies"); diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index 1f84cd7be..55be48822 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -211,14 +211,6 @@ void ServiceDbObject::OnConfigUpdate(void) /* service dependencies */ Log(LogDebug, "db_ido", "service dependencies for '" + service->GetName() + "'"); - DbQuery query_del1; - query_del1.Table = GetType()->GetTable() + "dependencies"; - query_del1.Type = DbQueryDelete; - query_del1.Category = DbCatConfig; - query_del1.WhereCriteria = make_shared(); - query_del1.WhereCriteria->Set("dependent_service_object_id", service); - OnQuery(query_del1); - BOOST_FOREACH(const Service::Ptr& parent, service->GetParentServices()) { Log(LogDebug, "db_ido", "service parents: " + parent->GetName()); @@ -276,14 +268,6 @@ void ServiceDbObject::OnConfigUpdate(void) /* custom variables */ Log(LogDebug, "db_ido", "service customvars for '" + service->GetName() + "'"); - DbQuery query_del2; - query_del2.Table = "customvariables"; - query_del2.Type = DbQueryDelete; - query_del2.Category = DbCatConfig; - query_del2.WhereCriteria = make_shared(); - query_del2.WhereCriteria->Set("object_id", service); - OnQuery(query_del2); - Dictionary::Ptr customvars; { @@ -292,7 +276,7 @@ void ServiceDbObject::OnConfigUpdate(void) } if (customvars) { - ObjectLock olock (customvars); + ObjectLock olock(customvars); String key; Value value; @@ -317,8 +301,6 @@ void ServiceDbObject::OnConfigUpdate(void) } /* update comments and downtimes on config change */ - RemoveComments(service); - RemoveDowntimes(service); AddComments(service); AddDowntimes(service); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index 532aa1dc0..3a45529c2 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -48,9 +48,6 @@ void Service::Start(void) VERIFY(GetHost()); - SetSchedulingOffset(Utility::Random()); - UpdateNextCheck(); - AddDowntimesToCache(); AddCommentsToCache(); @@ -78,6 +75,11 @@ void Service::OnConfigLoaded(void) m_Host->AddService(GetSelf()); UpdateSlaveNotifications(); + + SetSchedulingOffset(Utility::Random()); + + if (GetNextCheck() < Utility::GetTime() + 300) + SetNextCheck(Utility::GetTime() + Utility::Random() % 300); } Service::Ptr Service::GetByNamePair(const String& hostName, const String& serviceName)