Currently, the application needs to be restarted every time the mapping files change. This can be done via external listeners that trigger restarts on mapping file changes, but that is far from ideal.
We can solve this most easily by moving the relevant lines from read_map_file from __init__() to work():
|
self.property_template_map = utils.read_map_file( |
|
os.path.join(self.zabbix_config.map_dir, "property_template_map.txt") |
|
) |
|
self.property_hostgroup_map = utils.read_map_file( |
|
os.path.join(self.zabbix_config.map_dir, "property_hostgroup_map.txt") |
|
) |
|
self.siteadmin_hostgroup_map = utils.read_map_file( |
|
os.path.join(self.zabbix_config.map_dir, "siteadmin_hostgroup_map.txt") |
|
) |
|
def work(self) -> None: |
|
start_time = time.time() |
|
logger.info("Zabbix update starting") |
|
self.do_update() |
|
logger.info( |
|
"Zabbix update finished", |
|
duration=time.time() - start_time, |
|
next_update=self.next_update.isoformat(timespec="seconds"), |
|
) |
There are other ways to solve this, but this is the easiest. It does have some downsides:
- Subclasses could override
work(), thereby losing these calls
work() could become overloaded with such bootstrapping code in the long run.
Currently, the application needs to be restarted every time the mapping files change. This can be done via external listeners that trigger restarts on mapping file changes, but that is far from ideal.
We can solve this most easily by moving the relevant lines from
read_map_filefrom__init__()towork():zabbix-auto-config/zabbix_auto_config/processing.py
Lines 756 to 764 in 9cdc478
zabbix-auto-config/zabbix_auto_config/processing.py
Lines 799 to 807 in 9cdc478
There are other ways to solve this, but this is the easiest. It does have some downsides:
work(), thereby losing these callswork()could become overloaded with such bootstrapping code in the long run.