mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-30 09:04:35 +02:00
Fix that RingBuffer does not get updated if nothing is written
refs #5750
This commit is contained in:
parent
e4466307a7
commit
2acaccd028
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "base/ringbuffer.hpp"
|
#include "base/ringbuffer.hpp"
|
||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
|
#include "base/utility.hpp"
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
@ -58,8 +59,10 @@ void RingBuffer::InsertValue(RingBuffer::SizeType tv, int num)
|
|||||||
m_Slots[offsetTarget] += num;
|
m_Slots[offsetTarget] += num;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RingBuffer::GetValues(RingBuffer::SizeType span) const
|
int RingBuffer::UpdateAndGetValues(RingBuffer::SizeType tv, RingBuffer::SizeType span)
|
||||||
{
|
{
|
||||||
|
InsertValue(tv, 0);
|
||||||
|
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
if (span > m_Slots.size())
|
if (span > m_Slots.size())
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
SizeType GetLength(void) const;
|
SizeType GetLength(void) const;
|
||||||
void InsertValue(SizeType tv, int num);
|
void InsertValue(SizeType tv, int num);
|
||||||
int GetValues(SizeType span) const;
|
int UpdateAndGetValues(SizeType tv, SizeType span);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> m_Slots;
|
std::vector<int> m_Slots;
|
||||||
|
@ -296,8 +296,8 @@ void WorkQueue::IncreaseTaskCount(void)
|
|||||||
m_TaskStats.InsertValue(now, 1);
|
m_TaskStats.InsertValue(now, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WorkQueue::GetTaskCount(RingBuffer::SizeType span) const
|
int WorkQueue::GetTaskCount(RingBuffer::SizeType span)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_StatsMutex);
|
boost::mutex::scoped_lock lock(m_StatsMutex);
|
||||||
return m_TaskStats.GetValues(span);
|
return m_TaskStats.UpdateAndGetValues(Utility::GetTime(), span);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
bool IsWorkerThread(void) const;
|
bool IsWorkerThread(void) const;
|
||||||
|
|
||||||
size_t GetLength(void) const;
|
size_t GetLength(void) const;
|
||||||
int GetTaskCount(RingBuffer::SizeType span) const;
|
int GetTaskCount(RingBuffer::SizeType span);
|
||||||
|
|
||||||
void SetExceptionCallback(const ExceptionCallback& callback);
|
void SetExceptionCallback(const ExceptionCallback& callback);
|
||||||
|
|
||||||
|
@ -474,10 +474,10 @@ void DbConnection::IncreaseQueryCount(void)
|
|||||||
m_QueryStats.InsertValue(now, 1);
|
m_QueryStats.InsertValue(now, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DbConnection::GetQueryCount(RingBuffer::SizeType span) const
|
int DbConnection::GetQueryCount(RingBuffer::SizeType span)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_StatsMutex);
|
boost::mutex::scoped_lock lock(m_StatsMutex);
|
||||||
return m_QueryStats.GetValues(span);
|
return m_QueryStats.UpdateAndGetValues(Utility::GetTime(), span);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DbConnection::IsIDCacheValid(void) const
|
bool DbConnection::IsIDCacheValid(void) const
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
|
void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
|
||||||
bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
|
bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
|
||||||
|
|
||||||
int GetQueryCount(RingBuffer::SizeType span) const;
|
int GetQueryCount(RingBuffer::SizeType span);
|
||||||
virtual int GetPendingQueryCount(void) const = 0;
|
virtual int GetPendingQueryCount(void) const = 0;
|
||||||
|
|
||||||
virtual void ValidateFailoverTimeout(double value, const ValidationUtils& utils) override;
|
virtual void ValidateFailoverTimeout(double value, const ValidationUtils& utils) override;
|
||||||
|
@ -45,12 +45,12 @@ void CIB::UpdateActiveServiceChecksStatistics(long tv, int num)
|
|||||||
|
|
||||||
int CIB::GetActiveHostChecksStatistics(long timespan)
|
int CIB::GetActiveHostChecksStatistics(long timespan)
|
||||||
{
|
{
|
||||||
return m_ActiveHostChecksStatistics.GetValues(timespan);
|
return m_ActiveHostChecksStatistics.UpdateAndGetValues(Utility::GetTime(), timespan);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CIB::GetActiveServiceChecksStatistics(long timespan)
|
int CIB::GetActiveServiceChecksStatistics(long timespan)
|
||||||
{
|
{
|
||||||
return m_ActiveServiceChecksStatistics.GetValues(timespan);
|
return m_ActiveServiceChecksStatistics.UpdateAndGetValues(Utility::GetTime(), timespan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIB::UpdatePassiveHostChecksStatistics(long tv, int num)
|
void CIB::UpdatePassiveHostChecksStatistics(long tv, int num)
|
||||||
@ -65,12 +65,12 @@ void CIB::UpdatePassiveServiceChecksStatistics(long tv, int num)
|
|||||||
|
|
||||||
int CIB::GetPassiveHostChecksStatistics(long timespan)
|
int CIB::GetPassiveHostChecksStatistics(long timespan)
|
||||||
{
|
{
|
||||||
return m_PassiveHostChecksStatistics.GetValues(timespan);
|
return m_PassiveHostChecksStatistics.UpdateAndGetValues(Utility::GetTime(), timespan);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CIB::GetPassiveServiceChecksStatistics(long timespan)
|
int CIB::GetPassiveServiceChecksStatistics(long timespan)
|
||||||
{
|
{
|
||||||
return m_PassiveServiceChecksStatistics.GetValues(timespan);
|
return m_PassiveServiceChecksStatistics.UpdateAndGetValues(Utility::GetTime(), timespan);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckableCheckStatistics CIB::CalculateHostCheckStats(void)
|
CheckableCheckStatistics CIB::CalculateHostCheckStats(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user