Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add monitoring support #50

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playbooks/ansible/client-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: clients
- hosts: all
become: yes
become_method: sudo
vars_files:
Expand Down
15 changes: 15 additions & 0 deletions playbooks/ansible/roles/monitor/tasks/start.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Stop monitoring if enabled
include_tasks: stop.yml

- name: Launch background sadc monitoring
shell:
executable: /bin/bash
cmd: >-
nohup /usr/lib64/sa/sadc -S XALL 1 </dev/null 2>/dev/null
> >(nohup xz - >{{ config.statedir }}/sadc_{{ name }}.xz 2>/dev/null) &
echo ${!} >/tmp/sadc.pid

- name: Wait few seconds to monitor idle activity
pause:
seconds: 5
20 changes: 20 additions & 0 deletions playbooks/ansible/roles/monitor/tasks/stop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Check if sadc is running
stat:
path: /tmp/sadc.pid
get_attributes: false
get_checksum: false
get_mime: false
register: sadc_pid

- name: Stop sadc if running
when: sadc_pid.stat.exists
block:
- name: Wait few seconds to monitor idle activity
pause:
seconds: 5

- name: Stop sadc
shell:
executable: /bin/bash
cmd: "kill -TERM $(cat /tmp/sadc.pid) && rm -f /tmp/sadc.pid"
16 changes: 16 additions & 0 deletions playbooks/ansible/roles/tests/tasks/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
line: "PREPARING {{ role }}"

- name: Prepare test {{ role }}
when: inventory_hostname in groups['clients']
include_role:
name: "{{ role }}"
tasks_from: prepare/main.yml

- name: Process test {{ role }}
block:
- name: Start monitoring
include_role:
name: monitor
tasks_from: start.yml
vars:
name: "{{ role }}"

- name: Log test start time
include_tasks: log.yml
vars:
line: "RUNNING {{ role }}"

- name: Run test {{ role }}
when: inventory_hostname in groups['clients']
include_role:
name: "{{ role }}"

Expand All @@ -27,6 +36,7 @@
line: "RECOVERING {{ role }}"

- name: Recover from failure of {{ role }}
when: inventory_hostname in groups['clients']
include_role:
name: "{{ role }}"
tasks_from: recover/main.yml
Expand All @@ -41,7 +51,13 @@
vars:
line: "FINISHED {{ role }}"

- name: Stop monitoring
include_role:
name: monitor
tasks_from: stop.yml

- name: Cleanup for {{ role }}
when: inventory_hostname in groups['clients']
include_role:
name: "{{ role }}"
tasks_from: cleanup/main.yml
Expand Down
1 change: 1 addition & 0 deletions playbooks/hosts.update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
- ansible/config.yml
roles:
- hosts.update
- monitor
21 changes: 21 additions & 0 deletions playbooks/roles/monitor/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Install sysstat
yum:
name: sysstat
state: latest

- name: Disable sysstat service and timers
systemd:
name: "{{ item }}"
enabled: false
masked: true
state: stopped
loop:
- sysstat
- sysstat-collect.timer
- sysstat-summary.timer

- name: Make sure statedir is present
file:
path: "{{ config.statedir }}"
state: directory
Loading