log progress to db every 5 minutes

This commit is contained in:
Clint Armstrong
2015-08-25 11:35:18 -04:00
parent 0588ff41c3
commit c65a160c18
+9
View File
@@ -217,6 +217,15 @@ while True:
log.debug('DEBUG: {} threads currently active'.format(threads))
if next_update < datetime.now():
seconds_taken = (datetime.now() - (next_update - timedelta(minutes=5))).seconds
update_query = ("insert into pollers set "
"poller_name='%s', "
"last_polled=NOW(), "
"devices='%d', "
"time_taken='%d' ").format(config['distributed_poller_name'],
devices_scanned,
seconds_taken)
cursor.execute(update_query)
log.info('INFO: {} devices scanned in the last 5 minutes'.format(devices_scanned))
devices_scanned = 0
next_update = datetime.now() + timedelta(minutes=5)