aboutsummaryrefslogtreecommitdiffstats
path: root/resources/metric/nDPI.yaml
blob: 79225443e28802e544e3ffe54d5b92cdd27cd197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
##############################################################################
# Copyright (c) 2017 ZTE Corporation and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################


- name: prepare sample pcap file
  get_url:
    url: "https://build.opnfv.org/artifacts.opnfv.org/qtip/utilities/test.pcap"
    dest: "{{ qtip_dump }}/localhost/{{ nDPI_file }}"
    validate_certs: no  # required when using proxy for https
  run_once: yes
  delegate_to: localhost

- name: installing nDPI dependencies if CentOS
  yum:
    name: '{{ item }}'
    state: present
  when: ansible_os_family == "RedHat"
  with_items:
    - git
    - gcc
    - patch
    - perl-Time-HiRes
    - autofconf
    - automake
    - libpcap-devel libtool

- name: installing nDPI dependencies if Ubuntu
  apt:
    name: build-essential
    state: present
  when: ansible_os_family == "Debian"

- name: making nDPI temporary directory
  file:
    path: "{{ nDPI_cwd }}"
    state: directory

- name: clone nDPI
  git:
    repo: https://github.com/ntop/nDPI.git
    dest: "{{ nDPI_cwd }}"
    depth: 1
    update: no

- name: build nDPI library
  command: '{{ item }}'
  with_items:
    - ./autogen.sh
    - ./configure
    - make
  args:
    chdir: "{{ nDPI_cwd }}"
    creates: example/ndpiReader

- name: copy sample packet file
  copy:
    src: "{{ qtip_dump }}/localhost/{{ nDPI_file }}"
    dest: "{{ nDPI_cwd }}/example/{{ nDPI_file }}"

- name:
  command: "./ndpiReader -i {{ nDPI_file }}"
  args:
    chdir: "{{ nDPI_cwd }}/example/"
  register: nDPI_out

- name: collect DPI metrics from nDPI
  collect:
    string: "{{ nDPI_out.stdout }}"
    patterns:
      - '^\s+nDPI throughput:.+?(?P<pps>\d+.\d+)\s.+\spps.+?(?P<bps>\d+.\d+)\s.+\/sec'
    dump: 'nDPI.log'
  register: dpi_metrics