Added two command line options to bin/swift-log-stats-collector
This commit is contained in:
parent
955e6fa81d
commit
0959eeb72a
@ -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,
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user