[icinga-checkins] icinga.org: icinga2/next: Implement workqueue statistics.

git at icinga.org git at icinga.org
Thu Nov 28 12:33:34 CET 2013


Module: icinga2
Branch: next
Commit: f9c53ad295086f494f7a924f0535477147c44b7d
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=f9c53ad295086f494f7a924f0535477147c44b7d

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Thu Nov 28 12:12:24 2013 +0100

Implement workqueue statistics.

Refs #5235

---

 lib/base/workqueue.cpp |   11 ++++++++++-
 lib/base/workqueue.h   |    1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/base/workqueue.cpp b/lib/base/workqueue.cpp
index 638264f..67e51c3 100644
--- a/lib/base/workqueue.cpp
+++ b/lib/base/workqueue.cpp
@@ -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) {
diff --git a/lib/base/workqueue.h b/lib/base/workqueue.h
index cccf625..6a35ba7 100644
--- a/lib/base/workqueue.h
+++ b/lib/base/workqueue.h
@@ -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);





More information about the icinga-checkins mailing list