Ejemplo n.º 1
0
 def run_forever(self, *args, **kwargs):
     """Run the container audit until stopped."""
     reported = time.time()
     time.sleep(random() * self.interval)
     while True:
         begin = time.time()
         try:
             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 %(time)s: Container audits: %(pass)s '
                           'passed audit, %(fail)s failed audit'),
                         {'time': time.ctime(reported),
                          'pass': self.container_passes,
                          'fail': self.container_failures})
                     reported = time.time()
                     self.container_passes = 0
                     self.container_failures = 0
         except (Exception, Timeout):
             self.logger.exception(_('ERROR auditing'))
         elapsed = time.time() - begin
         if elapsed < self.interval:
             time.sleep(self.interval - elapsed)
Ejemplo n.º 2
0
 def run_forever(self, *args, **kwargs):
     """Run the container audit until stopped."""
     reported = time.time()
     time.sleep(random() * self.interval)
     while True:
         begin = time.time()
         try:
             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 %(time)s: Container audits: %(pass)s '
                           'passed audit, %(fail)s failed audit'), {
                               'time': time.ctime(reported),
                               'pass': self.container_passes,
                               'fail': self.container_failures
                           })
                     reported = time.time()
                     self.container_passes = 0
                     self.container_failures = 0
         except (Exception, Timeout):
             self.logger.exception(_('ERROR auditing'))
         elapsed = time.time() - begin
         if elapsed < self.interval:
             time.sleep(self.interval - elapsed)
Ejemplo n.º 3
0
 def audit_all_objects(self, mode='once'):
     self.logger.info(_('Begin object audit "%s" mode (%s)' %
                        (mode, self.auditor_type)))
     begin = reported = time.time()
     self.total_bytes_processed = 0
     self.total_files_processed = 0
     total_quarantines = 0
     total_errors = 0
     files_running_time = 0
     time_auditing = 0
     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:
         loop_time = time.time()
         self.object_audit(path, device, partition)
         self.files_running_time = ratelimit_sleep(
             self.files_running_time, self.max_files_per_second)
         self.total_files_processed += 1
         now = time.time()
         if now - reported >= self.log_time:
             self.logger.info(_(
                 'Object audit (%(type)s). '
                 'Since %(start_time)s: Locally: %(passes)d passed, '
                 '%(quars)d quarantined, %(errors)d errors '
                 'files/sec: %(frate).2f , bytes/sec: %(brate).2f, '
                 'Total time: %(total).2f, Auditing time: %(audit).2f, '
                 'Rate: %(audit_rate).2f') % {
                         'type': self.auditor_type,
                         'start_time': time.ctime(reported),
                         'passes': self.passes, 'quars': self.quarantines,
                         'errors': self.errors,
                         'frate': self.passes / (now - reported),
                         'brate': self.bytes_processed / (now - reported),
                         'total': (now - begin), 'audit': time_auditing,
                         'audit_rate': time_auditing / (now - begin)})
             reported = now
             total_quarantines += self.quarantines
             total_errors += self.errors
             self.passes = 0
             self.quarantines = 0
             self.errors = 0
             self.bytes_processed = 0
         time_auditing += (now - loop_time)
     elapsed = time.time() - begin
     self.logger.info(_(
         'Object audit (%(type)s) "%(mode)s" mode '
         'completed: %(elapsed).02fs. Total quarantined: %(quars)d, '
         'Total errors: %(errors)d, Total files/sec: %(frate).2f , '
         'Total bytes/sec: %(brate).2f, Auditing time: %(audit).2f, '
         'Rate: %(audit_rate).2f') % {
             'type': self.auditor_type, 'mode': mode, 'elapsed': elapsed,
             'quars': total_quarantines, 'errors': total_errors,
             'frate': self.total_files_processed / elapsed,
             'brate': self.total_bytes_processed / elapsed,
             'audit': time_auditing, 'audit_rate': time_auditing / elapsed})
Ejemplo n.º 4
0
 def run_once(self):
     """
     Runs a single container sync scan.
     """
     self.logger.info(_('Begin container sync "once" mode'))
     begin = time()
     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_sync(path)
         if time() - self.reported >= 3600:  # once an hour
             self.report()
     self.report()
     elapsed = time() - begin
     self.logger.info(_('Container sync "once" mode completed: %.02fs'),
                      elapsed)
Ejemplo n.º 5
0
 def run_forever(self):
     """
     Runs container sync scans until stopped.
     """
     sleep(random() * self.interval)
     while True:
         begin = time()
         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_sync(path)
             if time() - self.reported >= 3600:  # once an hour
                 self.report()
         elapsed = time() - begin
         if elapsed < self.interval:
             sleep(self.interval - elapsed)
Ejemplo n.º 6
0
 def run_once(self):
     """
     Runs a single container sync scan.
     """
     self.logger.info(_('Begin container sync "once" mode'))
     begin = time()
     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_sync(path)
         if time() - self.reported >= 3600:  # once an hour
             self.report()
     self.report()
     elapsed = time() - begin
     self.logger.info(
         _('Container sync "once" mode completed: %.02fs'), elapsed)
Ejemplo n.º 7
0
 def run_forever(self):
     """
     Runs container sync scans until stopped.
     """
     sleep(random() * self.interval)
     while True:
         begin = time()
         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_sync(path)
             if time() - self.reported >= 3600:  # once an hour
                 self.report()
         elapsed = time() - begin
         if elapsed < self.interval:
             sleep(self.interval - elapsed)
Ejemplo n.º 8
0
 def run_once(self, *args, **kwargs):
     """Run the account audit once."""
     self.logger.info('Begin account audit "once" mode')
     begin = reported = time.time()
     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 %(time)s: Account audits: '
                 '%(passed)s passed audit, %(failed)s failed audit'),
                   {'time': time.ctime(reported),
                    'passed': self.account_passes,
                    'failed': 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)
Ejemplo n.º 9
0
 def run_once(self, *args, **kwargs):
     """Run the container audit once."""
     self.logger.info(_('Begin container audit "once" mode'))
     begin = reported = time.time()
     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 %(time)s: Container audits: %(pass)s passed '
                   'audit, %(fail)s failed audit'), {
                       'time': time.ctime(reported),
                       'pass': self.container_passes,
                       'fail': 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)
Ejemplo n.º 10
0
 def audit_all_objects(self, mode='once'):
     self.logger.info(
         _('Begin object audit "%s" mode (%s)' % (mode, self.auditor_type)))
     begin = reported = time.time()
     self.total_bytes_processed = 0
     self.total_files_processed = 0
     total_quarantines = 0
     total_errors = 0
     files_running_time = 0
     time_auditing = 0
     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:
         loop_time = time.time()
         self.object_audit(path, device, partition)
         self.files_running_time = ratelimit_sleep(
             self.files_running_time, self.max_files_per_second)
         self.total_files_processed += 1
         now = time.time()
         if now - reported >= self.log_time:
             self.logger.info(
                 _('Object audit (%(type)s). '
                   'Since %(start_time)s: Locally: %(passes)d passed, '
                   '%(quars)d quarantined, %(errors)d errors '
                   'files/sec: %(frate).2f , bytes/sec: %(brate).2f, '
                   'Total time: %(total).2f, Auditing time: %(audit).2f, '
                   'Rate: %(audit_rate).2f') % {
                       'type': self.auditor_type,
                       'start_time': time.ctime(reported),
                       'passes': self.passes,
                       'quars': self.quarantines,
                       'errors': self.errors,
                       'frate': self.passes / (now - reported),
                       'brate': self.bytes_processed / (now - reported),
                       'total': (now - begin),
                       'audit': time_auditing,
                       'audit_rate': time_auditing / (now - begin)
                   })
             reported = now
             total_quarantines += self.quarantines
             total_errors += self.errors
             self.passes = 0
             self.quarantines = 0
             self.errors = 0
             self.bytes_processed = 0
         time_auditing += (now - loop_time)
     elapsed = time.time() - begin
     self.logger.info(
         _('Object audit (%(type)s) "%(mode)s" mode '
           'completed: %(elapsed).02fs. Total quarantined: %(quars)d, '
           'Total errors: %(errors)d, Total files/sec: %(frate).2f , '
           'Total bytes/sec: %(brate).2f, Auditing time: %(audit).2f, '
           'Rate: %(audit_rate).2f') % {
               'type': self.auditor_type,
               'mode': mode,
               'elapsed': elapsed,
               'quars': total_quarantines,
               'errors': total_errors,
               'frate': self.total_files_processed / elapsed,
               'brate': self.total_bytes_processed / elapsed,
               'audit': time_auditing,
               'audit_rate': time_auditing / elapsed
           })