aboutsummaryrefslogtreecommitdiff
path: root/roles/collect-collectd/tasks/main.yml
blob: 779034b451e05865bd32579d0b53badd858c6dc7 (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
---
- name: copy rrdtool_graph file
  copy:
    src: rrdtool_graph.py
    dest: /usr/local/bin/rrdtool_graph
    mode: 0755
  become: true

- name: stop collectd service
  service:
    name: collectd
    state: stopped
  become: true

- name: generate image folder
  file:
    path: "/tmp/rrd_graph"
    state: directory
  become: true

- name: generate load graph
  command: "/usr/local/bin/rrdtool_graph --file /var/lib/collectd/rrd/{{ ansible_fqdn }}/load/load.rrd --output /tmp/rrd_graph/load.png"
  ignore_errors: true
  become: true

- name: generate memory graph
  command: "/usr/local/bin/rrdtool_graph --file /var/lib/collectd/rrd/{{ ansible_fqdn }}/memory/*.rrd --stack --area --output /tmp/rrd_graph/memory.png"
  ignore_errors: true
  become: true

- name: generate interface graph
  command: "/usr/local/bin/rrdtool_graph --file /var/lib/collectd/rrd/{{ ansible_fqdn }}/interface-{{ ansible_default_ipv4.interface }}/if_packets.rrd --output /tmp/rrd_graph/interface-{{ ansible_default_ipv4.interface }}.png"
  ignore_errors: true
  become: true

- name: generate graph.html
  vars:
    graphs:
      - load.png
      - memory.png
      - "interface-{{ ansible_default_ipv4.interface }}.png"
  template:
    src: graph.html.j2
    dest: /tmp/rrd_graph/graph.html
  ignore_errors: true
  become: true

- name: copy graph files
  synchronize:
    src: "/tmp/rrd_graph"
    dest: "{{ zuul.executor.log_root }}"
    mode: pull
    copy_links: true
    verify_host: true

- name: copy collectd rrd files
  synchronize:
    src: "/var/lib/collectd/rrd"
    dest: "{{ zuul.executor.log_root }}"
    mode: pull
    copy_links: true
    verify_host: true

- name: start collectd service
  service:
    name: collectd
    state: started
  become: true