summaryrefslogtreecommitdiffstats
path: root/plugins/barometer/roles/collectd/tasks/collectd.yml
blob: 0f6a6266cd839d909f5e6e0f5209dfac75d91b9c (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# #############################################################################
# Copyright (c) 2017-18 Intel Corp.
#
# 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: copy install_docker script
  remote_user: root
  copy:
    src: install_docker.sh
    dest: /opt/install_docker.sh
    mode: 0777

- name: install docker
  command: su -s /bin/sh -c "/opt/install_docker.sh"

- name: create collectd_sample_configs dir
  remote_user: root
  shell: |
    rm -rf /root/collectd_sample_configs;
    mkdir /root/collectd_sample_configs;

- name: docker pull opnfv/barometer-collectd
  remote_user: root
  shell: |
    docker pull opnfv/barometer-collectd;
    sleep 5

- name: configure logfile conf
  remote_user: root
  template:
    src: logfile.conf.j2
    dest: /root/collectd_sample_configs/logfile.conf

- name: configure csv conf
  remote_user: root
  template:
    src: csv.conf.j2
    dest: /root/collectd_sample_configs/csv.conf

- name: check if vswitchd on host
  shell: ps -ef | grep vswitchd | grep -v grep > /dev/null
  register: vswitchd_result
  ignore_errors: "true"

- name: check if db.sock exists
  stat:
    path: /var/run/openvswitch/db.sock
  register: dbsock_result
  ignore_errors: "true"

- name: configure ovs_stats conf and ovs_events conf
  remote_user: root
  template:
    src: "{{ item }}.conf.j2"
    dest: "/root/collectd_sample_configs/{{ item }}.conf"
  when: vswitchd_result|succeeded and dbsock_result|succeeded
  with_items:
    - ovs_stats
    - ovs_events

- name: check if mcelog running on host
  shell: ps -ef | grep mcelog | grep -v grep > /dev/null
  register: mcelog_running
  ignore_errors: "true"

- name: check if mcelog exists
  shell: which mcelog > /dev/null
  register: mcelog_exists
  ignore_errors: "true"

- name: check if mcelog-client exists
  stat:
    path: /var/run/mcelog-client
  register: mcelog_client_exists
  ignore_errors: "true"

- name: configure mcelog conf
  remote_user: root
  template:
    src: mcelog.conf.j2
    dest: /root/collectd_sample_configs/mcelog.conf
  when: mcelog_running|succeeded and mcelog_exists|succeeded and mcelog_client_exists|succeeded

- name: configure collectd-aodh plugin conf
  remote_user: root
  template:
    src: collectd-aodh.conf.j2
    dest: /root/collectd_sample_configs/collectd-aodh-plugin.conf

- name: configure collectd-gnocchi plugin conf
  remote_user: root
  template:
    src: collectd-gnocchi.conf.j2
    dest: /root/collectd_sample_configs/collectd-gnocchi-plugin.conf

- name: check if hugepages folders exist on host
  stat:
    path: "{{ item }}"
  register: hugepages_result
  ignore_errors: "true"
  with_items:
    /sys/devices/system/node
    /sys/kernel/mm/hugepages

- name: configure hugepages conf
  remote_user: root
  template:
    src: hugepages.conf.j2
    dest: /root/collectd_sample_configs/hugepages.conf
  when: hugepages_result|succeeded

- name: check if rdt on host
  shell: |
    grep -q cqm* "/proc/cpuinfo"
  register: rdt_result
  ignore_errors: "true"

- name: configure rdt conf
  remote_user: root
  template:
    src: rdt.conf.j2
    dest: /root/collectd_sample_configs/rdt.conf
  when: rdt_result|succeeded

- name: load msr kernel module
  modprobe:
    name: msr
    state: present

- name: check if libvirtd on host
  shell: ps -ef | grep libvirtd | grep -v grep > /dev/null
  register: libvirt_result
  ignore_errors: "true"

- name: configure virt conf
  remote_user: root
  template:
    src: virt.conf.j2
    dest: /root/collectd_sample_configs/virt.conf
  when: libvirt_result|succeeded

- name: configure virt conf extra stats when rdt is present
  remote_user: root
  shell: |
    sed -i '/ExtraStats/s/^#//g' /root/collectd_sample_configs/virt.conf
  when: rdt_result|failed and libvirt_result|succeeded

- name: configure rrdtool conf
  template:
    src: rrdtool.conf.j2
    dest: /root/collectd_sample_configs/rrdtool.conf

- name: configure intel_pmu conf
  remote_user: root
  template:
    src: intel_pmu.conf.j2
    dest: /root/collectd_sample_configs/intel_pmu.conf

- name: configure network conf
  remote_user: root
  template:
    src: network.conf.j2
    dest: /root/collectd_sample_configs/network.conf

- name: configure default plugins
  remote_user: root
  template:
    src: default_plugins.conf.j2
    dest: /root/collectd_sample_configs/default_plugins.conf

- name: run barometer collectd container
  remote_user: root
  shell: |
    docker run -dti --net=host -v /root/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
        -v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer-collectd /run_collectd.sh