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

Method LoadPendingItemsStats

lib/icingadb/icingadb-worker.cpp:467–484  ·  view source on GitHub ↗

* Load statistics about the pending items queue into the provided perfdata array. * * This function retrieves statistics about the pending items queue, such as the current queue size and * the age of the oldest item, and adds them to the provided perfdata array as performance data values. * * @param perfdata The array to which the pending items statistics will be added. */

Source from the content-addressed store, hash-verified

465 * @param perfdata The array to which the pending items statistics will be added.
466 */
467void IcingaDB::LoadPendingItemsStats(const Array::Ptr& perfdata) const
468{
469 namespace ch = std::chrono;
470
471 std::size_t queueSize = 0;
472 double oldestItemAge{0};
473 {
474 std::lock_guard lock(m_PendingItemsMutex);
475 queueSize = m_PendingItems.size();
476 if (auto& seqView = m_PendingItems.get<1>(); !seqView.empty()) {
477 oldestItemAge = ch::duration_cast<ch::duration<double>>(
478 ch::steady_clock::now() - seqView.front().EnqueueTime
479 ).count();
480 }
481 }
482 perfdata->Add(new PerfdataValue("icinga2_pending_config_and_state_updates_count", static_cast<double>(queueSize)));
483 perfdata->Add(new PerfdataValue("icinga2_pending_config_and_state_updates_backlog", oldestItemAge, false, "seconds"));
484}

Callers 1

ScriptFuncMethod · 0.80

Calls 4

countMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected