Skip to content

Commit

Permalink
Support hosts with mixed record_ids (#26)
Browse files Browse the repository at this point in the history
This PR adds a workaround for the issue that different hosts use different record_ids for the same entities. In particular, it adds a new config boolean option disable_record_ids. This settings allows to disable the usage of record_ids, allowing the mixed setups with a trade-off to performance.
  • Loading branch information
drotscher authored Feb 22, 2024
1 parent 33b607b commit d865359
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions metricq_source_ipmi/source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ async def try_fix_hosts(conf, hosts_to_fix):
for metric_sufix, metric_data in conf['metrics'].items():
for sensor in metric_data['sensors']:
try:
conf['record_ids'].add(
data[sensor][host]['record_id'],
)
if conf['record_ids'] is not None:
conf['record_ids'].add(
data[sensor][host]['record_id'],
)
except KeyError:
conf['hosts'][host]['next_try'] = now + \
RETRY_INTERVALS[
Expand Down Expand Up @@ -302,7 +303,7 @@ async def create_conf_and_metrics(conf_part, default_interval):
interval = conf_part.get('interval', default_interval)
new_conf = {
'metrics': {},
'record_ids': set(),
'record_ids': None if conf_part.get('disable_record_ids', False) else set(),
'hosts': {},
# 'active_hosts' serves for performance.
# That not always an additional loop has to be made to check who is active.
Expand Down Expand Up @@ -364,9 +365,10 @@ async def create_conf_and_metrics(conf_part, default_interval):
for host, host_name in zip(hosts, host_names):
for sensor in new_conf['metrics'][metric_sufix]['sensors']:
try:
new_conf['record_ids'].add(
queried_sensor_data[sensor][host]['record_id'],
)
if new_conf['record_ids'] is not None:
new_conf['record_ids'].add(
queried_sensor_data[sensor][host]['record_id'],
)
except KeyError:
new_conf['hosts'][host]['status'] = Status.ERROR
if host in new_conf['active_hosts']:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
version="0.1",
author="TU Dresden",
python_requires=">=3.10",
packages=["metricq_source_ipmi.source", "metricq_source_ipmi.plugin_hyc_tenant"],
packages=["metricq_source_ipmi.source", "metricq_source_ipmi.plugin_hyc_tenant", "metricq_source_ipmi.plugin_power_supply"],
scripts=[],
entry_points="""
[console_scripts]
Expand Down

0 comments on commit d865359

Please sign in to comment.