Files
bab-backend-ansible/playbooks/investigate_high_cpu.yml

31 lines
1.0 KiB
YAML

---
- name: Investigate High CPU
hosts: all
become: true
tasks:
- name: Gather information on top CPU consuming processes
ansible.builtin.command:
cmd: 'ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%cpu'
register: processes_cpu
changed_when: false
- name: Gather information on top Memory consuming processes
ansible.builtin.command:
cmd: 'ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%mem'
register: processes_mem
changed_when: false
- name: Create Problem Template
ansible.builtin.set_fact:
incident_report: "{{ lookup('template', '../templates/cpuhog_ticket.j2') }}"
- name: Create SNow Incident
servicenow.itsm.incident:
state: new
caller: "admin"
short_description: "CPUHog event detected on: {{ event.alert.labels.instance }}"
description: "A CPUHog was detected on: {{ event.alert.labels.instance }} that needs to be investigated."
impact: high
urgency: high
delegate_to: localhost