From fc72d0309b95f360efda1edcab2acee8671cfe2f Mon Sep 17 00:00:00 2001 From: John Dickinson Date: Mon, 18 Oct 2010 17:10:26 -0500 Subject: [PATCH] changed auditor once mode --- swift/account/auditor.py | 27 +++++++++++++++------------ swift/container/auditor.py | 27 +++++++++++++++------------ swift/obj/auditor.py | 27 +++++++++++++++------------ 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/swift/account/auditor.py b/swift/account/auditor.py index 6d0b2236ea..b92dd9ca44 100644 --- a/swift/account/auditor.py +++ b/swift/account/auditor.py @@ -65,18 +65,21 @@ class AccountAuditor(Daemon): """Run the account audit once.""" self.logger.info('Begin account audit "once" mode') begin = time.time() - try: - location = '' - gen = audit_location_generator(self.devices, - account_server.DATADIR, - mount_check=self.mount_check, - logger=self.logger) - while not location.endswith('.db'): - location, device, partition = gen.next() - except StopIteration: - self.logger.info('Nothing to audit') - else: - self.account_audit(location) + all_locs = audit_location_generator(self.devices, + account_server.DATADIR, + mount_check=self.mount_check, + logger=self.logger) + for path, device, partition in all_locs: + self.account_audit(path) + if time.time() - reported >= 3600: # once an hour + self.logger.info( + 'Since %s: Account audits: %s passed audit, ' + '%s failed audit' % (time.ctime(reported), + self.account_passes, + self.account_failures)) + reported = time.time() + self.account_passes = 0 + self.account_failures = 0 elapsed = time.time() - begin self.logger.info( 'Account audit "once" mode completed: %.02fs' % elapsed) diff --git a/swift/container/auditor.py b/swift/container/auditor.py index 3972feafd6..88b3b033f3 100644 --- a/swift/container/auditor.py +++ b/swift/container/auditor.py @@ -66,18 +66,21 @@ class ContainerAuditor(Daemon): """Run the container audit once.""" self.logger.info('Begin container audit "once" mode') begin = time.time() - try: - location = '' - gen = audit_location_generator(self.devices, - container_server.DATADIR, - mount_check=self.mount_check, - logger=self.logger) - while not location.endswith('.db'): - location, device, partition = gen.next() - except StopIteration: - self.logger.info('Nothing to audit') - else: - self.container_audit(location) + all_locs = audit_location_generator(self.devices, + container_server.DATADIR, + mount_check=self.mount_check, + logger=self.logger) + for path, device, partition in all_locs: + self.container_audit(path) + if time.time() - reported >= 3600: # once an hour + self.logger.info( + 'Since %s: Container audits: %s passed audit, ' + '%s failed audit' % (time.ctime(reported), + self.container_passes, + self.container_failures)) + reported = time.time() + self.container_passes = 0 + self.container_failures = 0 elapsed = time.time() - begin self.logger.info( 'Container audit "once" mode completed: %.02fs' % elapsed) diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py index 42ea671d6c..1d9d8e4cc3 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -68,18 +68,21 @@ class ObjectAuditor(Daemon): """Run the object audit once.""" self.logger.info('Begin object audit "once" mode') begin = time.time() - try: - location = '' - gen = audit_location_generator(self.devices, - object_server.DATADIR, - mount_check=self.mount_check, - logger=self.logger) - while not location.endswith('.data'): - location, device, partition = gen.next() - except StopIteration: - self.logger.info('Nothing to audit') - else: - self.object_audit(location, device, partition) + all_locs = audit_location_generator(self.devices, + object_server.DATADIR, + mount_check=self.mount_check, + logger=self.logger) + for path, device, partition in all_locs: + self.object_audit(path, device, partition) + if time.time() - reported >= 3600: # once an hour + self.logger.info( + 'Since %s: Locally: %d passed audit, %d quarantined, ' + '%d errors' % (time.ctime(reported), self.passes, + self.quarantines, self.errors)) + reported = time.time() + self.passes = 0 + self.quarantines = 0 + self.errors = 0 elapsed = time.time() - begin self.logger.info( 'Object audit "once" mode completed: %.02fs' % elapsed)