Added two command line options to bin/swift-log-stats-collector

This commit is contained in:
Greg Lange 2011-03-30 20:32:11 +00:00
parent 955e6fa81d
commit 0959eeb72a
2 changed files with 14 additions and 1 deletions

View File

@ -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] <conf_file>')
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,

View File

@ -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: