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
This commit is contained in:
David Shrewsbury 2012-11-09 09:44:01 -05:00
parent dca86f2241
commit 1c2c932f53
4 changed files with 19 additions and 7 deletions

View File

@ -144,6 +144,10 @@ Worker Command Line Options
Enable verbose output. Normally, only errors are logged. This enables Enable verbose output. Normally, only errors are logged. This enables
additional logging, but not as much as the :option:`-d` option. additional logging, but not as much as the :option:`-d` option.
.. option:: --stats-poll <SECONDS>
The number of seconds to sleep between statistics polling of the
load balancer driver. Default is 300 seconds.
Pool Manager Command Line Options Pool Manager Command Line Options
--------------------------------- ---------------------------------

View File

@ -28,6 +28,7 @@ user = haproxy
group = haproxy group = haproxy
driver = haproxy driver = haproxy
reconnect_sleep = 60 reconnect_sleep = 60
stats_poll = 300
server = 10.0.0.1:8080 10.0.0.2:8080 server = 10.0.0.1:8080 10.0.0.2:8080
pid = /var/run/libra/libra_worker.pid pid = /var/run/libra/libra_worker.pid
logfile = /var/log/libra/libra_worker.log logfile = /var/log/libra/libra_worker.log

View File

@ -81,6 +81,10 @@ def main():
choices=haproxy_services.keys(), default='ubuntu', choices=haproxy_services.keys(), default='ubuntu',
help='os services to use with HAProxy driver (when used)' 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() args = options.run()
logger = setup_logging('libra_worker', args) logger = setup_logging('libra_worker', args)
@ -115,7 +119,7 @@ def main():
# Tasks to execute in parallel # Tasks to execute in parallel
task_list = [ task_list = [
(config_manager, (logger, driver, args.server, args.reconnect_sleep)), (config_manager, (logger, driver, args.server, args.reconnect_sleep)),
(stats_manager, (logger, driver)) (stats_manager, (logger, driver, args.stats_poll))
] ]
if args.nodaemon: if args.nodaemon:

View File

@ -15,16 +15,19 @@
import eventlet import eventlet
def stats_manager(logger, driver): def stats_manager(logger, driver, stats_poll):
logger.debug("Statistics gathering process started.") logger.debug("[stats] Statistics gathering process started.")
logger.debug("[stats] Polling interval: %d" % stats_poll)
while True: while True:
try: try:
driver.get_stats() driver.get_stats()
except NotImplementedError: except NotImplementedError:
logger.warn("Driver does not implement statisics gathering.") logger.warn(
"[stats] Driver does not implement statisics gathering."
)
break break
eventlet.sleep(60) eventlet.sleep(stats_poll)
logger.info("Statistics gathering process terminated.") logger.info("[stats] Statistics gathering process terminated.")