mirror of https://github.com/Icinga/icinga2.git
Icinga DB: log amount of history kept in memory every 10s
This commit is contained in:
parent
8ea62f7fc7
commit
ad0fe764f7
|
@ -38,6 +38,11 @@ public:
|
|||
Container ConsumeMany();
|
||||
SizeType Size();
|
||||
|
||||
inline SizeType GetBulkSize() const noexcept
|
||||
{
|
||||
return m_BulkSize;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::chrono::time_point<Clock> TimePoint;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "icinga/timeperiod.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include "remote/zone.hpp"
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
@ -2264,7 +2265,25 @@ void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const
|
|||
|
||||
void IcingaDB::ForwardHistoryEntries()
|
||||
{
|
||||
using clock = std::chrono::steady_clock;
|
||||
|
||||
const std::chrono::seconds logInterval (10);
|
||||
auto nextLog (clock::now() + logInterval);
|
||||
|
||||
auto logPeriodically ([this, logInterval, &nextLog]() {
|
||||
if (clock::now() > nextLog) {
|
||||
nextLog += logInterval;
|
||||
|
||||
auto size (m_HistoryBulker.Size());
|
||||
|
||||
Log(size > m_HistoryBulker.GetBulkSize() ? LogInformation : LogNotice, "IcingaDB")
|
||||
<< "Pending history queries: " << size;
|
||||
}
|
||||
});
|
||||
|
||||
for (;;) {
|
||||
logPeriodically();
|
||||
|
||||
auto haystack (m_HistoryBulker.ConsumeMany());
|
||||
|
||||
if (haystack.empty()) {
|
||||
|
@ -2288,6 +2307,8 @@ void IcingaDB::ForwardHistoryEntries()
|
|||
});
|
||||
|
||||
for (;;) {
|
||||
logPeriodically();
|
||||
|
||||
if (m_Rcon && m_Rcon->IsConnected()) {
|
||||
try {
|
||||
m_Rcon->GetResultsOfQueries(haystack, Prio::History);
|
||||
|
|
Loading…
Reference in New Issue