Skip to content

Commit

Permalink
Add top-instances play
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt committed Oct 7, 2024
1 parent f622ead commit 8c6771b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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
23 changes: 23 additions & 0 deletions playbooks/generic/top-instances.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- 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

- 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 }}"

0 comments on commit 8c6771b

Please sign in to comment.