diff --git a/doc/3-monitoring-basics.md b/doc/3-monitoring-basics.md index 5ee3107cd..0306790e1 100644 --- a/doc/3-monitoring-basics.md +++ b/doc/3-monitoring-basics.md @@ -1418,6 +1418,9 @@ You can control that option by defining the `disable_notifications` attribute. disable_notifications = false +If the dependency should be triggered in the parent object's soft state, you +need to set `ignore_soft_states` to `false`. + The dependency state filter must be defined based on the parent object being either a host (`Up`, `Down`) or a service (`OK`, `Warning`, `Critical`, `Unknown`). diff --git a/doc/6-object-types.md b/doc/6-object-types.md index 37e1872cc..bf2e2d141 100644 --- a/doc/6-object-types.md +++ b/doc/6-object-types.md @@ -686,6 +686,7 @@ Configuration Attributes: child_service_name |**Optional.** The child service. If omitted this dependency object is treated as host dependency. disable_checks |**Optional.** Whether to disable checks when this dependency fails. Defaults to false. disable_notifications |**Optional.** Whether to disable notifications when this dependency fails. Defaults to true. + ignore_soft_states |**Optional.** Whether to ignore soft states for the reachability calculation. Defaults to true. period |**Optional.** Time period during which this dependency is enabled. zone |**Optional.** The zone this object is a member of. states |**Optional.** A list of state filters when this dependency should be OK. Defaults to [ OK, Warning ] for services and [ Up ] for hosts. diff --git a/lib/icinga/dependency.cpp b/lib/icinga/dependency.cpp index 42ed41b2d..59aa76d5b 100644 --- a/lib/icinga/dependency.cpp +++ b/lib/icinga/dependency.cpp @@ -131,11 +131,16 @@ bool Dependency::IsAvailable(DependencyType dt) const return true; } - /* ignore soft states */ - if (parent->GetStateType() == StateTypeSoft) { + if (GetIgnoreSoftStates()) { + /* ignore soft states */ + if (parent->GetStateType() == StateTypeSoft) { + Log(LogNotice, "Dependency") + << "Dependency '" << GetName() << "' passed: " << (service ? "Service" : "Host") << " '" << parent->GetName() << "' is in a soft state."; + return true; + } + } else { Log(LogNotice, "Dependency") - << "Dependency '" << GetName() << "' passed: " << (service ? "Service" : "Host") << " '" << parent->GetName() << "' is in a soft state."; - return true; + << "Dependency '" << GetName() << "' failed: " << (service ? "Service" : "Host") << " '" << parent->GetName() << "' is in a soft state."; } int state; diff --git a/lib/icinga/dependency.ti b/lib/icinga/dependency.ti index 062f54b3d..244877c34 100644 --- a/lib/icinga/dependency.ti +++ b/lib/icinga/dependency.ti @@ -44,6 +44,10 @@ class Dependency : CustomVarObject < DependencyNameComposer [config] Array::Ptr states; int state_filter_real (StateFilter); + [config] bool ignore_soft_states { + default {{{ return true; }}} + }; + [config] bool disable_checks; [config] bool disable_notifications { default {{{ return true; }}}