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 top-instances play #507

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions playbooks/generic/ipmi-address.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
ansible.builtin.shell: |
set -o pipefail
ipmitool lan print | grep "IP Address\s*:" | awk -F: '{ print $2 }'
args:
executable: /bin/bash
register: result
changed_when: false
when: p.stat.exists
Expand Down
25 changes: 25 additions & 0 deletions playbooks/generic/top-instances.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Get top instances
hosts: "{{ hosts_load_average|default('generic') }}"
serial: "{{ osism_serial['load_average']|default(osism_serial_default)|default(0) }}"
strategy: "{{ osism_strategy|default('linear') }}"

tasks:
- name: Get top instances
ansible.builtin.shell: |
set -o pipefail
ps -eo pcpu,cmd --sort=-pcpu --no-headers | grep OpenStack | head -n 3 | awk '{ print $0 }'
args:
executable: /bin/bash
register: result

- debug: var=result

- name: Print top instances
ansible.builtin.debug:
msg: "{{ item | ansible.builtin.regex_search('([0-9]+\\.[0-9]+).*-uuid ([a-f0-9\\-]{36})', '\\1', '\\2') }}"
loop: "{{ result.stdout_lines }}"
throttle: 1
loop_control:
index_var: loop_index
label: "{{ loop_index }}"