Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

fix: profiles are now loaded from file every time #164

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions splunk_connect_for_snmp_poller/manager/poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __check_inventory(self):
def delete_all_entries_per_host(self, host):
for entry_key in list(self._jobs_map.keys()):
if entry_key.split("#")[0] == host:
logger.debug("Removing job for %s", entry_key)
schedule.cancel_job(self._jobs_map.get(entry_key))
del self._jobs_map[entry_key]

Expand Down Expand Up @@ -229,7 +230,7 @@ def __start_realtime_scheduler_task(self):

schedule.every(self._args.matching_task_frequency).seconds.do(
self.process_unmatched_devices_job,
self._server_config,
self._args.config,
)

automatic_realtime_job(
Expand All @@ -253,15 +254,16 @@ def add_device_for_profile_matching(self, device: InventoryRecord):
self._unmatched_devices[device.host] = device
self._lock.release()

def process_unmatched_devices_job(self, server_config):
def process_unmatched_devices_job(self, config_location):
job_thread = threading.Thread(
target=self.process_unmatched_devices, args=[server_config]
target=self.process_unmatched_devices, args=[config_location]
)
job_thread.start()

def process_unmatched_devices(self, server_config):
def process_unmatched_devices(self, config_location):
if self._unmatched_devices:
try:
server_config = parse_config_file(config_location)
profiles = get_profiles(server_config)
self._lock.acquire()
processed_devices = set()
Expand Down