Fix bugs if plugins fail to load
This commit is contained in:
parent
71139fa66d
commit
b07396c39a
|
@ -52,9 +52,15 @@ def getNodeInformation(zkhandler, node_name):
|
|||
node_running_domains = zkhandler.read(("node.running_domains", node_name)).split()
|
||||
try:
|
||||
node_health = int(zkhandler.read(("node.monitoring.health", node_name)))
|
||||
except ValueError:
|
||||
except Exception:
|
||||
node_health = "N/A"
|
||||
node_health_plugins = zkhandler.read(("node.monitoring.plugins", node_name)).split()
|
||||
try:
|
||||
node_health_plugins = zkhandler.read(
|
||||
("node.monitoring.plugins", node_name)
|
||||
).split()
|
||||
except Exception:
|
||||
node_health_plugins = list()
|
||||
|
||||
node_health_details = list()
|
||||
for plugin in node_health_plugins:
|
||||
plugin_last_run = zkhandler.read(
|
||||
|
|
|
@ -190,6 +190,8 @@ class MonitoringInstance(object):
|
|||
self.all_plugins = list()
|
||||
self.all_plugin_names = list()
|
||||
|
||||
successful_plugins = 0
|
||||
|
||||
# Load each plugin file into the all_plugins list
|
||||
for plugin_file in sorted(plugin_files):
|
||||
try:
|
||||
|
@ -211,8 +213,6 @@ class MonitoringInstance(object):
|
|||
self.this_node,
|
||||
plugin_script.PLUGIN_NAME,
|
||||
)
|
||||
self.all_plugins.append(plugin)
|
||||
self.all_plugin_names.append(plugin.plugin_name)
|
||||
|
||||
# Create plugin key
|
||||
self.zkhandler.write(
|
||||
|
@ -273,6 +273,11 @@ class MonitoringInstance(object):
|
|||
),
|
||||
]
|
||||
)
|
||||
|
||||
self.all_plugins.append(plugin)
|
||||
self.all_plugin_names.append(plugin.plugin_name)
|
||||
successful_plugins += 1
|
||||
|
||||
self.logger.out(
|
||||
f"Successfully loaded monitoring plugin '{plugin.plugin_name}'",
|
||||
state="o",
|
||||
|
@ -292,6 +297,9 @@ class MonitoringInstance(object):
|
|||
]
|
||||
)
|
||||
|
||||
if successful_plugins < 1:
|
||||
return
|
||||
|
||||
# Clean up any old plugin data for which a plugin file no longer exists
|
||||
for plugin_key in self.zkhandler.children(
|
||||
("node.monitoring.data", self.this_node.name)
|
||||
|
|
Loading…
Reference in New Issue