* 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. */
| 465 | * @param perfdata The array to which the pending items statistics will be added. |
| 466 | */ |
| 467 | void 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 | } |
no test coverage detected