mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
smarter sleeping to try and lighten cpu load
This commit is contained in:
@@ -240,7 +240,8 @@ def poll_worker(thread_id):
|
||||
while True:
|
||||
dev_row = db.query(dev_query)
|
||||
if len(dev_row) < 1:
|
||||
#log.warning("WARNING: Thread {0} returned no devices from query".format(thread_id))
|
||||
# Sleep 1 second after getting an empty query, don't hammer the sql server for no reason.
|
||||
time.sleep(1)
|
||||
continue
|
||||
|
||||
device_id, status, next_poll, next_discovery = dev_row[0]
|
||||
@@ -296,7 +297,8 @@ for i in range(0, amount_of_workers):
|
||||
|
||||
|
||||
while True:
|
||||
if next_update < datetime.now():
|
||||
sleep_until(next_update)
|
||||
|
||||
seconds_taken = (datetime.now() - (next_update - timedelta(minutes=1))).seconds
|
||||
update_query = ('INSERT INTO pollers(poller_name, '
|
||||
' last_polled, '
|
||||
|
||||
Reference in New Issue
Block a user