mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
WorkQueue: Allow choosing stats log level
This commit is contained in:
parent
88949e36da
commit
3468191450
@ -14,9 +14,9 @@ using namespace icinga;
|
|||||||
std::atomic<int> WorkQueue::m_NextID(1);
|
std::atomic<int> WorkQueue::m_NextID(1);
|
||||||
boost::thread_specific_ptr<WorkQueue *> l_ThreadWorkQueue;
|
boost::thread_specific_ptr<WorkQueue *> l_ThreadWorkQueue;
|
||||||
|
|
||||||
WorkQueue::WorkQueue(size_t maxItems, int threadCount)
|
WorkQueue::WorkQueue(size_t maxItems, int threadCount, LogSeverity statsLogLevel)
|
||||||
: m_ID(m_NextID++), m_ThreadCount(threadCount), m_MaxItems(maxItems),
|
: m_ID(m_NextID++), m_ThreadCount(threadCount), m_MaxItems(maxItems),
|
||||||
m_TaskStats(15 * 60)
|
m_TaskStats(15 * 60), m_StatsLogLevel(statsLogLevel)
|
||||||
{
|
{
|
||||||
/* Initialize logger. */
|
/* Initialize logger. */
|
||||||
m_StatusTimerTimeout = Utility::GetTime();
|
m_StatusTimerTimeout = Utility::GetTime();
|
||||||
@ -216,7 +216,7 @@ void WorkQueue::StatusTimerHandler()
|
|||||||
|
|
||||||
/* Log if there are pending items, or 5 minute timeout is reached. */
|
/* Log if there are pending items, or 5 minute timeout is reached. */
|
||||||
if (pending > 0 || m_StatusTimerTimeout < now) {
|
if (pending > 0 || m_StatusTimerTimeout < now) {
|
||||||
Log(LogInformation, "WorkQueue")
|
Log(m_StatsLogLevel, "WorkQueue")
|
||||||
<< "#" << m_ID << " (" << m_Name << ") "
|
<< "#" << m_ID << " (" << m_Name << ") "
|
||||||
<< "items: " << pending << ", "
|
<< "items: " << pending << ", "
|
||||||
<< "rate: " << std::setw(2) << GetTaskCount(60) / 60.0 << "/s "
|
<< "rate: " << std::setw(2) << GetTaskCount(60) / 60.0 << "/s "
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "base/i2-base.hpp"
|
#include "base/i2-base.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/ringbuffer.hpp"
|
#include "base/ringbuffer.hpp"
|
||||||
|
#include "base/logger.hpp"
|
||||||
#include <boost/thread/thread.hpp>
|
#include <boost/thread/thread.hpp>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
@ -52,7 +53,7 @@ class WorkQueue
|
|||||||
public:
|
public:
|
||||||
typedef std::function<void (boost::exception_ptr)> ExceptionCallback;
|
typedef std::function<void (boost::exception_ptr)> ExceptionCallback;
|
||||||
|
|
||||||
WorkQueue(size_t maxItems = 0, int threadCount = 1);
|
WorkQueue(size_t maxItems = 0, int threadCount = 1, LogSeverity statsLogLevel = LogInformation);
|
||||||
~WorkQueue();
|
~WorkQueue();
|
||||||
|
|
||||||
void SetName(const String& name);
|
void SetName(const String& name);
|
||||||
@ -129,6 +130,7 @@ private:
|
|||||||
std::vector<boost::exception_ptr> m_Exceptions;
|
std::vector<boost::exception_ptr> m_Exceptions;
|
||||||
Timer::Ptr m_StatusTimer;
|
Timer::Ptr m_StatusTimer;
|
||||||
double m_StatusTimerTimeout;
|
double m_StatusTimerTimeout;
|
||||||
|
LogSeverity m_StatsLogLevel;
|
||||||
|
|
||||||
RingBuffer m_TaskStats;
|
RingBuffer m_TaskStats;
|
||||||
size_t m_PendingTasks{0};
|
size_t m_PendingTasks{0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user