From 0959eeb72ad068e18d74f0346574a81e38b2157d Mon Sep 17 00:00:00 2001 From: Greg Lange Date: Wed, 30 Mar 2011 20:32:11 +0000 Subject: [PATCH] Added two command line options to bin/swift-log-stats-collector --- bin/swift-log-stats-collector | 11 ++++++++++- swift/stats/log_processor.py | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/swift-log-stats-collector b/bin/swift-log-stats-collector index b1ec382570..f2d5011ec2 100755 --- a/bin/swift-log-stats-collector +++ b/bin/swift-log-stats-collector @@ -14,12 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +from optparse import OptionParser + from swift.stats.log_processor import LogProcessorDaemon from swift.common.utils import parse_options from swift.common.daemon import run_daemon if __name__ == '__main__': - conf_file, options = parse_options() + parser = OptionParser(usage='Usage: %prog [options] ') + + parser.add_option('--lookback_hours', type='int', dest='lookback_hours', + help='Hours in the past to start looking for log files') + parser.add_option('--lookback_window', type='int', dest='lookback_window', + help='Hours past lookback_hours to stop looking for log files') + + conf_file, options = parse_options(parser) # currently the LogProcessorDaemon only supports run_once options['once'] = True run_daemon(LogProcessorDaemon, conf_file, section_name=None, diff --git a/swift/stats/log_processor.py b/swift/stats/log_processor.py index f2d5bc124a..14a242526f 100644 --- a/swift/stats/log_processor.py +++ b/swift/stats/log_processor.py @@ -236,6 +236,10 @@ class LogProcessorDaemon(Daemon): self.worker_count = int(c.get('worker_count', '1')) def run_once(self, *args, **kwargs): + for k in 'lookback_hours lookback_window'.split(): + if kwargs[k] != None: + setattr(self, k, kwargs[k]) + self.logger.info(_("Beginning log processing")) start = time.time() if self.lookback_hours == 0: