MCPcopy Create free account
hub / github.com/Icinga/icinga2 / LogStatsHandler

Method LogStatsHandler

lib/db_ido/dbconnection.cpp:270–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void DbConnection::LogStatsHandler()
271{
272 if (!GetConnected() || IsPaused())
273 return;
274
275 auto pending = m_PendingQueries.load();
276
277 auto now = Utility::GetTime();
278 bool timeoutReached = m_LogStatsTimeout < now;
279
280 if (pending == 0u && !timeoutReached) {
281 return;
282 }
283
284 auto output = round(m_OutputQueries.CalculateRate(now, 10));
285
286 if (pending < output * 5 && !timeoutReached) {
287 return;
288 }
289
290 auto input = round(m_InputQueries.CalculateRate(now, 10));
291
292 Log(LogInformation, GetReflectionType()->GetName())
293 << "Pending queries: " << pending << " (Input: " << input
294 << "/s; Output: " << output << "/s)";
295
296 /* Reschedule next log entry in 5 minutes. */
297 if (timeoutReached) {
298 m_LogStatsTimeout = now + 60 * 5;
299 }
300}
301
302void DbConnection::CleanUpExecuteQuery(const String&, const String&, double)
303{

Callers

nothing calls this directly

Calls 4

LogClass · 0.85
loadMethod · 0.80
CalculateRateMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected