Ceph report fixes and Ceph bench beta 0.1

- Ceph stats collection
- Updated Ceph results averages calculations

Fixes:
- Fixed huge PG dump copying >30MB jsons
- Fixes for the fio-runner constants

 Related-PROD: PROD-36669

Change-Id: Id8e250f626dfdaecc12ad005b61d03a21c9e6c4e
diff --git a/cfg_checker/modules/ceph/__init__.py b/cfg_checker/modules/ceph/__init__.py
index f9bf3ca..dd483cf 100644
--- a/cfg_checker/modules/ceph/__init__.py
+++ b/cfg_checker/modules/ceph/__init__.py
@@ -1,4 +1,5 @@
 from cfg_checker.agent.fio_runner import get_fio_options
+from cfg_checker.agent.fio_runner import seq_modes, mix_modes
 from cfg_checker.common import logger_cli
 from cfg_checker.common.settings import ENV_TYPE_KUBE
 from cfg_checker.helpers import args_utils
@@ -29,6 +30,11 @@
 #     else:
 #         return _class
 
+def _get_param_and_log(arg, param_str):
+    _value = args_utils.get_arg(arg, param_str)
+    logger_cli.info("    {}={}".format(param_str, _value))
+    return _value
+
 
 def init_parser(_parser):
     # network subparser
@@ -107,6 +113,56 @@
         metavar="dump_results", default="/tmp",
         help="Dump result after each test run to use them later"
     )
+    ceph_bench_parser.add_argument(
+        '--name',
+        metavar="name", default="cephbench",
+        help="Dump result after each test run to use them later"
+    )
+    ceph_bench_parser.add_argument(
+        '--bs',
+        metavar="blocksize", default="16k",
+        help="Block size for single run"
+    )
+    ceph_bench_parser.add_argument(
+        '--iodepth',
+        metavar="iodepth", default="16",
+        help="IO Depth for single run"
+    )
+    ceph_bench_parser.add_argument(
+        '--size',
+        metavar="size", default="10G",
+        help="Persistent volume size (M, G)"
+    )
+    ceph_bench_parser.add_argument(
+        '--readwrite',
+        metavar="readwrite", default="randrw",
+        help="Test mode for single run"
+    )
+    ceph_bench_parser.add_argument(
+        '--rwmixread',
+        metavar="rwmixread", default="50",
+        help="Percent of read in randon mixed mode (randrw)"
+    )
+    ceph_bench_parser.add_argument(
+        '--ramp-time',
+        metavar="ramp_time", default="5s",
+        help="Warmup time before test"
+    )
+    ceph_bench_parser.add_argument(
+        '--runtime',
+        metavar="runtime", default="60s",
+        help="Time based test run longevity"
+    )
+    ceph_bench_parser.add_argument(
+        '--ioengine',
+        metavar="ioengine", default="libaio",
+        help="IO Engine used by fio. See eng-help output in fio for list"
+    )
+    ceph_bench_parser.add_argument(
+        '--offset-increment',
+        metavar="offset_increment", default="500M",
+        help="IO Engine used by fio. See eng-help output in fio for list"
+    )
 
     return _parser
 
@@ -183,10 +239,12 @@
     # Prepare the tasks and do synced testrun or a single one
     logger_cli.info("# Initializing ceph benchmark module")
     args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
+    # Report filename
     _filename = args_utils.get_arg(args, 'html')
     # agents count option
     config.bench_agent_count = args_utils.get_arg(args, "agents")
     logger_cli.info("-> using {} agents".format(config.bench_agent_count))
+    # Cleaning option
     config.no_cleaning_after_benchmark = args_utils.get_arg(args, "no_cleanup")
     # storage class
     _storage_class = args_utils.get_arg(args, "storage_class")
@@ -204,15 +262,38 @@
         )
         config.bench_results_dump_path = _dump_path
     # Task files or options
+    _opts = get_fio_options()
     _task_file = args_utils.get_arg(args, "task_file", nofail=True)
     if not _task_file:
-        logger_cli.info("-> running single run")
+        logger_cli.info("-> Running single benchmark run")
         config.bench_mode = "single"
+        # Updating _opts from arguments
+        _params = [
+            "bs",
+            "iodepth",
+            "size",
+            "readwrite",
+            "ramp_time",
+            "runtime",
+            "ioengine"
+        ]
+        for _p in _params:
+            _opts[_p] = _get_param_and_log(args, _p)
+        if _opts["readwrite"] in seq_modes:
+            _p = "offset_increment"
+            _opts[_p] = _get_param_and_log(args, _p)
+        elif _opts["readwrite"] in mix_modes:
+            _p = "rwmixread"
+            _opts[_p] = _get_param_and_log(args, _p)
     else:
         logger_cli.info("-> running with tasks from '{}'".format(_task_file))
         config.bench_task_file = _task_file
         config.bench_mode = "tasks"
-    _opts = get_fio_options()
+    config.bench_name = args_utils.get_arg(args, "name")
+    _opts["name"] = config.bench_name
+    logger_cli.info(
+        "# Using '{}' as ceph bench jobs name".format(_opts["name"])
+    )
     logger_cli.debug("... default/selected options for fio:")
     for _k in _opts.keys():
         # TODO: Update options for single run
@@ -223,6 +304,8 @@
     # init the Bench class
     ceph_bench = bench.KubeCephBench(config)
     ceph_bench.set_ceph_info_class(ceph_info)
+    # Preload previous results for this name
+    ceph_bench.preload_results()
     # Do the testrun
     ceph_bench.prepare_agents(_opts)
     ceph_bench.wait_ceph_cooldown()