Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give PerfdataWriter a 👷‍♂️WorkQueue like e.g GraphiteWriter🖋️ #10267

Open
Al2Klimov opened this issue Dec 10, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers ref/NC

Comments

@Al2Klimov
Copy link
Member

Al2Klimov commented Dec 10, 2024

Describe the bug

On every Checkable::OnNewCheckResult, PerfdataWriter::CheckResultHandler locks m_StreamMutex and writes to HDD. This blocks Checkable::OnNewCheckResult callers, e.g Checkable::ProcessCheckResult().

To Reproduce

m_HandleCheckResults = Checkable::OnNewCheckResult.connect([this](const Checkable::Ptr& checkable,
const CheckResult::Ptr& cr, const MessageOrigin::Ptr&) {
CheckResultHandler(checkable, cr);

void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
{
if (IsPaused())
return;
CONTEXT("Writing performance data for object '" << checkable->GetName() << "'");
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !checkable->GetEnablePerfdata())
return;
Service::Ptr service = dynamic_pointer_cast<Service>(checkable);
Host::Ptr host;
if (service)
host = service->GetHost();
else
host = static_pointer_cast<Host>(checkable);
MacroProcessor::ResolverList resolvers;
if (service)
resolvers.emplace_back("service", service);
resolvers.emplace_back("host", host);
if (service) {
String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, nullptr, &PerfdataWriter::EscapeMacroMetric);
{
std::unique_lock<std::mutex> lock(m_StreamMutex);
if (!m_ServiceOutputFile.good())
return;
m_ServiceOutputFile << line << "\n";

Expected behavior

The actual work is put in a WorkQueue, exactly like GraphiteWriter does. Then Checkable::OnNewCheckResult() can return early.

Your Environment

Include as many relevant details about the environment you experienced the problem in

  • Version used (icinga2 --version): e50eb52

Additional context

ref/NC/820479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers ref/NC
Projects
None yet
Development

No branches or pull requests

1 participant