If any of the consul agents such as manage, tenant, or warehouse are not set.

This exception is raised:
Exception when host-monitored by console: Object 'NoneType' has no attribute 'get_health': AttributeError: Object 'NoneType' has no attribute 'get_health'.

Now to handle this exception, we just need to check the condition whether the name exists in 'agents.name'.

Change-Id: I00ca3271f52eb4de770dbd719a57b2d15c138833
This commit is contained in:
Hamid Lotfi
2025-01-07 12:35:27 +00:00
committed by hamid lotfi
parent 8bc76b34c3
commit 1f62741b17
2 changed files with 24 additions and 10 deletions

View File

@@ -0,0 +1,12 @@
.. _monitors-config:
---------------------------------------
Masakari Monitors Configuration Options
---------------------------------------
The following is an overview of all available configuration options in
masakari-monitors.
To see sample configuration file, see :ref:`monitors-config-file`.
.. _show-options::
:config-file: etc/masakarimonitors/masakarimonitors-config-generator.conf

View File

@@ -71,21 +71,23 @@ class ConsulManager(object):
hosts_health = {}
all_agents = []
for name in sequence:
consul_agent = self.agents.get(name)
agent_health = consul_agent.get_health()
hosts_health[name] = agent_health
if not all_agents:
all_agents = agent_health.keys()
if name in self.agents:
consul_agent = self.agents.get(name)
agent_health = consul_agent.get_health()
hosts_health[name] = agent_health
if not all_agents:
all_agents = agent_health.keys()
sequence_hosts_health = {}
for host in all_agents:
sequence_hosts_health[host] = []
for name in sequence:
state = hosts_health[name].get(host)
if state:
sequence_hosts_health[host].append(state)
else:
continue
if name in self.agents:
state = hosts_health[name].get(host)
if state:
sequence_hosts_health[host].append(state)
else:
continue
return sequence_hosts_health