From 1c2c932f531db1b7ccd340bcc987b84154e12a76 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Fri, 9 Nov 2012 09:44:01 -0500 Subject: [PATCH] Add statistics polling interval option. New --stats-poll option to specify statistics polling interval in seconds. Update documentation for the new option. Change-Id: I57deafec96bd2543217a45d3f52e8ffd46d208b0 --- doc/config.rst | 6 +++++- etc/sample_libra.cfg | 1 + libra/worker/main.py | 6 +++++- libra/worker/stats_client.py | 13 ++++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/config.rst b/doc/config.rst index 7d0c7b71..df1e1d57 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -144,6 +144,10 @@ Worker Command Line Options Enable verbose output. Normally, only errors are logged. This enables additional logging, but not as much as the :option:`-d` option. + .. option:: --stats-poll + + The number of seconds to sleep between statistics polling of the + load balancer driver. Default is 300 seconds. Pool Manager Command Line Options --------------------------------- @@ -248,4 +252,4 @@ Pool Manager Command Line Options Enable verbose output. Normally, only errors are logged. This enables additional logging, but not as much as the :option:`-d` option. - + diff --git a/etc/sample_libra.cfg b/etc/sample_libra.cfg index ccddfb26..2df4c89e 100644 --- a/etc/sample_libra.cfg +++ b/etc/sample_libra.cfg @@ -28,6 +28,7 @@ user = haproxy group = haproxy driver = haproxy reconnect_sleep = 60 +stats_poll = 300 server = 10.0.0.1:8080 10.0.0.2:8080 pid = /var/run/libra/libra_worker.pid logfile = /var/log/libra/libra_worker.log diff --git a/libra/worker/main.py b/libra/worker/main.py index 6e40daba..a5eafc13 100644 --- a/libra/worker/main.py +++ b/libra/worker/main.py @@ -81,6 +81,10 @@ def main(): choices=haproxy_services.keys(), default='ubuntu', help='os services to use with HAProxy driver (when used)' ) + options.parser.add_argument( + '--stats-poll', dest='stats_poll', type=int, metavar='TIME', + default=300, help='statistics polling interval in seconds' + ) args = options.run() logger = setup_logging('libra_worker', args) @@ -115,7 +119,7 @@ def main(): # Tasks to execute in parallel task_list = [ (config_manager, (logger, driver, args.server, args.reconnect_sleep)), - (stats_manager, (logger, driver)) + (stats_manager, (logger, driver, args.stats_poll)) ] if args.nodaemon: diff --git a/libra/worker/stats_client.py b/libra/worker/stats_client.py index 5816fff2..c3331533 100644 --- a/libra/worker/stats_client.py +++ b/libra/worker/stats_client.py @@ -15,16 +15,19 @@ import eventlet -def stats_manager(logger, driver): - logger.debug("Statistics gathering process started.") +def stats_manager(logger, driver, stats_poll): + logger.debug("[stats] Statistics gathering process started.") + logger.debug("[stats] Polling interval: %d" % stats_poll) while True: try: driver.get_stats() except NotImplementedError: - logger.warn("Driver does not implement statisics gathering.") + logger.warn( + "[stats] Driver does not implement statisics gathering." + ) break - eventlet.sleep(60) + eventlet.sleep(stats_poll) - logger.info("Statistics gathering process terminated.") + logger.info("[stats] Statistics gathering process terminated.")