NFVBENCH-36 Send results to fluentd on show-summary option
[nfvbench.git] / nfvbench / nfvbench.py
index 920838a..f09af90 100644 (file)
@@ -129,10 +129,13 @@ class NFVBench(object):
 
     def prepare_summary(self, result):
         """Prepares summary of the result to print and send it to logger (eg: fluentd)"""
-        sender = FluentLogHandler("resultnfvbench",
-                                  fluentd_ip=self.config.fluentd.ip,
-                                  fluentd_port=self.config.fluentd.port) \
-            if self.config.fluentd.logging_tag else None
+        global fluent_logger
+        sender = None
+        if fluent_logger:
+            sender = FluentLogHandler("resultnfvbench",
+                                      fluentd_ip=self.config.fluentd.ip,
+                                      fluentd_port=self.config.fluentd.port)
+            sender.runlogdate = fluent_logger.runlogdate
         summary = NFVBenchSummarizer(result, sender)
         LOG.info(str(summary))
 
@@ -377,7 +380,11 @@ def parse_opts_from_cli():
     parser.add_argument('--log-file', '--logfile', dest='log_file',
                         action='store',
                         help='Filename for saving logs',
-                        metavar='<log_file>')
+                        metavar='<log_file>'),
+
+    parser.add_argument('--user-label', '--userlabel', dest='user_label',
+                        action='store',
+                        help='Custom label for performance records')
 
     opts, unknown_opts = parser.parse_known_args()
     return opts, unknown_opts
@@ -457,7 +464,10 @@ def main():
 
         if opts.summary:
             with open(opts.summary) as json_data:
-                print NFVBenchSummarizer(json.load(json_data), None)
+                result = json.load(json_data)
+                if opts.user_label:
+                    result['config']['user_label'] = opts.user_label
+                print NFVBenchSummarizer(result, fluent_logger)
             sys.exit(0)
 
         # show default config in text/yaml format