Skip to content

Commit

Permalink
Merge pull request #696 from savoirfairelinux/BR_ack
Browse files Browse the repository at this point in the history
Fix #685 : BP Rules: Consider downtime/acknowledged host/service as OK
  • Loading branch information
mohierf authored Jan 18, 2017
2 parents 7d7f097 + f8fe7db commit 7b59276
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 29 deletions.
21 changes: 17 additions & 4 deletions alignak/dependencynode.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ def get_state(self, hosts, services):
# hard state
if self.operand == 'host':
host = hosts[self.sons[0]]
return self.get_host_node_state(host.last_hard_state_id)
return self.get_host_node_state(host.last_hard_state_id,
host.problem_has_been_acknowledged,
host.in_scheduled_downtime)
elif self.operand == 'service':
service = services[self.sons[0]]
return self.get_service_node_state(service.last_hard_state_id)
return self.get_service_node_state(service.last_hard_state_id,
service.problem_has_been_acknowledged,
service.in_scheduled_downtime)
elif self.operand == '|':
return self.get_complex_or_node_state(hosts, services)
elif self.operand == '&':
Expand All @@ -162,7 +166,7 @@ def get_state(self, hosts, services):
else:
return 4 # We have an unknown node. Code is not reachable because we validate operands

def get_host_node_state(self, state):
def get_host_node_state(self, state, problem_has_been_acknowledged, in_scheduled_downtime):
"""Get host node state, simplest case ::
* Handle not value (revert) for host and consider 1 as 2
Expand All @@ -173,19 +177,28 @@ def get_host_node_state(self, state):
# Make DOWN look as CRITICAL (2 instead of 1)
if state == 1:
state = 2

# If our node is acknowledged or in downtime, state is ok/up
if problem_has_been_acknowledged or in_scheduled_downtime:
state = 0

# Maybe we are a NOT node, so manage this
if self.not_value:
return 0 if state else 2 # Keep the logic of return Down on NOT rules
return state

def get_service_node_state(self, state):
def get_service_node_state(self, state, problem_has_been_acknowledged, in_scheduled_downtime):
"""Get service node state, simplest case ::
* Handle not value (revert) for service
:return: 0, 1 or 2
:rtype: int
"""
# If our node is acknowledged or in downtime, state is ok/up
if problem_has_been_acknowledged or in_scheduled_downtime:
state = 0

# Maybe we are a NOT node, so manage this
if self.not_value:
# Critical -> OK
Expand Down
Loading

0 comments on commit 7b59276

Please sign in to comment.