]> granicus.if.org Git - icinga2/commitdiff
Implement workqueue statistics.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 28 Nov 2013 11:12:24 +0000 (12:12 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 28 Nov 2013 11:12:24 +0000 (12:12 +0100)
Refs #5235

lib/base/workqueue.cpp
lib/base/workqueue.h

index 638264f5f92d74ac77186ac865e11f4875fc2204..67e51c397c67a5fd64155d2f0f3a8226cfdeef7b 100644 (file)
@@ -21,6 +21,7 @@
 #include "base/utility.h"
 #include "base/debug.h"
 #include "base/logger_fwd.h"
+#include "base/convert.h"
 #include <boost/bind.hpp>
 
 using namespace icinga;
@@ -29,7 +30,8 @@ int WorkQueue::m_NextID = 1;
 
 WorkQueue::WorkQueue(size_t maxItems)
        : m_ID(m_NextID++), m_MaxItems(maxItems), m_Joined(false),
-         m_Stopped(false), m_ExceptionCallback(WorkQueue::DefaultExceptionCallback)
+         m_Stopped(false), m_ExceptionCallback(WorkQueue::DefaultExceptionCallback),
+         m_LastStatus(0)
 {
        m_Thread = boost::thread(boost::bind(&WorkQueue::WorkerThreadProc, this));
 }
@@ -109,6 +111,13 @@ void WorkQueue::ProcessItems(boost::mutex::scoped_lock& lock, bool interleaved)
                        m_Items.pop_front();
                        m_CV.notify_all();
 
+                       double now = Utility::GetTime();
+
+                       if (m_LastStatus + 10 < now) {
+                               Log(LogInformation, "base", "WQ items: " + Convert::ToString(m_Items.size()));
+                               m_LastStatus = now;
+                       }
+
                        lock.unlock();
                        wi.Callback();
                } catch (const std::exception& ex) {
index cccf625c42dca722d82429c4836b0a9787c8c6bc..6a35ba728e7b8b31b4463f86fb9fb3d5ed9d9e7e 100644 (file)
@@ -72,6 +72,7 @@ private:
        bool m_Stopped;
        std::deque<WorkItem> m_Items;
        ExceptionCallback m_ExceptionCallback;
+       double m_LastStatus;
 
        void ProcessItems(boost::mutex::scoped_lock& lock, bool interleaved);
        void WorkerThreadProc(void);