mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 08:04:14 +02:00
Merge pull request #10397 from Icinga/activation-priority-10179
Checkable#ProcessCheckResult(): discard🗑️ CR or delay its producers shutdown
This commit is contained in:
commit
c253e7eb6e
@ -87,6 +87,7 @@ set(base_SOURCES
|
||||
unixsocket.cpp unixsocket.hpp
|
||||
utility.cpp utility.hpp
|
||||
value.cpp value.hpp value-operators.cpp
|
||||
wait-group.cpp wait-group.hpp
|
||||
win32.hpp
|
||||
workqueue.cpp workqueue.hpp
|
||||
)
|
||||
|
38
lib/base/wait-group.cpp
Normal file
38
lib/base/wait-group.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/* Icinga 2 | (c) 2025 Icinga GmbH | GPLv2+ */
|
||||
|
||||
#include "base/wait-group.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
bool StoppableWaitGroup::try_lock_shared()
|
||||
{
|
||||
std::unique_lock lock (m_Mutex);
|
||||
|
||||
if (m_Stopped) {
|
||||
return false;
|
||||
}
|
||||
|
||||
++m_SharedLocks;
|
||||
return true;
|
||||
}
|
||||
|
||||
void StoppableWaitGroup::unlock_shared()
|
||||
{
|
||||
std::unique_lock lock (m_Mutex);
|
||||
|
||||
if (!--m_SharedLocks && m_Stopped) {
|
||||
lock.unlock();
|
||||
m_CV.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disallow new shared locks, wait for all existing ones.
|
||||
*/
|
||||
void StoppableWaitGroup::Join()
|
||||
{
|
||||
std::unique_lock lock (m_Mutex);
|
||||
|
||||
m_Stopped = true;
|
||||
m_CV.wait(lock, [this] { return !m_SharedLocks; });
|
||||
}
|
54
lib/base/wait-group.hpp
Normal file
54
lib/base/wait-group.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/* Icinga 2 | (c) 2025 Icinga GmbH | GPLv2+ */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base/object.hpp"
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* A synchronization interface that allows concurrent shared locking.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class WaitGroup : public Object
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(WaitGroup);
|
||||
|
||||
virtual bool try_lock_shared() = 0;
|
||||
virtual void unlock_shared() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* A thread-safe wait group that can be stopped to prevent further shared locking.
|
||||
*
|
||||
* @ingroup base
|
||||
*/
|
||||
class StoppableWaitGroup : public WaitGroup
|
||||
{
|
||||
public:
|
||||
DECLARE_PTR_TYPEDEFS(StoppableWaitGroup);
|
||||
|
||||
StoppableWaitGroup() = default;
|
||||
StoppableWaitGroup(const StoppableWaitGroup&) = delete;
|
||||
StoppableWaitGroup(StoppableWaitGroup&&) = delete;
|
||||
StoppableWaitGroup& operator=(const StoppableWaitGroup&) = delete;
|
||||
StoppableWaitGroup& operator=(StoppableWaitGroup&&) = delete;
|
||||
|
||||
bool try_lock_shared() override;
|
||||
void unlock_shared() override;
|
||||
void Join();
|
||||
|
||||
private:
|
||||
std::mutex m_Mutex;
|
||||
std::condition_variable m_CV;
|
||||
uint_fast32_t m_SharedLocks = 0;
|
||||
bool m_Stopped = false;
|
||||
};
|
||||
|
||||
}
|
@ -81,6 +81,7 @@ void CheckerComponent::Stop(bool runtimeRemoved)
|
||||
m_CV.notify_all();
|
||||
}
|
||||
|
||||
m_WaitGroup->Join();
|
||||
m_ResultTimer->Stop(true);
|
||||
m_Thread.join();
|
||||
|
||||
@ -248,7 +249,7 @@ void CheckerComponent::CheckThreadProc()
|
||||
void CheckerComponent::ExecuteCheckHelper(const Checkable::Ptr& checkable)
|
||||
{
|
||||
try {
|
||||
checkable->ExecuteCheck();
|
||||
checkable->ExecuteCheck(m_WaitGroup);
|
||||
} catch (const std::exception& ex) {
|
||||
CheckResult::Ptr cr = new CheckResult();
|
||||
cr->SetState(ServiceUnknown);
|
||||
@ -262,7 +263,7 @@ void CheckerComponent::ExecuteCheckHelper(const Checkable::Ptr& checkable)
|
||||
cr->SetExecutionStart(now);
|
||||
cr->SetExecutionEnd(now);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, m_WaitGroup);
|
||||
|
||||
Log(LogCritical, "checker", output);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "base/configobject.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/key_extractors.hpp>
|
||||
@ -77,6 +78,7 @@ private:
|
||||
CheckableSet m_IdleCheckables;
|
||||
CheckableSet m_PendingCheckables;
|
||||
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
Timer::Ptr m_ResultTimer;
|
||||
|
||||
void CheckThreadProc();
|
||||
|
@ -50,6 +50,8 @@ void ExternalCommandListener::Start(bool runtimeCreated)
|
||||
*/
|
||||
void ExternalCommandListener::Stop(bool runtimeRemoved)
|
||||
{
|
||||
m_WaitGroup->Join();
|
||||
|
||||
Log(LogInformation, "ExternalCommandListener")
|
||||
<< "'" << GetName() << "' stopped.";
|
||||
|
||||
@ -136,7 +138,7 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
||||
Log(LogInformation, "ExternalCommandListener")
|
||||
<< "Executing external command: " << command;
|
||||
|
||||
ExternalCommandProcessor::Execute(command);
|
||||
ExternalCommandProcessor::Execute(m_WaitGroup, command);
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "ExternalCommandListener")
|
||||
<< "External command failed: " << DiagnosticInformation(ex, false);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "compat/externalcommandlistener-ti.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include <thread>
|
||||
@ -29,6 +30,8 @@ protected:
|
||||
void Stop(bool runtimeRemoved) override;
|
||||
|
||||
private:
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
|
||||
#ifndef _WIN32
|
||||
std::thread m_CommandThread;
|
||||
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IdoCheck, &IdoCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IdoCheck, &IdoCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
static void ReportIdoCheck(
|
||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
|
||||
const CheckResult::Ptr& cr, String output, ServiceState state = ServiceUnknown
|
||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj, const CheckResult::Ptr& cr,
|
||||
const WaitGroup::Ptr& producer, String output, ServiceState state = ServiceUnknown
|
||||
)
|
||||
{
|
||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||
@ -36,12 +36,12 @@ static void ReportIdoCheck(
|
||||
} else {
|
||||
cr->SetState(state);
|
||||
cr->SetOutput(output);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
||||
void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
ServiceState state;
|
||||
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
||||
@ -88,19 +88,19 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
return;
|
||||
|
||||
if (idoType.IsEmpty()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "Attribute 'ido_type' must be set.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "Attribute 'ido_type' must be set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (idoName.IsEmpty()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "Attribute 'ido_name' must be set.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "Attribute 'ido_name' must be set.");
|
||||
return;
|
||||
}
|
||||
|
||||
Type::Ptr type = Type::GetByName(idoType);
|
||||
|
||||
if (!type || !DbConnection::TypeInstance->IsAssignableFrom(type)) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "DB IDO type '" + idoType + "' is invalid.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO type '" + idoType + "' is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,14 +110,14 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
|
||||
|
||||
if (!conn) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "DB IDO connection '" + idoName + "' does not exist.");
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO connection '" + idoName + "' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
double qps = conn->GetQueryCount(60) / 60.0;
|
||||
|
||||
if (conn->IsPaused()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "DB IDO connection is temporarily disabled on this cluster instance.", ServiceOK);
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "DB IDO connection is temporarily disabled on this cluster instance.", ServiceOK);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -125,10 +125,10 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
|
||||
if (!conn->GetConnected()) {
|
||||
if (conn->GetShouldConnect()) {
|
||||
ReportIdoCheck(checkable, commandObj, cr, "Could not connect to the database server.", ServiceCritical);
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, "Could not connect to the database server.", ServiceCritical);
|
||||
} else {
|
||||
ReportIdoCheck(
|
||||
checkable, commandObj, cr,
|
||||
checkable, commandObj, cr, producer,
|
||||
"Not currently enabled: Another cluster instance is responsible for the IDO database.", ServiceOK
|
||||
);
|
||||
}
|
||||
@ -193,5 +193,5 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
||||
{ new PerfdataValue("pending_queries", pendingQueries, false, "", pendingQueriesWarning, pendingQueriesCritical) }
|
||||
}));
|
||||
|
||||
ReportIdoCheck(checkable, commandObj, cr, msgbuf.str(), state);
|
||||
ReportIdoCheck(checkable, commandObj, cr, producer, msgbuf.str(), state);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class IdoCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
IdoCheckTask();
|
||||
|
@ -126,7 +126,8 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
|
||||
if (params->Contains("ttl"))
|
||||
cr->SetTtl(HttpUtility::GetLastParameter(params, "ttl"));
|
||||
|
||||
Result result = checkable->ProcessCheckResult(cr);
|
||||
Result result = checkable->ProcessCheckResult(cr, ApiListener::GetInstance()->GetWaitGroup());
|
||||
|
||||
switch (result) {
|
||||
case Result::Ok:
|
||||
return ApiActions::CreateResult(200, "Successfully processed check result for object '" + checkable->GetName() + "'.");
|
||||
@ -787,7 +788,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, cons
|
||||
Defer resetCheckCommandOverride([]() {
|
||||
CheckCommand::ExecuteOverride = nullptr;
|
||||
});
|
||||
cmd->Execute(checkable, cr, execMacros, false);
|
||||
cmd->Execute(checkable, cr, listener->GetWaitGroup(), execMacros, false);
|
||||
}
|
||||
} else if (command_type == "EventCommand") {
|
||||
EventCommand::Ptr cmd = GetSingleObjectByNameUsingPermissions(EventCommand::GetTypeName(), resolved_command, ActionsHandler::AuthenticatedApiUser);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/convert.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include "base/context.hpp"
|
||||
#include <shared_mutex>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
@ -96,11 +97,12 @@ double Checkable::GetLastCheck() const
|
||||
return schedule_end;
|
||||
}
|
||||
|
||||
Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin)
|
||||
Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const WaitGroup::Ptr& producer, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
using Result = Checkable::ProcessingResult;
|
||||
|
||||
VERIFY(cr);
|
||||
VERIFY(producer);
|
||||
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
@ -135,6 +137,14 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
|
||||
cr->SetCheckSource(command_endpoint->GetName());
|
||||
}
|
||||
|
||||
std::shared_lock producerLock (*producer, std::try_to_lock);
|
||||
|
||||
if (!producerLock) {
|
||||
// Discard the check result to not delay the current reload.
|
||||
// We'll re-run the check immediately after the reload.
|
||||
return Result::CheckableInactive;
|
||||
}
|
||||
|
||||
/* agent checks go through the api */
|
||||
if (command_endpoint && GetExtension("agent_check")) {
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
@ -544,7 +554,7 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
|
||||
return Result::Ok;
|
||||
}
|
||||
|
||||
void Checkable::ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros)
|
||||
void Checkable::ExecuteRemoteCheck(const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros)
|
||||
{
|
||||
CONTEXT("Executing remote check for object '" << GetName() << "'");
|
||||
|
||||
@ -555,10 +565,10 @@ void Checkable::ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros)
|
||||
cr->SetScheduleStart(scheduled_start);
|
||||
cr->SetExecutionStart(before_check);
|
||||
|
||||
GetCheckCommand()->Execute(this, cr, resolvedMacros, true);
|
||||
GetCheckCommand()->Execute(this, cr, producer, resolvedMacros, true);
|
||||
}
|
||||
|
||||
void Checkable::ExecuteCheck()
|
||||
void Checkable::ExecuteCheck(const WaitGroup::Ptr& producer)
|
||||
{
|
||||
CONTEXT("Executing check for object '" << GetName() << "'");
|
||||
|
||||
@ -599,10 +609,10 @@ void Checkable::ExecuteCheck()
|
||||
bool local = !endpoint || endpoint == Endpoint::GetLocalEndpoint();
|
||||
|
||||
if (local) {
|
||||
GetCheckCommand()->Execute(this, cr, nullptr, false);
|
||||
GetCheckCommand()->Execute(this, cr, producer, nullptr, false);
|
||||
} else {
|
||||
Dictionary::Ptr macros = new Dictionary();
|
||||
GetCheckCommand()->Execute(this, cr, macros, false);
|
||||
GetCheckCommand()->Execute(this, cr, producer, macros, false);
|
||||
|
||||
if (endpoint->GetConnected()) {
|
||||
/* perform check on remote endpoint */
|
||||
@ -667,7 +677,7 @@ void Checkable::ExecuteCheck()
|
||||
|
||||
cr->SetOutput(output);
|
||||
|
||||
ProcessCheckResult(cr);
|
||||
ProcessCheckResult(cr, producer);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "base/function.hpp"
|
||||
#include "base/functionwrapper.hpp"
|
||||
#include "base/scriptframe.hpp"
|
||||
#include "remote/apilistener.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
@ -16,7 +17,9 @@ static void CheckableProcessCheckResult(const CheckResult::Ptr& cr)
|
||||
REQUIRE_NOT_NULL(self);
|
||||
|
||||
if (cr) {
|
||||
self->ProcessCheckResult(cr);
|
||||
auto api (ApiListener::GetInstance());
|
||||
|
||||
self->ProcessCheckResult(cr, api ? api->GetWaitGroup() : new StoppableWaitGroup());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "icinga/notification.hpp"
|
||||
#include "icinga/comment.hpp"
|
||||
#include "icinga/downtime.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include "remote/endpoint.hpp"
|
||||
#include "remote/messageorigin.hpp"
|
||||
#include <condition_variable>
|
||||
@ -114,15 +115,17 @@ public:
|
||||
|
||||
static void UpdateStatistics(const CheckResult::Ptr& cr, CheckableType type);
|
||||
|
||||
void ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros = nullptr);
|
||||
void ExecuteCheck();
|
||||
void ExecuteRemoteCheck(const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros = nullptr);
|
||||
void ExecuteCheck(const WaitGroup::Ptr& producer);
|
||||
|
||||
enum class ProcessingResult
|
||||
{
|
||||
Ok,
|
||||
CheckableInactive,
|
||||
NewerCheckResultPresent,
|
||||
};
|
||||
ProcessingResult ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin = nullptr);
|
||||
|
||||
ProcessingResult ProcessCheckResult(const CheckResult::Ptr& cr, const WaitGroup::Ptr& producer, const MessageOrigin::Ptr& origin = nullptr);
|
||||
|
||||
Endpoint::Ptr GetCommandEndpoint() const;
|
||||
|
||||
|
@ -11,11 +11,12 @@ REGISTER_TYPE(CheckCommand);
|
||||
thread_local CheckCommand::Ptr CheckCommand::ExecuteOverride;
|
||||
|
||||
void CheckCommand::Execute(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
GetExecute()->Invoke({
|
||||
checkable,
|
||||
cr,
|
||||
producer,
|
||||
resolvedMacros,
|
||||
useResolvedMacros
|
||||
});
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
static thread_local CheckCommand::Ptr ExecuteOverride;
|
||||
|
||||
void Execute(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const WaitGroup::Ptr& producer,
|
||||
const Dictionary::Ptr& resolvedMacros = nullptr,
|
||||
bool useResolvedMacros = false);
|
||||
};
|
||||
|
@ -279,7 +279,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||
|
||||
if (command_type == "check_command") {
|
||||
try {
|
||||
host->ExecuteRemoteCheck(macros);
|
||||
host->ExecuteRemoteCheck(ApiListener::GetInstance()->GetWaitGroup(), macros);
|
||||
} catch (const std::exception& ex) {
|
||||
String output = "Exception occurred while checking '" + host->GetName() + "': " + DiagnosticInformation(ex);
|
||||
ServiceState state = ServiceUnknown;
|
||||
|
@ -176,9 +176,9 @@ Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, con
|
||||
}
|
||||
|
||||
if (!checkable->IsPaused() && Zone::GetLocalZone() == checkable->GetZone() && endpoint == checkable->GetCommandEndpoint())
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, ApiListener::GetInstance()->GetWaitGroup());
|
||||
else
|
||||
checkable->ProcessCheckResult(cr, origin);
|
||||
checkable->ProcessCheckResult(cr, ApiListener::GetInstance()->GetWaitGroup(), origin);
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ using namespace icinga;
|
||||
|
||||
boost::signals2::signal<void(double, const String&, const std::vector<String>&)> ExternalCommandProcessor::OnNewExternalCommand;
|
||||
|
||||
void ExternalCommandProcessor::Execute(const String& line)
|
||||
void ExternalCommandProcessor::Execute(const WaitGroup::Ptr& producer, const String& line)
|
||||
{
|
||||
if (line.IsEmpty())
|
||||
return;
|
||||
@ -54,10 +54,10 @@ void ExternalCommandProcessor::Execute(const String& line)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Missing arguments in command: " + line));
|
||||
|
||||
std::vector<String> argvExtra(argv.begin() + 1, argv.end());
|
||||
Execute(ts, argv[0], argvExtra);
|
||||
Execute(producer, ts, argv[0], argvExtra);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::Execute(double time, const String& command, const std::vector<String>& arguments)
|
||||
void ExternalCommandProcessor::Execute(const WaitGroup::Ptr& producer, double time, const String& command, const std::vector<String>& arguments)
|
||||
{
|
||||
ExternalCommandInfo eci;
|
||||
|
||||
@ -102,7 +102,7 @@ void ExternalCommandProcessor::Execute(double time, const String& command, const
|
||||
|
||||
OnNewExternalCommand(time, command, realArguments);
|
||||
|
||||
eci.Callback(time, realArguments);
|
||||
eci.Callback(producer, time, realArguments);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::RegisterCommand(const String& command, const ExternalCommandCallback& callback, size_t minArgs, size_t maxArgs)
|
||||
@ -115,6 +115,16 @@ void ExternalCommandProcessor::RegisterCommand(const String& command, const Exte
|
||||
GetCommands()[command] = eci;
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::RegisterCommand(const String& command, const ExternalCommandCallbackLite& callback, size_t minArgs, size_t maxArgs)
|
||||
{
|
||||
RegisterCommand(
|
||||
command,
|
||||
[callback](const WaitGroup::Ptr&, double time, const std::vector<String>& args) { callback(time, args); },
|
||||
minArgs,
|
||||
maxArgs
|
||||
);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::RegisterCommands()
|
||||
{
|
||||
RegisterCommand("PROCESS_HOST_CHECK_RESULT", &ExternalCommandProcessor::ProcessHostCheckResult, 3);
|
||||
@ -237,7 +247,7 @@ void ExternalCommandProcessor::RegisterCommands()
|
||||
RegisterCommand("DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS", &ExternalCommandProcessor::DisableServicegroupSvcNotifications, 1);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ExecuteFromFile(const String& line, std::deque< std::vector<String> >& file_queue)
|
||||
void ExternalCommandProcessor::ExecuteFromFile(const WaitGroup::Ptr& producer, const String& line, std::deque<std::vector<String>>& file_queue)
|
||||
{
|
||||
if (line.IsEmpty())
|
||||
return;
|
||||
@ -270,11 +280,11 @@ void ExternalCommandProcessor::ExecuteFromFile(const String& line, std::deque< s
|
||||
<< "Enqueing external command file " << argvExtra[0];
|
||||
file_queue.push_back(argvExtra);
|
||||
} else {
|
||||
Execute(ts, argv[0], argvExtra);
|
||||
Execute(producer, ts, argv[0], argvExtra);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::vector<String>& arguments)
|
||||
void ExternalCommandProcessor::ProcessHostCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments)
|
||||
{
|
||||
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||
|
||||
@ -318,10 +328,10 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
|
||||
Log(LogNotice, "ExternalCommandProcessor")
|
||||
<< "Processing passive check result for host '" << arguments[0] << "'";
|
||||
|
||||
host->ProcessCheckResult(result);
|
||||
host->ProcessCheckResult(result, producer);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std::vector<String>& arguments)
|
||||
void ExternalCommandProcessor::ProcessServiceCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments)
|
||||
{
|
||||
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
|
||||
|
||||
@ -356,7 +366,7 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
|
||||
Log(LogNotice, "ExternalCommandProcessor")
|
||||
<< "Processing passive check result for service '" << arguments[1] << "'";
|
||||
|
||||
service->ProcessCheckResult(result);
|
||||
service->ProcessCheckResult(result, producer);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vector<String>& arguments)
|
||||
@ -921,7 +931,7 @@ void ExternalCommandProcessor::DisableHostgroupPassiveSvcChecks(double, const st
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ProcessFile(double, const std::vector<String>& arguments)
|
||||
void ExternalCommandProcessor::ProcessFile(const WaitGroup::Ptr& producer, double, const std::vector<String>& arguments)
|
||||
{
|
||||
std::deque< std::vector<String> > file_queue;
|
||||
file_queue.push_back(arguments);
|
||||
@ -946,7 +956,7 @@ void ExternalCommandProcessor::ProcessFile(double, const std::vector<String>& ar
|
||||
Log(LogNotice, "compat")
|
||||
<< "Executing external command: " << line;
|
||||
|
||||
ExecuteFromFile(line, file_queue);
|
||||
ExecuteFromFile(producer, line, file_queue);
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "ExternalCommandProcessor")
|
||||
<< "External command failed: " << DiagnosticInformation(ex);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "icinga/i2-icinga.hpp"
|
||||
#include "icinga/command.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include "base/string.hpp"
|
||||
#include <boost/signals2.hpp>
|
||||
#include <vector>
|
||||
@ -12,7 +13,8 @@
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
typedef std::function<void (double, const std::vector<String>& arguments)> ExternalCommandCallback;
|
||||
typedef std::function<void(const WaitGroup::Ptr&, double, const std::vector<String>& arguments)> ExternalCommandCallback;
|
||||
typedef std::function<void(double, const std::vector<String>& arguments)> ExternalCommandCallbackLite;
|
||||
|
||||
struct ExternalCommandInfo
|
||||
{
|
||||
@ -23,18 +25,18 @@ struct ExternalCommandInfo
|
||||
|
||||
class ExternalCommandProcessor {
|
||||
public:
|
||||
static void Execute(const String& line);
|
||||
static void Execute(double time, const String& command, const std::vector<String>& arguments);
|
||||
static void Execute(const WaitGroup::Ptr& producer, const String& line);
|
||||
static void Execute(const WaitGroup::Ptr& producer, double time, const String& command, const std::vector<String>& arguments);
|
||||
|
||||
static boost::signals2::signal<void(double, const String&, const std::vector<String>&)> OnNewExternalCommand;
|
||||
|
||||
private:
|
||||
ExternalCommandProcessor();
|
||||
|
||||
static void ExecuteFromFile(const String& line, std::deque< std::vector<String> >& file_queue);
|
||||
static void ExecuteFromFile(const WaitGroup::Ptr& producer, const String& line, std::deque<std::vector<String>>& file_queue);
|
||||
|
||||
static void ProcessHostCheckResult(double time, const std::vector<String>& arguments);
|
||||
static void ProcessServiceCheckResult(double time, const std::vector<String>& arguments);
|
||||
static void ProcessHostCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments);
|
||||
static void ProcessServiceCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments);
|
||||
static void ScheduleHostCheck(double time, const std::vector<String>& arguments);
|
||||
static void ScheduleForcedHostCheck(double time, const std::vector<String>& arguments);
|
||||
static void ScheduleSvcCheck(double time, const std::vector<String>& arguments);
|
||||
@ -67,7 +69,7 @@ private:
|
||||
static void DisableServicegroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
||||
static void EnableHostgroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
||||
static void DisableHostgroupPassiveSvcChecks(double time, const std::vector<String>& arguments);
|
||||
static void ProcessFile(double time, const std::vector<String>& arguments);
|
||||
static void ProcessFile(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments);
|
||||
static void ScheduleSvcDowntime(double time, const std::vector<String>& arguments);
|
||||
static void DelSvcDowntime(double time, const std::vector<String>& arguments);
|
||||
static void ScheduleHostDowntime(double time, const std::vector<String>& arguments);
|
||||
@ -157,6 +159,7 @@ private:
|
||||
static void ChangeCustomCommandVarInternal(const Command::Ptr& command, const String& name, const Value& value);
|
||||
|
||||
static void RegisterCommand(const String& command, const ExternalCommandCallback& callback, size_t minArgs = 0, size_t maxArgs = UINT_MAX);
|
||||
static void RegisterCommand(const String& command, const ExternalCommandCallbackLite& callback, size_t minArgs = 0, size_t maxArgs = UINT_MAX);
|
||||
static void RegisterCommands();
|
||||
|
||||
static std::mutex& GetMutex();
|
||||
|
@ -13,11 +13,11 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IcingadbCheck, &IcingadbCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IcingadbCheck, &IcingadbCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
static void ReportIcingadbCheck(
|
||||
const Checkable::Ptr& checkable, const CheckCommand::Ptr& commandObj,
|
||||
const CheckResult::Ptr& cr, String output, ServiceState state)
|
||||
const CheckResult::Ptr& cr, const WaitGroup::Ptr& producer, String output, ServiceState state)
|
||||
{
|
||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||
double now = Utility::GetTime();
|
||||
@ -32,7 +32,7 @@ static void ReportIcingadbCheck(
|
||||
} else {
|
||||
cr->SetState(state);
|
||||
cr->SetOutput(output);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ double GetXMessageTs(const Array::Ptr& xMessage)
|
||||
}
|
||||
|
||||
void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
|
||||
|
||||
@ -87,21 +87,21 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
||||
return;
|
||||
|
||||
if (icingadbName.IsEmpty()) {
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB UNKNOWN: Attribute 'icingadb_name' must be set.", ServiceUnknown);
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB UNKNOWN: Attribute 'icingadb_name' must be set.", ServiceUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
auto conn (IcingaDB::GetByName(icingadbName));
|
||||
|
||||
if (!conn) {
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB UNKNOWN: Icinga DB connection '" + icingadbName + "' does not exist.", ServiceUnknown);
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB UNKNOWN: Icinga DB connection '" + icingadbName + "' does not exist.", ServiceUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
auto redis (conn->GetConnection());
|
||||
|
||||
if (!redis || !redis->GetConnected()) {
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, "Icinga DB CRITICAL: Not connected to Redis.", ServiceCritical);
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, producer, "Icinga DB CRITICAL: Not connected to Redis.", ServiceCritical);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
||||
xReadHistoryBacklog = std::move(replies.at(4));
|
||||
} catch (const std::exception& ex) {
|
||||
ReportIcingadbCheck(
|
||||
checkable, commandObj, cr,
|
||||
checkable, commandObj, cr, producer,
|
||||
String("Icinga DB CRITICAL: Could not query Redis: ") + ex.what(), ServiceCritical
|
||||
);
|
||||
return;
|
||||
@ -144,7 +144,7 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
||||
|
||||
if (!xReadHeartbeat) {
|
||||
ReportIcingadbCheck(
|
||||
checkable, commandObj, cr,
|
||||
checkable, commandObj, cr, producer,
|
||||
"Icinga DB CRITICAL: The Icinga DB daemon seems to have never run. (Missing heartbeat)",
|
||||
ServiceCritical
|
||||
);
|
||||
@ -511,5 +511,5 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR
|
||||
}
|
||||
|
||||
cr->SetPerformanceData(perfdata);
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, msgbuf.str(), state);
|
||||
ReportIcingadbCheck(checkable, commandObj, cr, producer, msgbuf.str(), state);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class IcingadbCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
IcingadbCheckTask();
|
||||
|
@ -112,6 +112,7 @@ void LivestatusListener::Stop(bool runtimeRemoved)
|
||||
<< "'" << GetName() << "' stopped.";
|
||||
|
||||
m_Listener->Close();
|
||||
m_WaitGroup->Join();
|
||||
|
||||
if (m_Thread.joinable())
|
||||
m_Thread.join();
|
||||
@ -191,7 +192,7 @@ void LivestatusListener::ClientHandler(const Socket::Ptr& client)
|
||||
break;
|
||||
|
||||
LivestatusQuery::Ptr query = new LivestatusQuery(lines, GetCompatLogPath());
|
||||
if (!query->Execute(stream))
|
||||
if (!query->Execute(m_WaitGroup, stream))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "livestatus/livestatuslistener-ti.hpp"
|
||||
#include "livestatus/livestatusquery.hpp"
|
||||
#include "base/socket.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include <thread>
|
||||
|
||||
using namespace icinga;
|
||||
@ -40,6 +41,7 @@ private:
|
||||
|
||||
Socket::Ptr m_Listener;
|
||||
std::thread m_Thread;
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream)
|
||||
SendResponse(stream, LivestatusErrorOK, result.str());
|
||||
}
|
||||
|
||||
void LivestatusQuery::ExecuteCommandHelper(const Stream::Ptr& stream)
|
||||
void LivestatusQuery::ExecuteCommandHelper(const WaitGroup::Ptr& producer, const Stream::Ptr& stream)
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(l_QueryMutex);
|
||||
@ -580,7 +580,7 @@ void LivestatusQuery::ExecuteCommandHelper(const Stream::Ptr& stream)
|
||||
|
||||
Log(LogNotice, "LivestatusQuery")
|
||||
<< "Executing command: " << m_Command;
|
||||
ExternalCommandProcessor::Execute(m_Command);
|
||||
ExternalCommandProcessor::Execute(producer, m_Command);
|
||||
SendResponse(stream, LivestatusErrorOK, "");
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ void LivestatusQuery::PrintFixed16(const Stream::Ptr& stream, int code, const St
|
||||
}
|
||||
}
|
||||
|
||||
bool LivestatusQuery::Execute(const Stream::Ptr& stream)
|
||||
bool LivestatusQuery::Execute(const WaitGroup::Ptr& producer, const Stream::Ptr& stream)
|
||||
{
|
||||
try {
|
||||
Log(LogNotice, "LivestatusQuery")
|
||||
@ -630,7 +630,7 @@ bool LivestatusQuery::Execute(const Stream::Ptr& stream)
|
||||
if (m_Verb == "GET")
|
||||
ExecuteGetHelper(stream);
|
||||
else if (m_Verb == "COMMAND")
|
||||
ExecuteCommandHelper(stream);
|
||||
ExecuteCommandHelper(producer, stream);
|
||||
else if (m_Verb == "ERROR")
|
||||
ExecuteErrorHelper(stream);
|
||||
else
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "livestatus/filter.hpp"
|
||||
#include "livestatus/aggregator.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include "base/object.hpp"
|
||||
#include "base/array.hpp"
|
||||
#include "base/stream.hpp"
|
||||
@ -33,7 +34,7 @@ public:
|
||||
|
||||
LivestatusQuery(const std::vector<String>& lines, const String& compat_log_path);
|
||||
|
||||
bool Execute(const Stream::Ptr& stream);
|
||||
bool Execute(const WaitGroup::Ptr& producer, const Stream::Ptr& stream);
|
||||
|
||||
static int GetExternalCommands();
|
||||
|
||||
@ -76,7 +77,7 @@ private:
|
||||
static String QuoteStringPython(const String& str);
|
||||
|
||||
void ExecuteGetHelper(const Stream::Ptr& stream);
|
||||
void ExecuteCommandHelper(const Stream::Ptr& stream);
|
||||
void ExecuteCommandHelper(const WaitGroup::Ptr& producer, const Stream::Ptr& stream);
|
||||
void ExecuteErrorHelper(const Stream::Ptr& stream);
|
||||
|
||||
void SendResponse(const Stream::Ptr& stream, int code, const String& data);
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -47,7 +47,7 @@ void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRe
|
||||
} else {
|
||||
cr->SetOutput(output);
|
||||
cr->SetState(ServiceUnknown);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -92,7 +92,7 @@ void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRe
|
||||
cr->SetState(state);
|
||||
cr->SetOutput(output);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class ClusterCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
ClusterCheckTask();
|
||||
|
@ -12,10 +12,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -42,7 +42,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
||||
cr->SetCommand(commandName);
|
||||
cr->SetOutput(output);
|
||||
cr->SetState(state);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -97,7 +97,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
||||
cr->SetCommand(commandName);
|
||||
cr->SetOutput(output);
|
||||
cr->SetState(state);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -123,7 +123,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
||||
cr->SetCommand(commandName);
|
||||
cr->SetOutput(output);
|
||||
cr->SetState(state);
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -213,6 +213,6 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
||||
new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond)
|
||||
}));
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class ClusterZoneCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
ClusterZoneCheckTask();
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, DummyCheck, &DummyCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, DummyCheck, &DummyCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -70,6 +70,6 @@ void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu
|
||||
cr->SetExecutionEnd(now);
|
||||
cr->SetCommand(commandName);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class DummyCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
DummyCheckTask();
|
||||
|
@ -12,10 +12,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, ExceptionCheck, &ExceptionCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, ExceptionCheck, &ExceptionCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void ExceptionCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr&, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
|
@ -18,7 +18,7 @@ class ExceptionCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
ExceptionCheckTask();
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IcingaCheck, &IcingaCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IcingaCheck, &IcingaCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -204,6 +204,6 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||
cr->SetOutput(output);
|
||||
cr->SetCommand(commandName);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class IcingaCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
IcingaCheckTask();
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IfwApiCheck, &IfwApiCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, IfwApiCheck, &IfwApiCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
static const char* GetUnderstandableError(const std::exception& ex)
|
||||
{
|
||||
@ -194,7 +194,7 @@ static void DoIfwNetIo(
|
||||
}
|
||||
|
||||
void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
namespace asio = boost::asio;
|
||||
namespace http = boost::beast::http;
|
||||
@ -213,7 +213,7 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||
if (!(commandEndpoint->GetCapabilities() & (uint_fast64_t)ApiCapabilities::IfwApiCheckCommand)) {
|
||||
// Assume "ifw-api-check-command" has been imported into a check command which can also work
|
||||
// based on "plugin-check-command", delegate respectively and hope for the best
|
||||
PluginCheckTask::ScriptFunc(checkable, cr, resolvedMacros, useResolvedMacros);
|
||||
PluginCheckTask::ScriptFunc(checkable, cr, producer, resolvedMacros, useResolvedMacros);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||
callback(cr->GetCommand(), pr);
|
||||
};
|
||||
} else {
|
||||
reportResult = [checkable, cr]() { checkable->ProcessCheckResult(cr); };
|
||||
reportResult = [checkable, cr, producer] { checkable->ProcessCheckResult(cr, producer); };
|
||||
}
|
||||
|
||||
// Set the default check result state and exit code to unknown for the moment!
|
||||
|
@ -18,7 +18,7 @@ class IfwApiCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
IfwApiCheckTask();
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, NullCheck, &NullCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, NullCheck, &NullCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void NullCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -45,6 +45,6 @@ void NullCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResul
|
||||
}));
|
||||
cr->SetState(state);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class NullCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
NullCheckTask();
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, PluginCheck, &PluginCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, PluginCheck, &PluginCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -48,8 +48,8 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||
callback = Checkable::ExecuteCommandProcessFinishedHandler;
|
||||
} else {
|
||||
callback = [checkable, cr](const Value& commandLine, const ProcessResult& pr) {
|
||||
ProcessFinishedHandler(checkable, cr, commandLine, pr);
|
||||
callback = [checkable, cr, producer](const Value& commandLine, const ProcessResult& pr) {
|
||||
ProcessFinishedHandler(checkable, cr, producer, commandLine, pr);
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,7 +62,8 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||
}
|
||||
}
|
||||
|
||||
void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr)
|
||||
void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const WaitGroup::Ptr& producer, const Value& commandLine, const ProcessResult& pr)
|
||||
{
|
||||
Checkable::CurrentConcurrentChecks.fetch_sub(1);
|
||||
Checkable::DecreasePendingChecks();
|
||||
@ -93,5 +94,5 @@ void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, co
|
||||
cr->SetExecutionStart(pr.ExecutionStart);
|
||||
cr->SetExecutionEnd(pr.ExecutionEnd);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ class PluginCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
PluginCheckTask();
|
||||
|
||||
static void ProcessFinishedHandler(const Checkable::Ptr& service,
|
||||
const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr);
|
||||
static void ProcessFinishedHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const WaitGroup::Ptr& producer, const Value& commandLine, const ProcessResult& pr);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, RandomCheck, &RandomCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, RandomCheck, &RandomCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void RandomCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -60,6 +60,6 @@ void RandomCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||
cr->SetState(state);
|
||||
cr->SetCommand(commandName);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class RandomCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
RandomCheckTask();
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_FUNCTION_NONCONST(Internal, SleepCheck, &SleepCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
|
||||
REGISTER_FUNCTION_NONCONST(Internal, SleepCheck, &SleepCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
|
||||
|
||||
void SleepCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||
{
|
||||
REQUIRE_NOT_NULL(checkable);
|
||||
REQUIRE_NOT_NULL(cr);
|
||||
@ -62,6 +62,6 @@ void SleepCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu
|
||||
cr->SetExecutionEnd(now);
|
||||
cr->SetCommand(commandName);
|
||||
|
||||
checkable->ProcessCheckResult(cr);
|
||||
checkable->ProcessCheckResult(cr, producer);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class SleepCheckTask
|
||||
{
|
||||
public:
|
||||
static void ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||
|
||||
private:
|
||||
SleepCheckTask();
|
||||
|
@ -368,6 +368,7 @@ void ApiListener::Stop(bool runtimeDeleted)
|
||||
m_Timer->Stop(true);
|
||||
m_RenewOwnCertTimer->Stop(true);
|
||||
|
||||
m_WaitGroup->Join();
|
||||
ObjectImpl<ApiListener>::Stop(runtimeDeleted);
|
||||
|
||||
Log(LogInformation, "ApiListener")
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "base/tcpsocket.hpp"
|
||||
#include "base/tlsstream.hpp"
|
||||
#include "base/threadpool.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include <atomic>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
@ -151,6 +152,11 @@ public:
|
||||
double GetTlsHandshakeTimeout() const override;
|
||||
void SetTlsHandshakeTimeout(double value, bool suppress_events, const Value& cookie) override;
|
||||
|
||||
WaitGroup::Ptr GetWaitGroup() const
|
||||
{
|
||||
return m_WaitGroup;
|
||||
}
|
||||
|
||||
protected:
|
||||
void OnConfigLoaded() override;
|
||||
void OnAllConfigLoaded() override;
|
||||
@ -177,6 +183,7 @@ private:
|
||||
Timer::Ptr m_RenewOwnCertTimer;
|
||||
|
||||
Endpoint::Ptr m_LocalEndpoint;
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
|
||||
static ApiListener::Ptr m_Instance;
|
||||
static std::atomic<bool> m_UpdatedObjectAuthority;
|
||||
|
@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(host_not_flapping)
|
||||
int i = 0;
|
||||
while (i++ < 10) {
|
||||
// For some reason, elusive to me, the first check is a state change
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
|
||||
LogFlapping(host);
|
||||
LogHostStatus(host);
|
||||
@ -107,9 +107,9 @@ BOOST_AUTO_TEST_CASE(host_flapping)
|
||||
int i = 0;
|
||||
while (i++ < 25) {
|
||||
if (i % 2)
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
else
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
|
||||
LogFlapping(host);
|
||||
LogHostStatus(host);
|
||||
@ -144,18 +144,18 @@ BOOST_AUTO_TEST_CASE(host_flapping_recover)
|
||||
Utility::SetTime(0);
|
||||
|
||||
// A few warning
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
|
||||
LogFlapping(host);
|
||||
LogHostStatus(host);
|
||||
for (int i = 0; i <= 7; i++) {
|
||||
if (i % 2)
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
else
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
}
|
||||
|
||||
LogFlapping(host);
|
||||
@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(host_flapping_recover)
|
||||
BOOST_CHECK(host->GetFlappingCurrent() > 25.0);
|
||||
BOOST_CHECK(host->IsFlapping());
|
||||
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
LogFlapping(host);
|
||||
LogHostStatus(host);
|
||||
count++;
|
||||
@ -203,40 +203,40 @@ BOOST_AUTO_TEST_CASE(host_flapping_docs_example)
|
||||
|
||||
Utility::SetTime(0);
|
||||
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceWarning), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
|
||||
LogFlapping(host);
|
||||
LogHostStatus(host);
|
||||
BOOST_CHECK(host->GetFlappingCurrent() == 39.1);
|
||||
BOOST_CHECK(host->IsFlapping());
|
||||
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
|
||||
LogFlapping(host);
|
||||
LogHostStatus(host);
|
||||
|
@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(host_1attempt)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "First check result (unknown)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(host_1attempt)
|
||||
CheckNotification(host, true, NotificationProblem);
|
||||
|
||||
std::cout << "Second check result (ok)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostUp);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(host_1attempt)
|
||||
CheckNotification(host, true, NotificationRecovery);
|
||||
|
||||
std::cout << "Third check result (critical)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(host_1attempt)
|
||||
CheckNotification(host, true, NotificationProblem);
|
||||
|
||||
std::cout << "Fourth check result (ok)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostUp);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(host_2attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "First check result (unknown)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(host_2attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "Second check result (critical)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(host_2attempts)
|
||||
CheckNotification(host, true, NotificationProblem);
|
||||
|
||||
std::cout << "Third check result (ok)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostUp);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(host_2attempts)
|
||||
CheckNotification(host, true, NotificationRecovery);
|
||||
|
||||
std::cout << "Fourth check result (critical)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(host_2attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "Fifth check result (ok)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostUp);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(host_3attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "First check result (unknown)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(host_3attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "Second check result (critical)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 2);
|
||||
@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(host_3attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "Third check result (critical)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(host_3attempts)
|
||||
CheckNotification(host, true, NotificationProblem);
|
||||
|
||||
std::cout << "Fourth check result (ok)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostUp);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(host_3attempts)
|
||||
CheckNotification(host, true, NotificationRecovery);
|
||||
|
||||
std::cout << "Fifth check result (critical)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostDown);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE(host_3attempts)
|
||||
CheckNotification(host, false);
|
||||
|
||||
std::cout << "Sixth check result (ok)" << std::endl;
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(host->GetState() == HostUp);
|
||||
BOOST_CHECK(host->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(host->GetCheckAttempt() == 1);
|
||||
@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE(service_1attempt)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "First check result (unknown)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceUnknown);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -272,7 +272,7 @@ BOOST_AUTO_TEST_CASE(service_1attempt)
|
||||
CheckNotification(service, true, NotificationProblem);
|
||||
|
||||
std::cout << "Second check result (ok)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceOK);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -280,7 +280,7 @@ BOOST_AUTO_TEST_CASE(service_1attempt)
|
||||
CheckNotification(service, true, NotificationRecovery);
|
||||
|
||||
std::cout << "Third check result (critical)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceCritical);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -288,7 +288,7 @@ BOOST_AUTO_TEST_CASE(service_1attempt)
|
||||
CheckNotification(service, true, NotificationProblem);
|
||||
|
||||
std::cout << "Fourth check result (ok)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceOK);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(service_2attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "First check result (unknown)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceUnknown);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(service_2attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "Second check result (critical)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceCritical);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(service_2attempts)
|
||||
CheckNotification(service, true, NotificationProblem);
|
||||
|
||||
std::cout << "Third check result (ok)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceOK);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(service_2attempts)
|
||||
CheckNotification(service, true, NotificationRecovery);
|
||||
|
||||
std::cout << "Fourth check result (critical)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceCritical);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -353,7 +353,7 @@ BOOST_AUTO_TEST_CASE(service_2attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "Fifth check result (ok)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceOK);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE(service_3attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "First check result (unknown)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceUnknown);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE(service_3attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "Second check result (critical)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceCritical);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 2);
|
||||
@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(service_3attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "Third check result (critical)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceCritical);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -410,7 +410,7 @@ BOOST_AUTO_TEST_CASE(service_3attempts)
|
||||
CheckNotification(service, true, NotificationProblem);
|
||||
|
||||
std::cout << "Fourth check result (ok)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceOK);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -418,7 +418,7 @@ BOOST_AUTO_TEST_CASE(service_3attempts)
|
||||
CheckNotification(service, true, NotificationRecovery);
|
||||
|
||||
std::cout << "Fifth check result (critical)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceCritical);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeSoft);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(service_3attempts)
|
||||
CheckNotification(service, false);
|
||||
|
||||
std::cout << "Sixth check result (ok)" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == ServiceOK);
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
BOOST_CHECK(service->GetCheckAttempt() == 1);
|
||||
@ -470,7 +470,7 @@ BOOST_AUTO_TEST_CASE(host_flapping_notification)
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ServiceState state = (i % 2 == 0 ? ServiceOK : ServiceCritical);
|
||||
host->ProcessCheckResult(MakeCheckResult(state));
|
||||
host->ProcessCheckResult(MakeCheckResult(state), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE(host_flapping_notification)
|
||||
std::cout << "Now calm down..." << std::endl;
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
host->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -527,7 +527,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_notification)
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ServiceState state = (i % 2 == 0 ? ServiceOK : ServiceCritical);
|
||||
service->ProcessCheckResult(MakeCheckResult(state));
|
||||
service->ProcessCheckResult(MakeCheckResult(state), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_notification)
|
||||
std::cout << "Now calm down..." << std::endl;
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_problem_notifications)
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ServiceState state = (i % 2 == 0 ? ServiceOK : ServiceCritical);
|
||||
service->ProcessCheckResult(MakeCheckResult(state));
|
||||
service->ProcessCheckResult(MakeCheckResult(state), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -595,11 +595,11 @@ BOOST_AUTO_TEST_CASE(service_flapping_problem_notifications)
|
||||
|
||||
//Insert enough check results to get into hard problem state but staying flapping
|
||||
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
|
||||
|
||||
@ -611,7 +611,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_problem_notifications)
|
||||
|
||||
// Calm down
|
||||
while (service->IsFlapping()) {
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_problem_notifications)
|
||||
// Known failure, see #5713
|
||||
// CheckNotification(service, true, NotificationProblem);
|
||||
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
|
||||
// Known failure, see #5713
|
||||
@ -686,7 +686,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_ok_into_bad)
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ServiceState state = (i % 2 == 0 ? ServiceOK : ServiceCritical);
|
||||
service->ProcessCheckResult(MakeCheckResult(state));
|
||||
service->ProcessCheckResult(MakeCheckResult(state), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -696,11 +696,11 @@ BOOST_AUTO_TEST_CASE(service_flapping_ok_into_bad)
|
||||
|
||||
//Insert enough check results to get into hard problem state but staying flapping
|
||||
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
|
||||
|
||||
@ -712,13 +712,13 @@ BOOST_AUTO_TEST_CASE(service_flapping_ok_into_bad)
|
||||
|
||||
// Calm down
|
||||
while (service->IsFlapping()) {
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
CheckNotification(service, true, NotificationFlappingEnd);
|
||||
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
|
||||
BOOST_CHECK(service->IsFlapping() == false);
|
||||
@ -767,7 +767,7 @@ BOOST_AUTO_TEST_CASE(service_flapping_ok_over_bad_into_ok)
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ServiceState state = (i % 2 == 0 ? ServiceOK : ServiceCritical);
|
||||
service->ProcessCheckResult(MakeCheckResult(state));
|
||||
service->ProcessCheckResult(MakeCheckResult(state), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
@ -777,11 +777,11 @@ BOOST_AUTO_TEST_CASE(service_flapping_ok_over_bad_into_ok)
|
||||
|
||||
//Insert enough check results to get into hard problem state but staying flapping
|
||||
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
|
||||
|
||||
@ -793,13 +793,13 @@ BOOST_AUTO_TEST_CASE(service_flapping_ok_over_bad_into_ok)
|
||||
|
||||
// Calm down
|
||||
while (service->IsFlapping()) {
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceCritical), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
}
|
||||
|
||||
CheckNotification(service, true, NotificationFlappingEnd);
|
||||
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK));
|
||||
service->ProcessCheckResult(MakeCheckResult(ServiceOK), new StoppableWaitGroup());
|
||||
Utility::IncrementTime(timeStepInterval);
|
||||
|
||||
BOOST_CHECK(service->IsFlapping() == false);
|
||||
@ -894,7 +894,7 @@ BOOST_AUTO_TEST_CASE(suppressed_notification)
|
||||
for (int i = 0; i < checkAttempts; i++) {
|
||||
std::cout << " ProcessCheckResult("
|
||||
<< Service::StateToString(initialState) << ")" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(initialState));
|
||||
service->ProcessCheckResult(MakeCheckResult(initialState), new StoppableWaitGroup());
|
||||
}
|
||||
|
||||
BOOST_CHECK(service->GetState() == initialState);
|
||||
@ -972,7 +972,7 @@ BOOST_AUTO_TEST_CASE(suppressed_notification)
|
||||
// Process check results for the state sequence.
|
||||
for (ServiceState s : sequence) {
|
||||
std::cout << " ProcessCheckResult(" << Service::StateToString(s) << ")" << std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(s));
|
||||
service->ProcessCheckResult(MakeCheckResult(s), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == s);
|
||||
if (checkAttempts == 1) {
|
||||
BOOST_CHECK(service->GetStateType() == StateTypeHard);
|
||||
@ -1002,7 +1002,7 @@ BOOST_AUTO_TEST_CASE(suppressed_notification)
|
||||
for (int i = 0; i < checkAttempts && service->GetStateType() == StateTypeSoft; i++) {
|
||||
std::cout << " ProcessCheckResult(" << Service::StateToString(sequence.back()) << ")"
|
||||
<< std::endl;
|
||||
service->ProcessCheckResult(MakeCheckResult(sequence.back()));
|
||||
service->ProcessCheckResult(MakeCheckResult(sequence.back()), new StoppableWaitGroup());
|
||||
BOOST_CHECK(service->GetState() == sequence.back());
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ String LivestatusQueryHelper(const std::vector<String>& lines)
|
||||
std::stringstream stream;
|
||||
StdioStream::Ptr sstream = new StdioStream(&stream, false);
|
||||
|
||||
query->Execute(sstream);
|
||||
query->Execute(new StoppableWaitGroup(), sstream);
|
||||
|
||||
String output;
|
||||
String result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user