mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-31 01:24:19 +02:00
Merge pull request #8267 from efuss/passive_reach
Drop passive check results for unreachable hosts/services
This commit is contained in:
commit
ef23ae5f3c
@ -200,7 +200,7 @@ Configuration Attributes:
|
|||||||
parent\_service\_name | Object name | **Optional.** The parent service. If omitted, this dependency object is treated as host dependency.
|
parent\_service\_name | Object name | **Optional.** The parent service. If omitted, this dependency object is treated as host dependency.
|
||||||
child\_host\_name | Object name | **Required.** The child host.
|
child\_host\_name | Object name | **Required.** The child host.
|
||||||
child\_service\_name | Object name | **Optional.** The child service. If omitted, this dependency object is treated as host dependency.
|
child\_service\_name | Object name | **Optional.** The child service. If omitted, this dependency object is treated as host dependency.
|
||||||
disable\_checks | Boolean | **Optional.** Whether to disable checks when this dependency fails. Defaults to false.
|
disable\_checks | Boolean | **Optional.** Whether to disable checks (i.e., don't schedule active checks and drop passive results) when this dependency fails. Defaults to false.
|
||||||
disable\_notifications | Boolean | **Optional.** Whether to disable notifications when this dependency fails. Defaults to true.
|
disable\_notifications | Boolean | **Optional.** Whether to disable notifications when this dependency fails. Defaults to true.
|
||||||
ignore\_soft\_states | Boolean | **Optional.** Whether to ignore soft states for the reachability calculation. Defaults to true.
|
ignore\_soft\_states | Boolean | **Optional.** Whether to ignore soft states for the reachability calculation. Defaults to true.
|
||||||
period | Object name | **Optional.** Time period object during which this dependency is enabled.
|
period | Object name | **Optional.** Time period object during which this dependency is enabled.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
||||||
|
|
||||||
#include "icinga/apiactions.hpp"
|
#include "icinga/apiactions.hpp"
|
||||||
|
#include "icinga/checkable.hpp"
|
||||||
#include "icinga/service.hpp"
|
#include "icinga/service.hpp"
|
||||||
#include "icinga/servicegroup.hpp"
|
#include "icinga/servicegroup.hpp"
|
||||||
#include "icinga/hostgroup.hpp"
|
#include "icinga/hostgroup.hpp"
|
||||||
@ -63,6 +64,9 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
|
|||||||
if (!checkable->GetEnablePassiveChecks())
|
if (!checkable->GetEnablePassiveChecks())
|
||||||
return ApiActions::CreateResult(403, "Passive checks are disabled for object '" + checkable->GetName() + "'.");
|
return ApiActions::CreateResult(403, "Passive checks are disabled for object '" + checkable->GetName() + "'.");
|
||||||
|
|
||||||
|
if (!checkable->IsReachable(DependencyCheckExecution))
|
||||||
|
return ApiActions::CreateResult(200, "Ignoring passive check result for unreachable object '" + checkable->GetName() + "'.");
|
||||||
|
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
||||||
|
|
||||||
#include "icinga/externalcommandprocessor.hpp"
|
#include "icinga/externalcommandprocessor.hpp"
|
||||||
|
#include "icinga/checkable.hpp"
|
||||||
#include "icinga/host.hpp"
|
#include "icinga/host.hpp"
|
||||||
#include "icinga/service.hpp"
|
#include "icinga/service.hpp"
|
||||||
#include "icinga/user.hpp"
|
#include "icinga/user.hpp"
|
||||||
@ -283,6 +284,12 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
|
|||||||
if (!host->GetEnablePassiveChecks())
|
if (!host->GetEnablePassiveChecks())
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
|
||||||
|
|
||||||
|
if (!host->IsReachable(DependencyCheckExecution)) {
|
||||||
|
Log(LogNotice, "ExternalCommandProcessor")
|
||||||
|
<< "Ignoring passive check result for unreachable host '" << arguments[0] << "'";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int exitStatus = Convert::ToDouble(arguments[1]);
|
int exitStatus = Convert::ToDouble(arguments[1]);
|
||||||
CheckResult::Ptr result = new CheckResult();
|
CheckResult::Ptr result = new CheckResult();
|
||||||
std::pair<String, String> co = PluginUtility::ParseCheckOutput(arguments[2]);
|
std::pair<String, String> co = PluginUtility::ParseCheckOutput(arguments[2]);
|
||||||
@ -324,6 +331,12 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
|
|||||||
if (!service->GetEnablePassiveChecks())
|
if (!service->GetEnablePassiveChecks())
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
|
||||||
|
|
||||||
|
if (!service->IsReachable(DependencyCheckExecution)) {
|
||||||
|
Log(LogNotice, "ExternalCommandProcessor")
|
||||||
|
<< "Ignoring passive check result for unreachable service '" << arguments[1] << "'";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int exitStatus = Convert::ToDouble(arguments[2]);
|
int exitStatus = Convert::ToDouble(arguments[2]);
|
||||||
CheckResult::Ptr result = new CheckResult();
|
CheckResult::Ptr result = new CheckResult();
|
||||||
String output = CompatUtility::UnEscapeString(arguments[3]);
|
String output = CompatUtility::UnEscapeString(arguments[3]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user