Skip to content

Commit 561bc45

Browse files
committed
Add the monitor role
Signed-off-by: Xavi Hernandez <[email protected]>
1 parent f03565a commit 561bc45

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: Stop monitoring if enabled
3+
include_tasks: stop.yml
4+
5+
- name: Launch background sadc monitoring
6+
shell:
7+
executable: /bin/bash
8+
cmd: >-
9+
nohup /usr/lib64/sa/sadc -S XALL 1 </dev/null 2>/dev/null
10+
> >(nohup xz - >{{ config.statedir }}/sadc_{{ name }}.xz 2>/dev/null) &
11+
echo ${!} >/tmp/sadc.pid
12+
13+
- name: Wait few seconds to monitor idle activity
14+
pause:
15+
seconds: 5
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Check if sadc is running
3+
stat:
4+
path: /tmp/sadc.pid
5+
get_attributes: false
6+
get_checksum: false
7+
get_mime: false
8+
register: sadc_pid
9+
10+
- name: Stop sadc if running
11+
when: sadc_pid.stat.exists
12+
block:
13+
- name: Wait few seconds to monitor idle activity
14+
pause:
15+
seconds: 5
16+
17+
- name: Stop sadc
18+
shell:
19+
executable: /bin/bash
20+
cmd: "kill -TERM $(cat /tmp/sadc.pid) && rm -f /tmp/sadc.pid"

playbooks/hosts.update.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
- ansible/config.yml
1010
roles:
1111
- hosts.update
12+
- monitor
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- name: Install sysstat
3+
yum:
4+
name: sysstat
5+
state: latest
6+
7+
- name: Disable sysstat service and timers
8+
systemd:
9+
name: "{{ item }}"
10+
enabled: false
11+
masked: true
12+
state: stopped
13+
loop:
14+
- sysstat
15+
- sysstat-collect.timer
16+
- sysstat-summary.timer
17+
18+
- name: Make sure statedir is present
19+
file:
20+
path: "{{ config.statedir }}"
21+
state: directory

0 commit comments

Comments
 (0)