mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
identify thread numbers
This commit is contained in:
@@ -233,7 +233,7 @@ next_update = datetime.now() + timedelta(minutes=1)
|
||||
devices_scanned = 0
|
||||
|
||||
|
||||
def poll_worker():
|
||||
def poll_worker(thread_id):
|
||||
global dev_query
|
||||
global devices_scanned
|
||||
db = DB()
|
||||
@@ -244,14 +244,14 @@ def poll_worker():
|
||||
continue
|
||||
|
||||
if next_poll and next_poll > datetime.now():
|
||||
log.debug('DEBUG: Sleeping until {0} before polling {1}'.format(next_poll, device_id))
|
||||
log.debug('DEBUG: Thread {0} Sleeping until {1} before polling {2}'.format(thread_id, next_poll, device_id))
|
||||
sleep_until(next_poll)
|
||||
|
||||
action = 'poll'
|
||||
if (not next_discovery or next_discovery < datetime.now()) and status == 1:
|
||||
action = 'discovery'
|
||||
|
||||
log.debug('DEBUG: Starting {0} of device {1}'.format(action, device_id))
|
||||
log.debug('DEBUG: Thread {0} Starting {1} of device {2}'.format(thread_id, action, device_id))
|
||||
devices_scanned += 1
|
||||
|
||||
db.query('UPDATE devices SET last_poll_attempted = NOW() WHERE device_id = {0}'.format(device_id))
|
||||
@@ -270,9 +270,9 @@ def poll_worker():
|
||||
subprocess.check_call(command, shell=True)
|
||||
elapsed_time = int(time.time() - start_time)
|
||||
if elapsed_time < 300:
|
||||
log.debug("DEBUG: worker finished %s of device %s in %s seconds" % (action, device_id, elapsed_time))
|
||||
log.debug("DEBUG: Thread {0} finished {1} of device {2} in {3} seconds".format(thread_id, action, device_id, elapsed_time))
|
||||
else:
|
||||
log.warning("WARNING: worker finished %s of device %s in %s seconds" % (action, device_id, elapsed_time))
|
||||
log.warning("WARNING: Thread {0} finished {1} of device {2} in {3} seconds".format(thread_id, action, device_id, elapsed_time))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
@@ -283,7 +283,7 @@ def poll_worker():
|
||||
|
||||
t = []
|
||||
for i in range(0, amount_of_workers):
|
||||
t.append(threading.Thread(target=poll_worker))
|
||||
t.append(threading.Thread(target=poll_worker, args=[i]))
|
||||
t[i].start()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user