Skip to content

Commit 61bb14b

Browse files
author
Anze
committed
Set job ids (use entity id as job identifier) when adding jobs
1 parent 4d27b27 commit 61bb14b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

collector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def __init__(self, backend_url, bot_token):
165165
@abstractmethod
166166
def jobs(self):
167167
"""
168-
Returns a list of (intervals, job_func, job_data) tuples. Usually calls
168+
Returns a list of (job_id, intervals, job_func, job_data) tuples. Usually calls
169169
`fetch_job_configs` to get input data.
170170
"""
171171

@@ -260,9 +260,9 @@ def execute(self):
260260
executor = IntervalsAwareProcessPoolExecutor(10)
261261
scheduler.add_executor(executor, 'iaexecutor')
262262

263-
for intervals, job_func, job_data in self.jobs():
263+
for job_id, intervals, job_func, job_data in self.jobs():
264264
trigger = MultipleIntervalsTrigger(intervals)
265-
scheduler.add_job(job_func, trigger=trigger, executor='iaexecutor', kwargs=job_data)
265+
scheduler.add_job(job_func, id=job_id, trigger=trigger, executor='iaexecutor', kwargs=job_data)
266266

267267
try:
268268
scheduler.start()

snmpcollector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ def jobs(self):
198198
for entity_info in self.fetch_job_configs('snmp'):
199199
intervals = list(set([sensor_info["interval"] for sensor_info in entity_info["sensors"]]))
200200
job_info = { **entity_info, "backend_url": self.backend_url, "bot_token": self.bot_token }
201-
yield intervals, SNMPCollector.do_snmp, job_info
201+
job_id = str(entity_info["entity_id"])
202+
yield job_id, intervals, SNMPCollector.do_snmp, job_info
202203

203204

204205
if __name__ == "__main__":

0 commit comments

Comments
 (0)