]> granicus.if.org Git - icinga2/commitdiff
Ignore debug log for now.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Jun 2012 08:46:18 +0000 (10:46 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 20 Jun 2012 08:46:18 +0000 (10:46 +0200)
base/application.cpp
base/threadpool.h
components/checker/checkercomponent.cpp
components/delegation/delegationcomponent.cpp

index d057d8ec81dbfec1bdc87c2828d0c6069f2ee812..ea479cbeb8c2b5c865ea4e219ff7c5ad426b6a76 100644 (file)
@@ -299,6 +299,10 @@ void Application::Log(LogSeverity severity, const string& facility, const string
 {
        char timestamp[100];
 
+       // TODO: make this configurable
+       if (severity < LogInformation)
+               return;
+
        string severityStr;
        switch (severity) {
                case LogDebug:
index 7c905b09a72044d3fbe1e7aab43fc13212332a6f..5032a6d2dd9aef777d1e5f46422116e461bc70ae 100644 (file)
@@ -18,7 +18,7 @@ public:
        typedef shared_ptr<ThreadPool> Ptr;
        typedef weak_ptr<ThreadPool> WeakPtr;
 
-       ThreadPool(long numThreads = 128);
+       ThreadPool(long maxThreads = 128);
        ~ThreadPool(void);
 
        static ThreadPool::Ptr GetDefaultPool(void);
index 2dd5154074d95a2fcf8e3640268f334db079cf07..2122759008d7620341d4c381208f2f8adc4fb514 100644 (file)
@@ -76,7 +76,7 @@ void CheckerComponent::CheckTimerHandler(void)
 
                m_Services.pop();
 
-//             Application::Log(LogInformation, "checker", "Executing service check for '" + service.GetName() + "'");
+               Application::Log(LogDebug, "checker", "Executing service check for '" + service.GetName() + "'");
 
                CheckTask::Ptr task = CheckTask::CreateTask(service);
                task->Enqueue();
@@ -90,7 +90,7 @@ void CheckerComponent::CheckTimerHandler(void)
 
        stringstream msgbuf;
        msgbuf << "CheckTimerHandler: created " << tasks << " tasks";
-       Application::Log(LogDebug, "checker", msgbuf.str());
+       Application::Log(LogInformation, "checker", msgbuf.str());
 }
 
 void CheckerComponent::ResultTimerHandler(void)
@@ -100,7 +100,7 @@ void CheckerComponent::ResultTimerHandler(void)
        time_t now;
        time(&now);
 
-       long min_latency = -1, max_latency = 0, avg_latency = 0, results = 0;
+       long min_latency = -1, max_latency = 0, avg_latency = 0, results = 0, failed = 0;
 
        vector<CheckTask::Ptr> finishedTasks = CheckTask::GetFinishedTasks();
 
@@ -110,7 +110,7 @@ void CheckerComponent::ResultTimerHandler(void)
                Service service = task->GetService();
 
                CheckResult result = task->GetResult();
-//             Application::Log(LogInformation, "checker", "Got result! Plugin output: " + result.Output);
+               Application::Log(LogDebug, "checker", "Got result for service '" + service.GetName() + "'");
 
                long latency = result.EndTime - result.StartTime;
                avg_latency += latency;
@@ -123,13 +123,16 @@ void CheckerComponent::ResultTimerHandler(void)
 
                results++;
 
+               if (result.State != StateOK)
+                       failed++;
+
                service.SetNextCheck(now + service.GetCheckInterval());
                m_Services.push(service);
        }
 
        stringstream msgbuf;
-       msgbuf << "ResultTimerHandler: " << results << " results; latency: avg=" << avg_latency / (results ? results : 1) << ", min=" << min_latency << ", max: " << max_latency;
-       Application::Log(LogDebug, "checker", msgbuf.str());
+       msgbuf << "ResultTimerHandler: " << results << " results (" << failed << " failed); latency: avg=" << avg_latency / (results ? results : 1) << ", min=" << min_latency << ", max: " << max_latency;
+       Application::Log(LogInformation, "checker", msgbuf.str());
 }
 
 void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
@@ -146,7 +149,7 @@ void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender,
        Service service(object);
        m_Services.push(service);
 
-       Application::Log(LogInformation, "checker", "Accepted delegation for service '" + service.GetName() + "'");
+       Application::Log(LogDebug, "checker", "Accepted delegation for service '" + service.GetName() + "'");
 
        /* force a service check */
        m_CheckTimer->Reschedule(0);
@@ -189,7 +192,7 @@ void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender,
        for (it = services.begin(); it != services.end(); it++)
                m_Services.push(*it);
 
-       Application::Log(LogInformation, "checker", "Revoked delegation for service '" + name + "'");
+       Application::Log(LogDebug, "checker", "Revoked delegation for service '" + name + "'");
 
        string id;
        if (request.GetID(&id)) {
@@ -204,7 +207,7 @@ void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender,
 
 void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
-       Application::Log(LogInformation, "checker", "Clearing service delegations.");
+       Application::Log(LogDebug, "checker", "Clearing service delegations.");
        m_Services = ServiceQueue();
 
        string id;
index f52a4806091dd5ec8a2947232cb7edeb9966e45d..ef228e1a9c0d2ad134cebb4821bd52a3f343429d 100644 (file)
@@ -72,7 +72,7 @@ void DelegationComponent::AssignService(const Service& service)
        params.SetProperty("service", service.GetConfigObject()->GetProperties());
        request.SetParams(params);
 
-       Application::Log(LogInformation, "delegation", "Trying to delegate service '" + service.GetName() + "'");
+       Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");
 
        GetEndpointManager()->SendAPIMessage(m_DelegationEndpoint, request,
            boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _2, _5));
@@ -81,10 +81,10 @@ void DelegationComponent::AssignService(const Service& service)
 void DelegationComponent::AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut)
 {
        if (timedOut) {
-               Application::Log(LogInformation, "delegation", "Service delegation for service '" + service.GetName() + "' timed out.");
+               Application::Log(LogDebug, "delegation", "Service delegation for service '" + service.GetName() + "' timed out.");
        } else {
                service.SetChecker(sender->GetIdentity());
-               Application::Log(LogInformation, "delegation", "Service delegation for service '" + service.GetName() + "' was successful.");
+               Application::Log(LogDebug, "delegation", "Service delegation for service '" + service.GetName() + "' was successful.");
        }
 }
 
@@ -100,6 +100,7 @@ void DelegationComponent::RevokeServiceResponseHandler(Service& service, const E
 void DelegationComponent::DelegationTimerHandler(void)
 {
        ConfigObject::Set::Iterator it;
+       long delegated = 0;
        for (it = m_AllServices->Begin(); it != m_AllServices->End(); it++) {
                Service service = *it;
 
@@ -108,9 +109,12 @@ void DelegationComponent::DelegationTimerHandler(void)
                        continue;
 
                AssignService(service);
+               delegated++;
        }
 
-       m_DelegationTimer->Stop();
+       stringstream msgbuf;
+       msgbuf << "Delegated " << delegated << " services";
+       Application::Log(LogInformation, "delegation", msgbuf.str());
 }
 
 EXPORT_COMPONENT(delegation, DelegationComponent);