summaryrefslogtreecommitdiffstats
path: root/nfvbench/nfvbench.py
diff options
context:
space:
mode:
authorahothan <ahothan@cisco.com>2017-08-22 17:41:16 -0700
committerahothan <ahothan@cisco.com>2017-08-22 17:41:57 -0700
commit2d55474511a5057015e77547c326120c1649c0b7 (patch)
treee5f1db615655d73c9778d0499d7a312e8de2cc3e /nfvbench/nfvbench.py
parent6c4e55c53c65b7e63c17c85367b4813443c5d942 (diff)
NFVBENCH-6 Add support for sending logs to fluentd with fluentd client library
Change-Id: I1bc01b26f9e43f78c169b5fcd26247debcfe31bf Signed-off-by: ahothan <ahothan@cisco.com>
Diffstat (limited to 'nfvbench/nfvbench.py')
-rw-r--r--nfvbench/nfvbench.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py
index d3f7f02..dccd63c 100644
--- a/nfvbench/nfvbench.py
+++ b/nfvbench/nfvbench.py
@@ -26,6 +26,7 @@ import copy
import credentials
import datetime
from factory import BasicFactory
+from fluentd import FluentLogHandler
import importlib
import json
import log
@@ -42,6 +43,7 @@ import traceback
from traffic_client import TrafficGeneratorFactory
import utils
+fluent_logger = None
class NFVBench(object):
"""Main class of NFV benchmarking tool."""
@@ -78,6 +80,10 @@ class NFVBench(object):
status = NFVBench.STATUS_OK
result = None
message = ''
+ if fluent_logger:
+ # take a snapshot of the current time for this new run
+ # so that all subsequent logs can relate to this run
+ fluent_logger.start_new_run()
try:
self.update_config(opts)
self.setup()
@@ -411,6 +417,7 @@ def check_physnet(name, netattrs):
.format(n=name))
def main():
+ global fluent_logger
try:
log.setup()
# load default config file
@@ -427,6 +434,15 @@ def main():
config = config_plugin.get_config()
openstack_spec = config_plugin.get_openstack_spec()
+ # setup the fluent logger as soon as possible right after the config plugin is called
+ if config.fluentd.logging_tag:
+ fluent_logger = FluentLogHandler(config.fluentd.logging_tag,
+ fluentd_ip=config.fluentd.ip,
+ fluentd_port=config.fluentd.port)
+ LOG.addHandler(fluent_logger)
+ else:
+ fluent_logger = None
+
opts, unknown_opts = parse_opts_from_cli()
log.set_level(debug=opts.debug)