diff options
author | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2017-04-23 19:37:16 +0800 |
---|---|---|
committer | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2017-04-24 08:53:40 +0800 |
commit | 48d36caabb09f2456a1d7ad64acb7aa099277eda (patch) | |
tree | 748c4bd2a5d4c3e2f6fc76a77b358f8174d598ab | |
parent | e579659699b4571a69990efc5861914e4701a4f6 (diff) |
Save logs before collecting
Change-Id: I0e39103ef917fa7ea86d5c47de0cc71c37fca74c
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
-rw-r--r-- | qtip/ansible_library/plugins/action/collect.py | 15 | ||||
-rw-r--r-- | resources/ansible_roles/inxi/tasks/main.yml | 13 | ||||
-rw-r--r-- | resources/ansible_roles/nDPI/tasks/main.yml | 19 | ||||
-rw-r--r-- | resources/ansible_roles/openssl/tasks/main.yml | 28 | ||||
-rw-r--r-- | resources/ansible_roles/ramspeed/tasks/main.yml | 35 |
5 files changed, 70 insertions, 40 deletions
diff --git a/qtip/ansible_library/plugins/action/collect.py b/qtip/ansible_library/plugins/action/collect.py index f6ae7a5c..88ad0e35 100644 --- a/qtip/ansible_library/plugins/action/collect.py +++ b/qtip/ansible_library/plugins/action/collect.py @@ -10,7 +10,6 @@ ############################################################################## from collections import defaultdict -import os import re from ansible.plugins.action import ActionBase @@ -27,12 +26,6 @@ class ActionModule(ActionBase): string = self._task.args.get('string') patterns = self._task.args.get('patterns') - dump = self._task.args.get('dump') - if dump is not None: - root = task_vars.get('qtip_results', 'results') - base = task_vars.get('dump_base', 'dump') - dump_facts([{'name': dump, 'content': string}], root, base) - return collect(patterns, string) @@ -50,11 +43,3 @@ def collect(patterns, string): captured[key].append(value) return captured - - -def dump_facts(facts, root, base): - dest = os.path.join(root, base) - if not os.path.exists(dest): - os.makedirs(dest) - return [{'name': fact['name'], 'result': open(os.path.join(dest, fact['name']), 'w+').write(fact['content'])} - for fact in facts] diff --git a/resources/ansible_roles/inxi/tasks/main.yml b/resources/ansible_roles/inxi/tasks/main.yml index 0267b680..6d041e3f 100644 --- a/resources/ansible_roles/inxi/tasks/main.yml +++ b/resources/ansible_roles/inxi/tasks/main.yml @@ -16,6 +16,16 @@ command: inxi -b -c0 -n register: inxi_out +- name: generating log filename + set_fact: + logfile: "{{ qtip_results }}/inxi.log" + +- name: saving output to log + copy: + content: "{{ inxi_out.stdout }}" + dest: "{{ logfile }}" + delegate_to: localhost + # TODO(yujunz) normalize system information, test condition and performance metrics for future data mining # e.g. convert "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz" to # --- @@ -31,7 +41,7 @@ # cache_mb: None - name: collect system information from inxi collect: - string: "{{ inxi_out.stdout }}" + string: "{{ lookup('file', logfile) }}" patterns: - '.+\s+Host:\s+(?P<hostname>.+)\sKernel' - '.+\sMemory:\s+(?P<memory>.+MB)\s' @@ -42,6 +52,7 @@ - '.+\sproduct:\s+(?P<product>.+)\sv' dump: 'inix.log' register: system_info + delegate_to: localhost - name: create system information report template: diff --git a/resources/ansible_roles/nDPI/tasks/main.yml b/resources/ansible_roles/nDPI/tasks/main.yml index e8d359e5..230ee2e1 100644 --- a/resources/ansible_roles/nDPI/tasks/main.yml +++ b/resources/ansible_roles/nDPI/tasks/main.yml @@ -43,25 +43,34 @@ checksum: "sha256:ac5d1501d91a6d8a8d3bfcef6f74a87bf660cd2c2ab11b9791535aa5193e4f71" validate_certs: no # required when using proxy for https -- name: +- name: measuring dpi performance command: "./ndpiReader -i {{ sample_pcap }}" args: chdir: "{{ workdir }}/nDPI-1.6/example/" register: ndpi_out -- name: collect DPI metrics from nDPI +- name: generating log filename + set_fact: + logfile: "{{ qtip_results }}/nDPI.log" + +- name: saving output to log + copy: + content: "{{ ndpi_out.stdout }}" + dest: "{{ logfile }}" + delegate_to: localhost + +- name: collecting DPI metrics collect: - string: "{{ ndpi_out.stdout }}" + string: "{{ lookup('file', logfile) }}" patterns: # nDPI throughput: 1.46 M pps / 13.69 Gb/sec # TODO(yujunz) convert "M pps" and "K pps" to number - 'nDPI throughput:\s+?(?P<dpi_pps>\d+.\d+.*) \/ (?P<dpi_bps>\d+.\d+.*)$' - dump: 'nDPI.log' register: dpi_metrics + delegate_to: localhost - name: create dpi report template: src: dpi-metrics.j2 dest: "{{ qtip_results }}/dpi-metrics" delegate_to: localhost - tags: [report] diff --git a/resources/ansible_roles/openssl/tasks/main.yml b/resources/ansible_roles/openssl/tasks/main.yml index 864d0946..9829de24 100644 --- a/resources/ansible_roles/openssl/tasks/main.yml +++ b/resources/ansible_roles/openssl/tasks/main.yml @@ -14,15 +14,34 @@ - name: RSA signatures speed measurement command: openssl speed rsa - register: openssl_rsa_log + register: openssl_rsa_out - name: AES speed measurement command: openssl speed -evp aes-128-cbc - register: openssl_aes_log + register: openssl_aes_out + + +- name: generating log filename + set_fact: + rsa_logfile: "{{ qtip_results }}/openssl_rsa.log" + aes_logfile: "{{ qtip_results }}/openssl_aes.log" + +# TODO(yujunz) `delegate_to` not working under `with_items` +- name: saving rsa output to log + copy: + content: "{{ openssl_rsa_out.stdout }}" + dest: "{{ rsa_logfile }}" + delegate_to: localhost + +- name: saving aes output to log + copy: + content: "{{ openssl_aes_out.stdout }}" + dest: "{{ aes_logfile }}" + delegate_to: localhost - name: collect ssl rsa metrics collect: - string: "{{ openssl_rsa_log.stdout }}" + string: "{{ lookup('file', rsa_logfile) }}" patterns: - |- ^rsa\s+512\sbits\s.+\s+ @@ -40,12 +59,11 @@ ^rsa\s+4096\sbits\s.+\s+ ?(?P<rsa_sign_4096>\d+\.\d)\s+ ?(?P<rsa_verify_4096>\d+\.\d)$ - dump: openssl_rsa.log register: ssl_rsa_metrics - name: collect ssl aes metrics collect: - string: "{{ openssl_aes_log.stdout }}" + string: "{{ lookup('file', aes_logfile) }}" patterns: - |- ^aes-128-cbc\s+ diff --git a/resources/ansible_roles/ramspeed/tasks/main.yml b/resources/ansible_roles/ramspeed/tasks/main.yml index 2ecf4279..bdb23b6c 100644 --- a/resources/ansible_roles/ramspeed/tasks/main.yml +++ b/resources/ansible_roles/ramspeed/tasks/main.yml @@ -11,14 +11,12 @@ file: path: "{{ workdir }}" state: directory - tags: [setup] - name: downloading ramsmp get_url: url: http://www.alasir.com/software/ramspeed/ramsmp-3.5.0.tar.gz dest: "{{ workdir }}" checksum: "sha256:39fb15493fb3c293575746d56f6ab9faaa1d876d8b1f0d8e5a4042d2ace95839" - tags: [setup] - name: extracting ramsmp # TODO(yujunz) unarchive may not work with long path (local: macOS, workdir: /root/qtip-workdir-20170423-0836/) @@ -32,51 +30,60 @@ args: chdir: "{{ workdir }}/ramsmp-3.5.0" creates: ramsmp - tags: [setup] - name: intmem benchmarking command: ./ramsmp -b 3 -l 5 -p 1 args: chdir: "{{ workdir }}/ramsmp-3.5.0" - register: ramsmp_intmem_out - tags: [run] + register: ramsmp_int_out - name: floatmem benchmarking command: ./ramsmp -b 6 -l 5 -p 1 args: chdir: "{{ workdir }}/ramsmp-3.5.0" - register: ramsmp_floatmem_out - tags: [run] + register: ramsmp_float_out + +- name: generating log filename + set_fact: + int_logfile: "{{ qtip_results }}/ramsmp-int.log" + float_logfile: "{{ qtip_results }}/ramsmp-float.log" + +- name: saving integer output to log + copy: + content: "{{ ramsmp_int_out.stdout }}" + dest: "{{ int_logfile }}" + delegate_to: localhost + +- name: saving floating point output to log + copy: + content: "{{ ramsmp_float_out.stdout }}" + dest: "{{ float_logfile }}" + delegate_to: localhost - name: collect integer memory metrics from ramspeed collect: - string: "{{ ramsmp_intmem_out.stdout }}" + string: "{{ lookup('file', int_logfile) }}" patterns: - '^INTEGER\s+BatchRun\s+Copy:\s+?(?P<copy>\d+\.\d+)\sMB/s$' - '^INTEGER\s+BatchRun\s+Scale:\s+?(?P<scale>\d+\.\d+)\sMB/s$' - '^INTEGER\s+BatchRun\s+Add:\s+?(?P<add>\d+\.\d+)\sMB/s$' - '^INTEGER\s+BatchRun\s+Triad:\s+?(?P<triad>\d+\.\d+)\sMB/s$' - '^INTEGER\s+BatchRun\s+AVERAGE:\s+?(?P<average>\d+\.\d+)\sMB/s$' - dump: 'ramsmp-intmem.log' register: intmem_metrics - tags: [collect] - name: collect float memory metrics from ramspeed collect: - string: "{{ ramsmp_floatmem_out.stdout }}" + string: "{{ lookup('file', float_logfile) }}" patterns: - '^FL-POINT\s+BatchRun\s+Copy:\s+?(?P<copy>\d+\.\d+)\sMB/s$' - '^FL-POINT\s+BatchRun\s+Scale:\s+?(?P<scale>\d+\.\d+)\sMB/s$' - '^FL-POINT\s+BatchRun\s+Add:\s+?(?P<add>\d+\.\d+)\sMB/s$' - '^FL-POINT\s+BatchRun\s+Triad:\s+?(?P<triad>\d+\.\d+)\sMB/s$' - '^FL-POINT\s+BatchRun\s+AVERAGE:\s+?(?P<average>\d+\.\d+)\sMB/s$' - dump: 'ramsmp-floatmem.log' register: floatmem_metrics - tags: [collect] - name: create memory metrics report template: src: "memory-metrics.j2" dest: "{{ qtip_results }}/memory-metrics" delegate_to: localhost - tags: [report] |