Add 'ignore_soft_states' attribute to Dependency objects

fixes #7326
This commit is contained in:
Michael Friedrich 2015-02-08 00:30:58 +01:00 committed by Gunnar Beutner
parent 4e27ded7ce
commit aac53c1dd1
4 changed files with 17 additions and 4 deletions

View File

@ -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`).

View File

@ -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.

View File

@ -131,12 +131,17 @@ bool Dependency::IsAvailable(DependencyType dt) const
return true;
}
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() << "' failed: " << (service ? "Service" : "Host") << " '" << parent->GetName() << "' is in a soft state.";
}
int state;

View File

@ -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; }}}