]> granicus.if.org Git - icinga2/commitdiff
Improve latency after start-up.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Nov 2013 15:09:21 +0000 (16:09 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Nov 2013 15:09:21 +0000 (16:09 +0100)
Fixes #5121

components/db_ido_mysql/idomysqlconnection.cpp
components/db_ido_pgsql/idopgsqlconnection.cpp
lib/db_ido/servicedbobject.cpp
lib/icinga/service.cpp

index fa4361ac7a9a3dd73555ef1479fdc530836ab7fb..093fb651b340d14a6804eca9560bf94c06a55976 100644 (file)
@@ -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");
index 56320fc9801073c6b05e16191ab4a0d495a79c17..a0eb66df5c17d2fc0d05347a266aa99c77abcb32 100644 (file)
@@ -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");
index 1f84cd7bedddadd7598248f5b0427237a24d0d9e..55be48822f604a8a4258c7c828658b4f054a86ff 100644 (file)
@@ -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<Dictionary>();
-       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<Dictionary>();
-       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);
 
index 532aa1dc074c6e2e33df39f437db05e020505d21..3a45529c2ccc56548e6bfa0464332913be1b9305 100644 (file)
@@ -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)