summaryrefslogtreecommitdiff
path: root/roles/install_monitoring/tasks/install_munin.yml
blob: 2c8da48f38f5a604965cbbd5d7db014cc0aac349 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
---
- name: install munin
  pacman:
      name: munin-node
      state: present

- name: copy munin-node config
  template:
      src: munin-node.conf.j2
      dest: /etc/munin/munin-node.conf
  notify: restart munin-node

- name: install perl-json
  pacman:
      name: perl-json
      state: present
  when: "'fastd' in group_names"

- name: copy fastd peers plugin
  copy:
      src: munin/munin_fastd_peers
      dest: /usr/lib/munin/plugins/fastd_peers_
      mode: 0755
  when: "'fastd' in group_names"

- name: copy fastd traffic plugin
  copy:
      src: munin/munin_fastd_traffic
      dest: /usr/lib/munin/plugins/fastd_traffic_
      mode: 0755
  when: "'fastd' in group_names"

- name: enable munin plugins for fastd peers
  file:
      path: /etc/munin/plugins/fastd_peers_ff{{ item.name }}
      src: /usr/lib/munin/plugins/fastd_peers_
      state: link
  with_items: "{{ sites }}"
  notify: restart munin-node
  when: "'fastd' in group_names"

- name: enable munin plugins for fastd traffic
  file:
      path: /etc/munin/plugins/fastd_traffic_ff{{ item.name }}
      src: /usr/lib/munin/plugins/fastd_traffic_
      state: link
  with_items: "{{ sites }}"
  notify: restart munin-node
  when: "'fastd' in group_names"

- name: copy fastd plugin config
  template:
      src: munin_fastd_conf.j2
      dest: /etc/munin/plugin-conf.d/fastd
  notify: restart munin-node
  when: "'fastd' in group_names"

- name: copy dhcp-pool plugin
  copy:
      src: munin/munin_dhcp_pool_plugin
      dest: /usr/lib/munin/plugins/dhcp-pool
      mode: 0755
  when: "'fastd' in group_names"

- name: enable munin plugins for dhcp
  file:
      path: /etc/munin/plugins/dhcp-pool
      src: /usr/lib/munin/plugins/dhcp-pool
      state: link
  notify: restart munin-node
  when: "'fastd' in group_names"

- name: copy global config
  copy:
      src: munin/munin_global_conf
      dest: /etc/munin/plugin-conf.d/global
  notify: restart munin-node

- name: install netstat
  pacman:
      name: net-tools
      state: present

- name: install perl-lwp-protocol-https
  pacman:
      name: perl-lwp-protocol-https
      state: present

- name: enable munin plugins for network monitoring (1/8)
  file:
      path: /etc/munin/plugins/if_{{ ansible_default_ipv4.interface }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node

- name: enable munin plugins for network monitoring (2/8)
  file:
      path: /etc/munin/plugins/if_{{ ansible_default_ipv6.interface }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node

- name: enable munin plugins for network monitoring (3/8)
  file:
      path: /etc/munin/plugins/if_{{ item[0] }}{{ item[1].name }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node
  with_nested:
      - [ 'bat', 'vpn', 'wg' ]
      - "{{ sites }}"
  when: "'fastd' in group_names"

- name: enable munin plugins for network monitoring (4/8)
  file:
      path: /etc/munin/plugins/if_bb{{ hostvars[item]['wireguard_bb_name'] }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node
  with_items: "{{ groups['uplink'] }}"
  when: "'fastd' in group_names"

- name: enable munin plugins for network monitoring (5/8)
  file:
      path: /etc/munin/plugins/if_bb{{ hostvars[item]['wireguard_bb_name'] }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node
  with_items: "{{ groups['fastd'] }}"
  when: "'uplink' in group_names"

- name: enable munin plugins for network monitoring (6/8)
  file:
      path: /etc/munin/plugins/if_bb{{ item.name }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node
  with_items: "{{ wireguard_bb_peers|default([]) }}"
  when: "'uplink' in group_names"

- name: enable munin plugins for network monitoring (7/8)
  file:
      path: /etc/munin/plugins/if_bb{{ item.name }}
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node
  with_items: "{{ ffrl_peers }}"
  when: "'ffrl_uplink' in group_names"

- name: enable munin plugins for network monitoring (8/8)
  file:
      path: /etc/munin/plugins/if_mullvad
      src: /usr/lib/munin/plugins/if_
      state: link
  notify: restart munin-node
  when: "'mullvad_uplink' in group_names"

- name: enable munin plugins
  file:
      path: /etc/munin/plugins/{{ item }}
      src: /usr/lib/munin/plugins/{{ item }}
      state: link
  with_items:
      - cpu
      - df
      - df_inode
      - diskstats
      - entropy
      - forks
      - fw_conntrack
      - fw_forwarded_local
      - fw_packets
      - interrupts
      - irqstats
      - load
      - memory
      - netstat
      - nginx_request
      - nginx_status
      - ntp_kernel_err
      - ntp_kernel_pll_freq
      - ntp_kernel_pll_off
      - ntp_offset
      - open_files
      - open_inodes
      - proc_pri
      - processes
      - threads
      - uptime
      - users
      - vmstat
  notify: restart munin-node

- name: start and enable munin-node
  systemd:
      name: munin-node.service
      enabled: yes
      state: started